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

add bucket versioning for s3 #7512

Closed
wants to merge 1 commit into from

Conversation

nadavMiz
Copy link
Contributor

Explain the changes

  1. add versioning for namespace s3

Issues: Fixed #xxx / Gap #xxx

Testing Instructions:

  1. unit tests
  • Doc added/updated
  • Tests added

Signed-off-by: nadav mizrahi <nadav.mizrahi16@gmail.com>
Copy link
Contributor

@shirady shirady left a comment

Choose a reason for hiding this comment

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

Added a few comments/questions

async set_bucket_versioning(params) {
dbg.log0('NamespaceS3.set_bucket_versioning:', this.bucket, inspect(params));
const { versioning } = params;
await this.s3.putBucketVersioning({Bucket: this.bucket, VersioningConfiguration: {Status: versioning}}).promise();
Copy link
Contributor

Choose a reason for hiding this comment

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

In this file would you please separate the key-value in new line? (in putBucketVersioning and getBucketVersioning)

Suggested change
await this.s3.putBucketVersioning({Bucket: this.bucket, VersioningConfiguration: {Status: versioning}}).promise();
await this.s3.putBucketVersioning({
Bucket: this.bucket,
VersioningConfiguration: { Status: versioning },
}).promise();

SUSPENDED: 'Suspended',
});

// TODO: There is also MFA Delete configuration that we do not support
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you please move this comment near the code line VersioningConfiguration (where we are supposed to return the MFADelete property)?

Status: GET_VERSIONING_STATUS_MAP[bucket_info.versioning]
}
};
return await req.object_sdk.get_bucket_versioning({name: req.params.bucket});
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you please save with formatter? I think it should be with extra space

Suggested change
return await req.object_sdk.get_bucket_versioning({name: req.params.bucket});
return await req.object_sdk.get_bucket_versioning({ name: req.params.bucket });

@@ -15,7 +15,7 @@ async function put_bucket_versioning(req) {
}
await req.object_sdk.set_bucket_versioning({
name: req.params.bucket,
versioning: versioning.toUpperCase()
versioning: versioning
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you please explain what you changed with UpperCase?
I see that you removed it from here and added it somewhere else, but didn't understand why.

@@ -106,15 +107,40 @@ class BucketSpaceNB {

async set_bucket_versioning(params, object_sdk) {
const ns = await object_sdk._get_bucket_namespace(params.name);
if (ns instanceof NamespaceS3) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you please add a short comment that would explain that it was a decision to implement the set_bucket_versioning / get_bucket_versioning under namespace s3 and not in bucket space s3 (what you discussed yesterday)?

Status: GET_VERSIONING_STATUS_MAP[bucket_info.versioning]
}
};
return await req.object_sdk.get_bucket_versioning({name: req.params.bucket});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at other actions, we usually get the res and then take from it what we want and explicitly return it. Why did you choose to change it?

@@ -824,6 +824,7 @@ interface BucketSpace {
delete_bucket_lifecycle(params: object): Promise<any>;

set_bucket_versioning(params: object, object_sdk: ObjectSDK): Promise<any>;
get_bucket_versioning(params: object, object_sdk: ObjectSDK): Promise<any>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would you please explain why we need params? and why object_sdk?
I see that in the file object_sdk you send them, but I don't see that use them in namespace s3 - the function signature of get_bucket_versioning is without any parameter).

});

//should work, object exist
await s3.getObject({ Bucket: bucket_name, Key: text_file1, VersionId: put_res.VersionId});
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of getObject you can use headObject?
You can add a check of the response you get (to be sure that you've got what you planned).

@@ -759,15 +806,23 @@ mocha.describe('s3_ops', function() {
// Objects: [{ Key: text_file1 }, { Key: text_file2 }]
// }
// });
await s3.deleteObject({ Bucket: BKT5, Key: text_file5 });
await s3.deleteObject({ Bucket: BKT5, Key: text_file5});
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it was a typo (to remove the space).

Comment on lines +792 to +799
// clean up versioning products
await s3.deleteObject({ Bucket: bucket_name, Key: text_file1, VersionId: put_res.VersionId});

await s3.putBucketVersioning({
Bucket: bucket_name,
VersioningConfiguration: {Status: "Suspended"}
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

After this step, you should compleatly delete the bucket and create it again.
Suspended versioned bucket is not the same as not enabled one.
This is changing the intention of the entire suite.

Copy link

This PR had no activity for too long - it will now be labeled stale. Update it to prevent it from getting closed.

@github-actions github-actions bot added the Stale label Apr 25, 2024
Copy link

This PR is stale and had no activity for too long - it will now be closed.

@github-actions github-actions bot closed this May 26, 2024
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.

None yet

3 participants