Skip to content

rgw : Bucket mv, bucket chown and user rename utilities#28813

Merged
cbodley merged 22 commits intoceph:masterfrom
smanjara:wip-user-rename-working
Aug 7, 2019
Merged

rgw : Bucket mv, bucket chown and user rename utilities#28813
cbodley merged 22 commits intoceph:masterfrom
smanjara:wip-user-rename-working

Conversation

@smanjara
Copy link
Contributor

@smanjara smanjara commented Jul 1, 2019

In summary, some of the key changes (detailed in the commit messages) are:

  • Bucket link feature extension support to include tenanted user namespace and ability to change bucket name. Refers to pr rgw: bucketmv #23994 submitted by @mdw-at-linuxbox

  • Introduces 'bucket chown' command to move buckets and objects under a new user built upon the above pr.

  • Introduces 'user rename' to change user ID.

  • References tracker ticket

  • Updates documentation if necessary

  • Includes tests for new functionality or reproducer for bug

@smanjara smanjara force-pushed the wip-user-rename-working branch from 626855a to b2f872a Compare July 2, 2019 03:26
@smanjara smanjara force-pushed the wip-user-rename-working branch from b2f872a to d4ebef0 Compare July 2, 2019 03:40
@smanjara smanjara mentioned this pull request Jul 2, 2019
3 tasks
Copy link
Contributor

@cbodley cbodley left a comment

Choose a reason for hiding this comment

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

it looks like there's some code duplication between RGWBucket::link() and the for loop in RGWUser::execute_user_rename(). is it possible to refactor some of that into a separate helper function?

@smanjara
Copy link
Contributor Author

smanjara commented Jul 15, 2019

it looks like there's some code duplication between RGWBucket::link() and the for loop in RGWUser::execute_user_rename(). is it possible to refactor some of that into a separate helper function?

Done

@smanjara smanjara force-pushed the wip-user-rename-working branch from 4e3dc21 to 6952e60 Compare July 16, 2019 14:30
Copy link
Contributor

@cbodley cbodley left a comment

Choose a reason for hiding this comment

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

can you please try to add some test coverage for 'user rename' in qa/tasks/radosgw_admin.py?

@smanjara smanjara requested a review from cbodley July 19, 2019 11:14
@smanjara
Copy link
Contributor Author

smanjara commented Jul 23, 2019

@smanjara smanjara force-pushed the wip-user-rename-working branch from 65eee91 to ba84c6f Compare July 25, 2019 11:21
@smanjara
Copy link
Contributor Author

@cbodley
Copy link
Contributor

cbodley commented Jul 25, 2019

we have a 'test case' that compares the output of radosgw-admin --help with src/test/cli/radosgw-admin/help.t and that's failing here. could you please update help.t?

/home/jenkins-build/build/workspace/ceph-pull-requests/src/test/cli/radosgw-admin/help.t: failed
--- /home/jenkins-build/build/workspace/ceph-pull-requests/src/test/cli/radosgw-admin/help.t
+++ /home/jenkins-build/build/workspace/ceph-pull-requests/src/test/cli/radosgw-admin/help.t.err
@@ -4,6 +4,7 @@
     user create                create a new user
     user modify                modify user
     user info                  get user info
+    user rename                rename user
     user rm                    remove user
     user suspend               suspend a user
     user enable                re-enable user after suspension
@@ -163,6 +164,7 @@
   options:
      --tenant=<tenant>         tenant name
      --uid=<id>                user id
+     --new-uid=<id>            new user id
      --subuser=<name>          subuser name
      --access-key=<key>        S3 access key
      --email=<email>           user's email address
# Ran 1 tests, 0 skipped, 1 failed.

@smanjara smanjara force-pushed the wip-user-rename-working branch from 0e4e54a to 3eda34e Compare July 26, 2019 05:35
@smanjara
Copy link
Contributor Author

we have a 'test case' that compares the output of radosgw-admin --help with src/test/cli/radosgw-admin/help.t and that's failing here. could you please update help.t?

