From 3f3b18bff16f6a5b36987f888ba3f2a0d1ea3155 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Mon, 9 May 2016 17:22:45 +0200 Subject: [PATCH] rgw: fix updating account/container metadata of Swift API. This patch rectifies an issue with handling of user metadata that are actually stored by an updated resource (account or container). The expected behaviour is they will be merged with new medadata coming from an HTTP client. Backport: Jewel Fixes: http://tracker.ceph.com/issues/15779 Signed-off-by: Radoslaw Zarzynski --- src/rgw/rgw_op.cc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index d0508213069b7..1932b6c73a439 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1856,6 +1856,8 @@ static void prepare_add_del_attrs(const map& orig_attrs, if (aiter != std::end(out_attrs)) { out_attrs.erase(aiter); } + } else { + out_attrs[name] = kv.second; } } else if (out_attrs.find(name) == std::end(out_attrs)) { out_attrs[name] = kv.second; @@ -2772,11 +2774,23 @@ void RGWPutMetadataAccount::execute() return; } + op_ret = rgw_get_user_attrs_by_uid(store, s->user->user_id, orig_attrs, + &acct_op_tracker); + if (op_ret < 0) { + return; + } + rgw_get_request_metadata(s->cct, s->info, attrs, false); - RGWUserInfo orig_uinfo; - rgw_get_user_info_by_uid(store, s->user->user_id, orig_uinfo, &acct_op_tracker); + prepare_add_del_attrs(orig_attrs, rmattr_names, attrs); populate_with_generic_attrs(s, attrs); + RGWUserInfo orig_uinfo; + op_ret = rgw_get_user_info_by_uid(store, s->user->user_id, orig_uinfo, + &acct_op_tracker); + if (op_ret < 0) { + return; + } + /* Handle the TempURL-related stuff. */ map temp_url_keys; filter_out_temp_url(attrs, rmattr_names, temp_url_keys); -- 2.39.5