Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ceph-disk: Add fix subcommand #13310

Merged
4 commits merged into from
Apr 5, 2017
Merged

ceph-disk: Add fix subcommand #13310

4 commits merged into from
Apr 5, 2017

Conversation

b-ranto
Copy link
Contributor

@b-ranto b-ranto commented Feb 8, 2017

This subcommand will fix the SELinux labels and/or file permissions on
ceph data (/var/lib/ceph).

The command is also optimized to run the commands in parallel (per
sub-dir in /var/lib/ceph) and do restorecon and chown at the same time
to take advantage of the caching mechanisms.

Signed-off-by: Boris Ranto branto@redhat.com

formatter_class=argparse.RawDescriptionHelpFormatter,
description=textwrap.fill(textwrap.dedent("""\
""")),
help='fix SELinux labells and/or file permissions')
Copy link
Contributor

Choose a reason for hiding this comment

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

s/labells/labels/

'+',
'-exec',
'restorecon',
'{}',
Copy link
Contributor

Choose a reason for hiding this comment

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

wrong indent.

@tchaikov tchaikov requested a review from a user February 9, 2017 09:41
@tchaikov
Copy link
Contributor

tchaikov commented Feb 9, 2017

also need to update the ceph-disk manpage.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

please add unit tests (in src/ceph-disk/tests/) and integration tests (in qa/workunits/ceph-disk/)

@b-ranto
Copy link
Contributor Author

b-ranto commented Feb 9, 2017

@tchaikov your comments should already be addressed in the latest commit
@dachary sure, I'll look into that

@b-ranto
Copy link
Contributor Author

b-ranto commented Feb 9, 2017

@dachary Hmm, I am thinking there is not much to test in the unit/integration tests. The function just calls few shell commands and it only does so if SELinux is enabled and the ceph daemons are down. I don't think we want to enable SELinux/stop daemons in the unit/integration tests, right?

I think this sounds like more of a job for teuthology to test this.

@ghost
Copy link

ghost commented Feb 9, 2017

qa/workunits/ceph-disk/ is a teuthology job, that's what I meant by "integration tests". Testing the various error cases to verify they are handled properly may be very tedious with integration tests though and it's probably enough to write unit tests to make sure they do not fail because of a typo when we need them the most ;-)

@b-ranto
Copy link
Contributor Author

b-ranto commented Feb 9, 2017

OK so I have pushed a patch that adds a unit test support. Weirdly, while testing this locally I had to use class TestCephDiskDeactivateAndDestroy instead of TestCephDisk which inherits only from object and its tests are not run.

Also, I do have a bit of a question about this. The test only works when it is run as root (we are doing chown and restorecon which require root) and in order to simulate it, I use a tmp directory. The test will fail when run as a regular user (not enough rights) but works fine when run as root/with sudo. Is this ok? Can I expect these to be run as root? It looks like my test is the only one requiring it at the moment (at least from those run by pytest).

@b-ranto b-ranto force-pushed the wip-ceph-disk-fix branch 2 times, most recently from b4a872e to 7a9a351 Compare February 9, 2017 18:23
@b-ranto
Copy link
Contributor Author

b-ranto commented Feb 9, 2017

Nevermind, I found a better way to unit test this by overriding the command* functions. This no longer needs root nor does it do any permanent changes to the system but it still exercises the python code.

@b-ranto
Copy link
Contributor Author

b-ranto commented Feb 13, 2017

@tchaikov @dachary your review concerns should already by addressed, can you re-review?

if args.all:
for directory, uid, gid, blocking, recursive in fix_table:
c = [
'find',
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tchaikov sure, the flake8 errors should be fixed, now

@ghost
Copy link

ghost commented Feb 13, 2017

@b-ranto you need to write a test that asserts it does the right thing.

@b-ranto
Copy link
Contributor Author

b-ranto commented Feb 13, 2017

@dachary I've added few asserts

@b-ranto
Copy link
Contributor Author

b-ranto commented Feb 15, 2017

@tchaikov after fixing the indentation errors, the jenkins build/test job works fine

@b-ranto
Copy link
Contributor Author

b-ranto commented Feb 16, 2017

It turns out, I forgot to add few more directories. We need to fix /var/log/ceph, /var/run/ceph and /etc/ceph as well. I fixed that in the latest commit.

Can you think of any other files/directories that need to be fixed?

@tchaikov
Copy link
Contributor

@b-ranto needs rebase,

@dachary shall we run it through ceph-disk test suite before the merge, or we can merge it once the conflict is resolved

@ghost
Copy link

ghost commented Mar 20, 2017

@tchaikov there are no integration tests for this change therefore it won't help to run the ceph-disk suite.

This subcommand will fix the SELinux labels and/or file permissions on
ceph data (/var/lib/ceph).

The command is also optimized to run the commands in parallel (per
sub-dir in /var/lib/ceph) and do restorecon and chown at the same time
to take advantage of the caching mechanisms.

Signed-off-by: Boris Ranto <branto@redhat.com>
This will simulate the command* functions to not actually run anything
thus excercising the python code directly. It also checks that the
proper (sub-strings) are in the output.

Signed-off-by: Boris Ranto <branto@redhat.com>
It turns out I forgot several more directories that needs to be fixed by
this script. We need to fix /var/log/ceph, /var/run/ceph and /etc/ceph
as well.

Signed-off-by: Boris Ranto <branto@redhat.com>
This adds the ability to restore the labels of the underlying system
data in addition to ceph data.

Signed-off-by: Boris Ranto <branto@redhat.com>
@b-ranto
Copy link
Contributor Author

b-ranto commented Mar 20, 2017

@tchaikov rebased

@ChristinaMeno
Copy link
Contributor

@tchaikov Would you please take a look at this?

@ghost ghost merged commit 8a2cf69 into master Apr 5, 2017
@ktdreyer ktdreyer deleted the wip-ceph-disk-fix branch April 5, 2017 17:10
This pull request was closed.
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.

3 participants