/home/jenkins-build/build/workspace/ceph-pull-requests/src/test/cli/radosgw-admin/help.t: failed
--- /home/jenkins-build/build/workspace/ceph-pull-requests/src/test/cli/radosgw-admin/help.t
+++ /home/jenkins-build/build/workspace/ceph-pull-requests/src/test/cli/radosgw-admin/help.t.err
@@ -4,6 +4,7 @@
     user create                create a new user
     user modify                modify user
     user info                  get user info
+    user rename                rename user
     user rm                    remove user
     user suspend               suspend a user
     user enable                re-enable user after suspension
@@ -163,6 +164,7 @@
   options:
      --tenant=<tenant>         tenant name
      --uid=<id>                user id
+     --new-uid=<id>            new user id
      --subuser=<name>          subuser name
      --access-key=<key>        S3 access key
      --email=<email>           user's email address
# Ran 1 tests, 0 skipped, 1 failed.

Fixed. Also line wrap. Missed it while switching between branches. Thanks.

@cbodley
Copy link
Contributor

cbodley commented Jul 26, 2019

@smanjara i did a quick test, and it looks like user rename will let you overwrite an existing uid; that's not intended, is it?

$ MON=1 OSD=1 RGW=1 MGR=0 MDS=0 ../src/vstart.sh -n -d
...
$ bin/radosgw-admin user info --uid testid
{
    "user_id": "testid",
    "display_name": "M. Tester",
    "email": "tester@ceph.com",
...
}
$ bin/radosgw-admin user info --uid 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
{
    "user_id": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "display_name": "youruseridhere",
    "email": "s3@example.com",
...
}
$ bin/radosgw-admin user rename --uid testid --new-uid 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
{
    "user_id": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "display_name": "M. Tester",
    "email": "tester@ceph.com",
...
}

@smanjara
Copy link
Contributor Author

@smanjara i did a quick test, and it looks like user rename will let you overwrite an existing uid; that's not intended, is it?

$ MON=1 OSD=1 RGW=1 MGR=0 MDS=0 ../src/vstart.sh -n -d
...
$ bin/radosgw-admin user info --uid testid
{
    "user_id": "testid",
    "display_name": "M. Tester",
    "email": "tester@ceph.com",
...
}
$ bin/radosgw-admin user info --uid 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
{
    "user_id": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "display_name": "youruseridhere",
    "email": "s3@example.com",
...
}
$ bin/radosgw-admin user rename --uid testid --new-uid 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
{
    "user_id": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "display_name": "M. Tester",
    "email": "tester@ceph.com",
...
}

@cbodley, yes, that's not intended. I seem to have missed this case. Will add checks to fail if new-uid already exists. Thanks for testing it.

In jewel, "rgw keystone implicit tenants" only applied to swift. As of
luminous), this option applies to s3 also.
Sites that used this feature with jewel now have outstanding data that
depends on the old behavior.

The fix here is to expand "rgw keystone implicit tenants" so that it
can be set to any of "none", "all", "s3" or "swift" (also 0=false=none,
1=true=all).  When set to "s3" or "swift", the actual id lookup
is also partitioned.

Formerly "rgw keystone implicit tenants" was a legacy opt.
This change converts it to the new style of option,
including support for dynamically changing it.

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

Signed-off-by: Marcus Watts <mwatts@redhat.com>
Add types: RGWBucketEntryPoint obj_version rgw_user
These are structures that are visible as data at rest
inside of rados when a bucket is made via radosgw.

RGWBucketEntryPoint is the contents of a rados
object with names that may be either "<bucket-name>"
or "<tenant>/<bucket-name>"

rgw_user is a structure contained inside of RGWBucketEntryPoint
and other structures.

obj_version is visible as the xattr "ceph.objclass.version"
on rados objects in ".rgw.meta" that contain ".bucket.meta."

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

Signed-off-by: Marcus Watts <mwatts@redhat.com>
This just adds the command line option and related bits.

Underlying functionality will be a later commit.

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

Signed-off-by: Marcus Watts <mwatts@redhat.com>
This is not a complete fix; but it makes it possible for the
bucket link command to correctly find and attempt to link a bucket
to a user with a different tenant.  The reason this is not a complete
fix is that with just this change, the resulting bucket is "broken";
a duplicate endpoint but 0 length contents is created, and
the info entry is not correctly moved.

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

