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

bucket notifications - validate notifications on change (gh issue 8649) #8667

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alphaprinz
Copy link
Contributor

Explain the changes

  1. As per aws spec, when bucket's notification change, all of the bucket's notification configuration are validated.
    If one of them fails, the user's request is failed.

Issues: Fixed #xxx / Gap #xxx

  1. put-bucket notification should check the connection before saving the information to the bucket #8649

Testing Instructions:

  1. Create a new bucket with a non-existing connect file or with a wrong connect info.
  2. Bucket creation should fail.
  • Doc added/updated
  • Tests added

@alphaprinz alphaprinz force-pushed the notif_gh_8649 branch 2 times, most recently from f48e291 to e01196d Compare January 9, 2025 07:16
@@ -275,7 +275,7 @@ async function delete_bucket(data, force) {
*/
async function bucket_management(action, user_input) {
const data = action === ACTIONS.LIST ? undefined : await fetch_bucket_data(action, user_input);
await manage_nsfs_validations.validate_bucket_args(config_fs, data, action);
await manage_nsfs_validations.validate_bucket_args(config_fs, data, action, user_input);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid adding a new argument user_input in the function signature?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find a way.
The new input is required, the merged is not good enough.
When bucket name is changed, it is passed through a specific parameter ("new_name").

Copy link
Contributor

Choose a reason for hiding this comment

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

But I don't see where you use the bucket name exactly.
Another option is maybe to check it later in the flow.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can add the notifications argument only? (I want to avoid confusion between data and user_input).

src/manage_nsfs/manage_nsfs_validations.js Outdated Show resolved Hide resolved
src/manage_nsfs/manage_nsfs_validations.js Show resolved Hide resolved
@alphaprinz alphaprinz requested a review from shirady January 14, 2025 22:00
@alphaprinz alphaprinz force-pushed the notif_gh_8649 branch 5 times, most recently from 035ad66 to 1b2142c Compare January 16, 2025 07:39
src/manage_nsfs/manage_nsfs_validations.js Show resolved Hide resolved
src/endpoint/s3/ops/s3_put_bucket_notification.js Outdated Show resolved Hide resolved
@@ -275,7 +275,7 @@ async function delete_bucket(data, force) {
*/
async function bucket_management(action, user_input) {
const data = action === ACTIONS.LIST ? undefined : await fetch_bucket_data(action, user_input);
await manage_nsfs_validations.validate_bucket_args(config_fs, data, action);
await manage_nsfs_validations.validate_bucket_args(config_fs, data, action, user_input);
Copy link
Contributor

Choose a reason for hiding this comment

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

But I don't see where you use the bucket name exactly.
Another option is maybe to check it later in the flow.

src/manage_nsfs/manage_nsfs_validations.js Show resolved Hide resolved
@shirady
Copy link
Contributor

shirady commented Jan 23, 2025

@alphaprinz could you add an automatic test for the fix?
If I understand correctly you can use the file test_nc_nsfs_bucket_cli.test.js as the non-existing connection is while creating or updating a new bucket.

@nimrod-becker
Copy link
Contributor

@dannyzaken can you PTAL ?

@@ -275,7 +275,7 @@ async function delete_bucket(data, force) {
*/
async function bucket_management(action, user_input) {
const data = action === ACTIONS.LIST ? undefined : await fetch_bucket_data(action, user_input);
await manage_nsfs_validations.validate_bucket_args(config_fs, data, action);
await manage_nsfs_validations.validate_bucket_args(config_fs, data, action, user_input);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can add the notifications argument only? (I want to avoid confusion between data and user_input).

Comment on lines +451 to +456
//if there's a change to the bucket's notifications, we need to test them
//if one of the specified notifications fail, we need to fail the user's request
if (user_input.notifications) {
const test_notif_err = await notifications_util.test_notifications(user_input.notifications, config_fs.connections_dir_path);
if (test_notif_err) {
throw_cli_error(ManageCLIError.InvalidArgument, "Failed to update notifications", test_notif_err);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you move this part to a separate function? (the function validate_bucket_args and then called it (the function has many lines before your change).

@alphaprinz
Copy link
Contributor Author

Re test - The test PR goes through this code path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants