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

rgw: set bucket versioninig donot change versioning status if missing status in xml #17662

Merged
merged 1 commit into from
Sep 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/rgw/rgw_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2034,11 +2034,13 @@ void RGWSetBucketVersioning::execute()
}
}

if (enable_versioning) {
if (versioning_status == VersioningEnabled) {
s->bucket_info.flags |= BUCKET_VERSIONED;
s->bucket_info.flags &= ~BUCKET_VERSIONS_SUSPENDED;
} else {
} else if (versioning_status == VersioningSuspended) {
s->bucket_info.flags |= (BUCKET_VERSIONED | BUCKET_VERSIONS_SUSPENDED);
} else {
return;
}

op_ret = store->put_bucket_instance_info(s->bucket_info, false, real_time(),
Expand Down
10 changes: 8 additions & 2 deletions src/rgw/rgw_op.h
Original file line number Diff line number Diff line change
Expand Up @@ -760,12 +760,18 @@ class RGWGetBucketVersioning : public RGWOp {
uint32_t op_mask() override { return RGW_OP_TYPE_READ; }
};

enum BucketVersionStatus {
VersioningNotChanged = 0,
VersioningEnabled = 1,
VersioningSuspended =2,
};

class RGWSetBucketVersioning : public RGWOp {
protected:
bool enable_versioning;
int versioning_status;
bufferlist in_data;
public:
RGWSetBucketVersioning() : enable_versioning(false) {}
RGWSetBucketVersioning() : versioning_status(VersioningNotChanged) {}

int verify_permission() override;
void pre_exec() override;
Expand Down
9 changes: 5 additions & 4 deletions src/rgw/rgw_rest_s3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -893,21 +893,22 @@ class RGWSetBucketVersioningParser : public RGWXMLParser
RGWSetBucketVersioningParser() {}
~RGWSetBucketVersioningParser() override {}

int get_versioning_status(bool *status) {
int get_versioning_status(int *status) {
XMLObj *config = find_first("VersioningConfiguration");
if (!config)
return -EINVAL;

*status = false;
*status = VersioningNotChanged;

XMLObj *field = config->find_first("Status");
if (!field)
return 0;

*status = VersioningSuspended;
string& s = field->get_data();

if (stringcasecmp(s, "Enabled") == 0) {
*status = true;
*status = VersioningEnabled;
} else if (stringcasecmp(s, "Suspended") != 0) {
return -EINVAL;
}
Expand Down Expand Up @@ -952,7 +953,7 @@ int RGWSetBucketVersioning_ObjStore_S3::get_params()
in_data.append(data, len);
}

r = parser.get_versioning_status(&enable_versioning);
r = parser.get_versioning_status(&versioning_status);

return r;
}
Expand Down