Signed-off-by: Marcus Watts <mwatts@redhat.com>
The bucket link command was doing an extra bucket
get info call because it needed attributes.  Revised
::init so that attributes could optionally be requested,
and eliminate now unnecessary call.

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

Signed-off-by: Marcus Watts <mwatts@redhat.com>
The bucket link command was doing a fetch of the entrypoint late
in the link process.  This makes it harder to do "bucket move"
functionality, because then it would need to know the old
bucket late in the process.  The bucketinfo structure has
all the data elements necessary to recreate the endpoint,
so the changes here arrange to just use that data.

In order to write the object it's also necessary to propagate
xattrs.  The only xattr that seems to be present on the endpoint
is "ceph.objclass.version", so that's what this copies out.
It appears that attribute may be set set separately by cls,
so I'm not sure this is actually necessary.  However, the
old code would have written it, so this code preserves
that behavior.

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

Signed-off-by: Marcus Watts <mwatts@redhat.com>
The existing RGWBucket::link logic changed things incrementally in
order to relink a bucket.  When doing a "bucket move", this is no longer
a good idea - bucket objects must be written to new names which don't
exist, so it is better to create then wholly out of in-memory data.

Also, add != for rgw_bucket - inverse of existing of ==, provides
another option to arrange code to make it more readable.

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

Signed-off-by: Marcus Watts <mwatts@redhat.com>
This is the base or primitive "bucket move" function.  It handles rewriting
the endpoint and info rados objects for the rgw bucket, plus deleting
the original rados objects that are no longer correct.  It doesn't
handle changing the bucket name; that's in a future commit.  Some of
the changes here will get overwritten by that commit.

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

Signed-off-by: Marcus Watts <mwatts@redhat.com>
Shilpa Jagannath added 9 commits July 30, 2019 14:00
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
…of an

existing user are moved under the new user namespace specified by "--new-uid".
It calls bucket link and bucket chown to link the buckets and objects to the new
user namespace. Access and secret keys of the user(and the subusers) are preserved.

Usage: "radosgw-admin user rename --uid=<> --new-uid=<>"

Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
… a time.

Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
Added a helper function to modify bucket acl.
Rebased onto master.

Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
@smanjara smanjara force-pushed the wip-user-rename-working branch from da32c64 to 67e98eb Compare July 30, 2019 08:42
@smanjara
Copy link
Contributor Author

@cbodley
Copy link
Contributor

cbodley commented Aug 1, 2019

thanks @smanjara; could you please add a test case for user rename over an existing user? it should also verify that, after failing to rename, both users can still access their buckets/objects?

since the metadata refactoring in #29118 is changing a lot of this code, i'd really like some extra coverage to make sure we don't break anything here

Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
Copy link
Contributor

@mattbenjamin mattbenjamin left a comment

Choose a reason for hiding this comment

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

+1

@cbodley cbodley merged commit 17fc695 into ceph:master Aug 7, 2019
@cbodley cbodley mentioned this pull request Aug 9, 2019
alfonsomthd added a commit to rhcs-dashboard/ceph that referenced this pull request Aug 20, 2019
Since ceph#28813 is in master, the bucket operations
(with tenanted owners) behaviour has changed regarding nautilus, so this fix is
applied to nautilus directly.

Fixes: https://tracker.ceph.com/issues/41067
Signed-off-by: alfonsomthd <almartin@redhat.com>
alfonsomthd added a commit to rhcs-dashboard/ceph that referenced this pull request Sep 17, 2019
Since ceph#28813 is in master, the bucket operations
(with tenanted owners) behaviour has changed regarding nautilus, so this fix is
applied to nautilus directly.

Fixes: https://tracker.ceph.com/issues/41067
Signed-off-by: Alfonso Martínez <almartin@redhat.com>
@votdev
Copy link
Member

votdev commented Oct 22, 2019

Are these new features available via RGW Admin OPS API? There are plans to support them via Dashboard. Can anyone comment this in the tracker issue https://tracker.ceph.com/issues/41819 please.

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.

6 participants