Skip to content

ceph-volume zap: improve zapping to remove all partitions and all LVs, encrypted or not#25330

Merged
alfredodeza merged 21 commits intoceph:masterfrom
alfredodeza:wip-rm37449
Nov 30, 2018
Merged

ceph-volume zap: improve zapping to remove all partitions and all LVs, encrypted or not#25330
alfredodeza merged 21 commits intoceph:masterfrom
alfredodeza:wip-rm37449

Conversation

@alfredodeza
Copy link
Contributor

@alfredodeza alfredodeza commented Nov 29, 2018

In order to be able to destroy devices/partitions/lvs related to an OSD ID a major rework had to be done for zapping, that properly detects them and fully removes them. Introduces the ability to fully remove partitions.

Fixes some related issues like:

  • skip removal of non existing vgs (present when two devices are zapped that belong to the same vg)
  • fixes detection of devices in the Device class (adds tests)
  • adds a Device.vgs attribute to avoid having to fetch the vgs every time they are needed
  • sets partitions as a top level key when scanning disks, fixes a bug with partition scanning that was trying to enforce a '1' value in partition which was incorrect.
  • Adds a holders key to the partition device scanning, to help in encrypted status detection from a partition.
  • creates a udevadm helper to provide extra information about devices

Fixes: http://tracker.ceph.com/issues/37449

return _udevadm_parser(out)


def _udevadm_parser(output):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jan--f this work includes this version of the parser, I am not clear if we decided to keep pursuing PR #25201 or if that is on hold for now. In any case, I am happy to consume your version if that gets pushed through.

This helper is needed to determine the partition number so that we can remove partitions accordingly

Copy link
Contributor

Choose a reason for hiding this comment

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

#25201 is not on hold afaik, I just need to deal with the FreeBDS portion.

@alfredodeza
Copy link
Contributor Author

jenkins test ceph-volume lvm

jan--f
jan--f previously requested changes Nov 30, 2018
Copy link
Contributor

@jan--f jan--f left a comment

Choose a reason for hiding this comment

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

Other then the contentious error handling this looks very useful. 👍

for line in output:
try:
key, value = line.split('=')
except ValueError:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have anything against this except for the silent error swallowing. I know there is a log statement now but the code still continues with bad input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are you suggesting a hard fail? Or what would you propose here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could add a logging statement to the terminal. I would prefer not have a hard fail. An non-parseable line should not prevent gathering metadata for a partition

Copy link
Contributor

@jan--f jan--f Nov 30, 2018

Choose a reason for hiding this comment

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

Are you suggesting a hard fail? Or what would you propose here

Yes as discussed in #25201.

We could add a logging statement to the terminal. I would prefer not have a hard fail. An non-parseable line should not prevent gathering metadata for a partition

I think it very much should fail since we don't know at all what is in the output. One line failing (and being skipped) does not mean that the other parsed lines might no contain something that causes a bug somewhere else. When we detect that one line is not as expected, we should assume the whole invocation of udevadm, and thus the whole returned output is bad.

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 am going to respectfully disagree here. I understand your concern, but this is type of parsing and handling of output is how we process pretty much everything else in ceph-volume.

That doesn't mean it is a good reason to introduce something that can be improved, but this type of parsing is good enough for what we need, and IMO we shouldn't fail hard. In any case, the consumer of the produced output can chose to fail hard (as we do for udevadm())

Copy link
Contributor

Choose a reason for hiding this comment

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

Look if this scenario ever happens this code logs that there is something wrong with the output and then continue anyway with this unknown output (there might be a '=' in one of the output lines). I think this is not useful behaviour and potentially dangerous.

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 current usage is just to retrieve the partition number. I see your point of potential breakage with a = in the value side of things.

That doesn't represent a dangerous behavior for determining partition numbers, but I agree that it might be better to have a strict mode where the caller may set a hard failure in case there are errors in parsing.

I have created http://tracker.ceph.com/issues/37488 to follow up on that. The current use case does not warrant a strict mode.

Copy link
Contributor

Choose a reason for hiding this comment

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

#25201 is ready to merge. We might as well just go with that.

@alfredodeza
Copy link
Contributor Author

jenkins test ceph-volume tox

Alfredo Deza added 21 commits November 30, 2018 12:19
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Before, the `if` condition meant that it would only work when the output
was '1', which is incorrect as that would only happen if a partition was
the first one, ignoring any other partition. The contents of that file
is the partition number, not a boolean to tell if it is a partition or
not.

It now includes the `holders` file contents which is needed for
dm-mapper work

Signed-off-by: Alfredo Deza <adeza@redhat.com>
…devices

Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
…property

Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
…nd mapper devices

Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
…ith --destroy

Signed-off-by: Alfredo Deza <adeza@redhat.com>
…loy after zapping

Signed-off-by: Alfredo Deza <adeza@redhat.com>
…redeploy after zapping

Signed-off-by: Alfredo Deza <adeza@redhat.com>
Signed-off-by: Alfredo Deza <adeza@redhat.com>
…n a test

Signed-off-by: Alfredo Deza <adeza@redhat.com>
@alfredodeza alfredodeza dismissed jan--f’s stale review November 30, 2018 18:40

pr #25201 from @jan--f got merged, the udevadm changes got dropped in this PR

@alfredodeza alfredodeza merged commit 8a50070 into ceph:master Nov 30, 2018
@alfredodeza
Copy link
Contributor Author

@jan--f had to add commit 9f440fb to patch udevadm calls to the Device class. On systems where there isn't a udevadm executable the tests would break.

@dotnwat
Copy link
Contributor

dotnwat commented Nov 30, 2018

i'm so happy right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants