Skip to content

NC | lifecycle | fix notifications #8913

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

Merged
merged 1 commit into from
Apr 1, 2025

Conversation

nadavMiz
Copy link
Contributor

@nadavMiz nadavMiz commented Mar 27, 2025

Describe the Problem

unlike the object server namespace_fs doesn't return object_info as part of the delete_multiple_objects result. object_info is needed to compose delete notification. change to return the entire object_info for the delete candidates object instead of just the key. then combine the object info with the result of delete_multiple_objects to create a new delete_object to pass to create_notification_delete_object. the implementation assumes that delete_multiple_objects return list has the same object order as the object list it got as an input.(same assumption is done in s3_post_bucket_delete)
also unlike the bucket object in containerized lifecycle, bucket_json does not contain the account name. added the account name from object sdk to the bucket_json before passing it to create_notification_delete_object.

Explain the Changes

  1. return object_info instead of just key for expire delete candidates
  2. create deleted_obj object that contain both object_info and info from delete_multiple_objects result and pass it to create_notification_delete_object
  3. use bucket owner instead of root user as the object sdk account. (this is from NC | lifecycle | add expire non current and expire delete marker rules #8872 but its needed here as well)
  4. add account name from object_sdk as bucket_owner in bucket_json before passing it to create_notification_delete_object

Issues

Fixes issues with #8883

####GAPS

  1. lifecycle and nc lifecycle notification are similer, should have a joint function in notifations_util and call it from both
  2. modifying bucket_json before passing it to create_notification_delete_object is a bit hacky. should probably modify create_notification_delete_object to account for different structure. should probably be done when combining the code

Testing Instructions:

  1. sudo npx jest test_nc_lifecycle_cli
  • Doc added/updated
  • Tests added

@nadavMiz nadavMiz force-pushed the nc-lifecycle-notifications-fix branch from 5c3f0e4 to d0a8d3d Compare March 27, 2025 14:21
@@ -161,7 +161,11 @@ async function process_buckets(config_fs, bucket_names, system_json) {
*/
async function process_bucket(config_fs, bucket_name, system_json) {
const bucket_json = await config_fs.get_bucket_by_name(bucket_name, config_fs_options);
const account = { email: '', nsfs_account_config: config_fs.fs_context, access_keys: [] };
const account = await config_fs.get_identity_by_id(bucket_json.owner_account, undefined, {silent_if_missing: true});
Copy link
Contributor

Choose a reason for hiding this comment

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

type should be account so it'll be backwards compatible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed the type to account

@@ -210,23 +214,31 @@ async function process_rules(config_fs, bucket_json, object_sdk, should_notify)
}
}

async function send_lifecycle_notifications(delete_res, bucket_json, object_sdk) {
function create_notification_delete_object(delete_res, delete_obj_info) {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. please move to notifications util section
  2. please add jsdoc

Copy link
Contributor

Choose a reason for hiding this comment

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

do we need to pass the version id of the delete marker in the notification as well? what about deleted_delete_marker? will we need this info?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right its not part of the object_info because we get the object info of the object to delete. I can pass it from the res. there are many nuances I am adding tests now

})) {
const deleted_obj = create_notification_delete_object(delete_res[i], delete_candidates[i]);
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure that the delete_res[i] and delete_candidates[i] are the same object?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they should match. it is what we do in s3_post_bucket_delete. the alternative is to modify the return object of of delete_multiple_objects to be like in containerized. for this PR I wanted to match as much as possible to s3_post_bucket_delete. as I don't know why this way was decided. currently it shouldn't matter as we can't have both delete marker and regular delete at the same time. but I would still validate this

@nadavMiz nadavMiz force-pushed the nc-lifecycle-notifications-fix branch from d0a8d3d to 07dc57f Compare March 31, 2025 11:39
@pull-request-size pull-request-size bot added size/L and removed size/S labels Mar 31, 2025
@nadavMiz nadavMiz force-pushed the nc-lifecycle-notifications-fix branch from 07dc57f to 6ff5ce6 Compare March 31, 2025 11:47
@nadavMiz nadavMiz requested a review from romayalon March 31, 2025 11:48
@nadavMiz nadavMiz force-pushed the nc-lifecycle-notifications-fix branch from 6ff5ce6 to 9903b56 Compare March 31, 2025 11:59
Copy link
Contributor

@alphaprinz alphaprinz left a comment

Choose a reason for hiding this comment

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

Had some comments, otherwise LGTM

* @param {Object} bucket_json
* @param {Object} object_sdk
* @returns {Promise<Void>}
* NOTE implementation assumes delete_candidates and delete_res uses the same index. this assumtion is also made in
Copy link
Contributor

Choose a reason for hiding this comment

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

typo - assumption

@@ -255,8 +270,8 @@ describe('noobaa cli - lifecycle', () => {
}
];
await bucketspace_fs.set_bucket_lifecycle_configuration_rules({ name: test_bucket, rules: lifecycle_rule });
create_object(test_bucket, test_key1, 100, true);
create_object(test_bucket, test_key2, 100, false);
create_object_lifecycle(test_bucket, test_key1, 100, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

create_object_lifecycle is async. Don't you need an await when you call it?

@nadavMiz nadavMiz self-assigned this Apr 1, 2025
@nadavMiz nadavMiz force-pushed the nc-lifecycle-notifications-fix branch from 9903b56 to 8e6c4f2 Compare April 1, 2025 07:16
@nadavMiz nadavMiz force-pushed the nc-lifecycle-notifications-fix branch from 8e6c4f2 to 66f619b Compare April 1, 2025 09:11
@nadavMiz nadavMiz force-pushed the nc-lifecycle-notifications-fix branch from 66f619b to 10e1156 Compare April 1, 2025 10:03
@nadavMiz nadavMiz merged commit 04d2ead into noobaa:master Apr 1, 2025
11 checks passed
@romayalon romayalon mentioned this pull request May 15, 2025
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