Skip to content

Commit c452120

Browse files
authored
Merge pull request ceph#65479 from smanjara/wip-fix-object-sync-trace
rgw/multisite: fix sync requests on existing objects Reviewed-by: Casey Bodley <[email protected]>
2 parents 7d5298b + e1ac09e commit c452120

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7436,7 +7436,20 @@ int RGWRados::set_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx* octx, RGWBu
74367436
if (!op.size())
74377437
return 0;
74387438

7439+
// remove replication-trace attr to be able to re-replicate an object when metadata changes
74397440
bufferlist bl;
7441+
const string replication_trace = RGW_ATTR_OBJ_REPLICATION_TRACE;
7442+
bool removed_attr{false};
7443+
r = state->get_attr(replication_trace, bl);
7444+
if (r < 0) {
7445+
ldpp_dout(dpp, 10) << "ERROR: cannot remove attr " << replication_trace.c_str() << dendl;
7446+
} else {
7447+
op.rmxattr(replication_trace.c_str());
7448+
removed_attr = true;
7449+
}
7450+
7451+
bl.clear();
7452+
74407453
RGWRados::Bucket bop(this, bucket_info);
74417454
RGWRados::Bucket::UpdateIndex index_op(&bop, obj);
74427455

@@ -7555,6 +7568,10 @@ int RGWRados::set_attrs(const DoutPrefixProvider *dpp, RGWObjectCtx* octx, RGWBu
75557568
}
75567569
}
75577570

7571+
if (removed_attr) {
7572+
state->attrset.erase(replication_trace);
7573+
}
7574+
75587575
for (iter = attrs.begin(); iter != attrs.end(); ++iter) {
75597576
state->attrset[iter->first] = iter->second;
75607577
}

src/rgw/driver/rados/rgw_sal_rados.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2863,8 +2863,10 @@ int RadosObject::modify_obj_attrs(const char* attr_name, bufferlist& attr_val, o
28632863
/* Temporarily set target */
28642864
state.obj = target;
28652865
set_atomic(true);
2866-
state.attrset[attr_name] = attr_val;
2867-
r = set_obj_attrs(dpp, &state.attrset, nullptr, y, flags);
2866+
2867+
Attrs mattr;
2868+
mattr[attr_name] = attr_val;
2869+
r = set_obj_attrs(dpp, &mattr, nullptr, y, flags);
28682870
/* Restore target */
28692871
state.obj = save;
28702872

src/test/rgw/rgw_multi/tests.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,14 +2326,14 @@ def test_object_acl():
23262326
before_set_acl = bucket2.get_acl(k)
23272327
assert(len(before_set_acl.acl.grants) == 1)
23282328

2329-
#set object acl on primary and wait for sync.
2330-
bucket.set_canned_acl('public-read', key_name=k)
2331-
log.debug('set acl=%s', bucket.name)
2329+
#set object acl on secondary and wait for sync.
2330+
bucket2.set_canned_acl('public-read', key_name=k)
2331+
log.debug('set acl=%s', bucket2.name)
23322332
zonegroup_data_checkpoint(zonegroup_conns)
2333-
zonegroup_bucket_checkpoint(zonegroup_conns, bucket.name)
2333+
zonegroup_bucket_checkpoint(zonegroup_conns, bucket2.name)
23342334

2335-
#check object secondary after setacl
2336-
bucket2 = get_bucket(secondary, bucket.name)
2335+
#check object on primary after setacl
2336+
bucket2 = get_bucket(primary, bucket.name)
23372337
after_set_acl = bucket2.get_acl(k)
23382338
assert(len(after_set_acl.acl.grants) == 2) # read grant added on AllUsers
23392339

0 commit comments

Comments
 (0)