Skip to content

Conversation

@cospotato
Copy link
Contributor

@cospotato cospotato commented Aug 30, 2021

Pull Request template

Why is this PR required? What issue does it fix?: #621

What this PR does?: Add partition table uuid support

Does this PR require any upgrade changes?: No

If the changes in this PR are manually verified, list down the scenarios covered::

  • on CentOS 7 host: 🆗
  • on CentOS 8 host: 🆗
  • on Ubuntu 16.04 host: 🆗

Any additional information for your reviewer? :
Mention if this PR is part of any design or a continuation of previous PRs

Checklist:

@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2021

Codecov Report

Merging #635 (83b0750) into develop (1fcc2b6) will decrease coverage by 0.89%.
The diff coverage is 7.46%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #635      +/-   ##
===========================================
- Coverage    46.58%   45.69%   -0.90%     
===========================================
  Files           78       79       +1     
  Lines         3834     3889      +55     
===========================================
- Hits          1786     1777       -9     
- Misses        1888     1953      +65     
+ Partials       160      159       -1     
Impacted Files Coverage Δ
cmd/ndm_daemonset/probe/addhandler.go 69.43% <0.00%> (-4.97%) ⬇️
cmd/ndm_daemonset/probe/blkidprobe.go 0.00% <0.00%> (ø)
cmd/ndm_daemonset/probe/probe.go 100.00% <ø> (ø)
pkg/features/features.go 100.00% <ø> (ø)
pkg/partition/partition.go 30.26% <0.00%> (-11.56%) ⬇️
cmd/ndm_daemonset/probe/eventhandler.go 28.94% <14.28%> (-0.39%) ⬇️
cmd/ndm_daemonset/probe/uuid.go 94.73% <57.14%> (-5.27%) ⬇️
cmd/ndm_daemonset/probe/udevprobe.go 47.43% <0.00%> (-1.59%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1fcc2b6...83b0750. Read the comment docs.

@cospotato cospotato force-pushed the master branch 2 times, most recently from 27508d1 to 2f61c8e Compare August 31, 2021 08:07
@cospotato cospotato marked this pull request as ready for review September 1, 2021 02:41
// partition table uuid instead of create partition described in
// https://github.com/openebs/node-disk-manager/issues/621 .
// This feature must enabled with GPTBasedUUID.
PartitionTableUUID Feature = "PartitionTableUUID"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add one check, to make sure this feature gets enabled only with GPTBasedUUID. The check can be added here, so that such dependent features can be checked in future also.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you missed this comment. PTAL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akhilerm Sorry, the here link previously point to the pkg/partition/partition.go file, so i add the feature check in that files. What the here point to exactly ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops. sorry for that, the check should be in the feature pkg here. So everything related to features are handled there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the check needed is, if PartitionTableUUID feature gate is given , we should make sure that GPTBasedUUID is also provided. The best place to make that check is in the feature pkg.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I get that. I will fix it!

Copy link
Contributor

@akhilerm akhilerm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cospotato Given some comments.

Also you need to update the node-disk-manager.yaml, and run make manifests so that the updated ndm-operator.yaml is generated.

@cospotato
Copy link
Contributor Author

Hello @akhilerm ,comments resolved.

limitations under the License.
*/

package probe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cospotato Do we need a new probe for fetching this details? Can this be included in some existing probes? WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akhilerm I think it's need this new probe to get partition table UUID by blkid. Because only the udevprobe can provide partition table UUID in the existing probes. But on CentOS 7, the host udev did not provide it. But we use the cache from host udev. So we cannot get partition table UUID with udev on CentOS 7 host.

case features.FeatureGates.IsEnabled(features.PartitionTableUUID) && len(bd.PartitionInfo.PartitionTableType) > 0:
if len(bd.PartitionInfo.PartitionTableUUID) == 0 {
klog.Errorf("device(%s) has a partition table, but can not get partition table uuid", bd.DevPath)
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen in the following case:

  1. The break gets executed here, which means the uuid wont be generated.
  2. NDM goes onto create a partition on the disk, but it will fail since a partition table already exists
  3. This will trigger a rescan and causes an infinite loop

Can we have some checks for the above case also, possibly in the eventhandler or addhandler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GPT partition table without UUID is very weird. But This may be happened. Or can we ignore this disk ?

@@ -1,3 +1,6 @@
//go:build (linux && ignore) || cgo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this build tag used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this and the below line changed because of my local environment is go 1.17.1 . The gofmt cause the change. The help described this: go help

To keep a file from being considered for the build:

	//go:build ignore

(any other unsatisfied word will work as well, but "ignore" is conventional.)

To build a file only when using cgo, and only on Linux and OS X:

	//go:build cgo && (linux || darwin)

It just a mark make us can set the file ignore when compiling.

@@ -1,3 +1,6 @@
//go:build (linux && ignore) || cgo
// +build linux,ignore cgo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the ignore tag do here?

Copy link
Contributor

@akhilerm akhilerm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented on a few more changes.


// IsEnabled returns true if the feature is enabled
func (fg featureFlag) IsEnabled(f Feature) bool {
if !fg.checkRequired(f) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This need not be checked everytime, since we set the flag to default value initially.

Copy link
Contributor

@z0marlin z0marlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cospotato left a few comments.

func (bp *blkidProbe) FillBlockDeviceDetails(bd *blockdevice.BlockDevice) {
di := &blkid.DeviceIdentifier{DevPath: bd.DevPath}

bd.FSInfo.FileSystem = di.GetOnDiskFileSystem()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right now udevprobe and mountprobe fill the filesystem information for the device. Is this required here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can check the bd.FSInfo.FileSystem length if zero before fill it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cospotato can you please add this check (check if FS is already filled by prior probes)

Comment on lines 159 to 166
// disable the feature if the requirement does not meet expectations
if !checkRequirement(fg, k) {
fg[k] = false
v = false

klog.Warningf("Feature gate: %s required: \"%v\" dose not meet expectation, set to disable", k, requirementString(k))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while using a map works in this scenario, it would break for cases when there are more complex requirements in which case we would have to do a graph traversal of sorts to determine if the requirements are satisfied. Although, I don't think feature gates will reach that complexity, do we want to consider those cases in this code? if not, then can we have some comments explaining the limitations for future reference. @akhilerm @cospotato wdyt?

an example that would break when using the above logic:
A requires B
B requires C
C is set to false by the user while B is set to true.
In this case, the correct setting would be A, B, C set to false. But in the code, it will depend on the order of traversal of the map and we may have a wrong setting.

Copy link
Contributor Author

@cospotato cospotato Sep 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we will never reach that complexity. There are two solution in this case:

  1. Calculate the requirement graph in initiation phase
  2. The More easier solution: calculate the requirement in IsEnabled method

I prefer the first solution. But it will introduce complexity. @z0marlin @akhilerm WDYT ?

Maybe we can create a new issue to implement this feature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also prefer the first solution. Will raise an issue to enhance the feature flag mechanism. I guess for now we will avoid those checks?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refer issue #651 for dependent features.

@cospotato cospotato force-pushed the master branch 2 times, most recently from edd089b to 2313e9c Compare September 22, 2021 03:33
@akhilerm
Copy link
Contributor

@cospotato Can you resolve the conflicts so that CI can be run

@cospotato
Copy link
Contributor Author

@cospotato Can you resolve the conflicts so that CI can be run

OK, I will fix it.

@cospotato cospotato closed this Sep 29, 2021
@cospotato
Copy link
Contributor Author

@akhilerm Can you show the the Better Code Hub report of this branch. I will try to refactor it. I tried to analysis in my repo. But it show lots of bad code smell which do not contained in this commit.

@akhilerm
Copy link
Contributor

@cospotato I think the BCH can be ignored for now as the results are from old code, which we may need to refactor.

@akhilerm
Copy link
Contributor

@cospotato The changes for dependent feature gates have been merged, Can you rebase those changes into this PR so that we can merge this.

@cospotato
Copy link
Contributor Author

@cospotato The changes for dependent feature gates have been merged, Can you rebase those changes into this PR so that we can merge this.

@akhilerm OK. I will rebase it. Thank you.

@cospotato cospotato force-pushed the master branch 2 times, most recently from c58a061 to 9d4703a Compare November 18, 2021 07:39
akhilerm
akhilerm previously approved these changes Nov 18, 2021
Copy link
Contributor

@akhilerm akhilerm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes looks good. Thanks @cospotato

Can we exclude the helm chart section from the PR, so that we can update it as part of the release? The operator.yaml is fine, since its not versioned.

@cospotato
Copy link
Contributor Author

@akhilerm Dose you means exclude the changes in deploy/helm ?

@akhilerm
Copy link
Contributor

@akhilerm Dose you means exclude the changes in deploy/helm ?

Yes

akhilerm
akhilerm previously approved these changes Nov 18, 2021
Copy link
Contributor

@akhilerm akhilerm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@z0marlin z0marlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One small change and we are good to go.

func (bp *blkidProbe) FillBlockDeviceDetails(bd *blockdevice.BlockDevice) {
di := &blkid.DeviceIdentifier{DevPath: bd.DevPath}

bd.FSInfo.FileSystem = di.GetOnDiskFileSystem()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cospotato can you please add this check (check if FS is already filled by prior probes)

@cospotato
Copy link
Contributor Author

@z0marlin Thank you. Fixed

Copy link
Contributor

@z0marlin z0marlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this :)

Copy link
Contributor

@akhilerm akhilerm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akhilerm akhilerm merged commit 8e36a0d into openebs-archive:develop Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[proposal] use DiskGUID instead of PartitionUUID

4 participants