-
Notifications
You must be signed in to change notification settings - Fork 83
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
NC | lifecycle | fix notifications #8913
Conversation
5c3f0e4
to
d0a8d3d
Compare
src/manage_nsfs/nc_lifecycle.js
Outdated
@@ -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}); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/manage_nsfs/nc_lifecycle.js
Outdated
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- please move to notifications util section
- please add jsdoc
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
src/manage_nsfs/nc_lifecycle.js
Outdated
})) { | ||
const deleted_obj = create_notification_delete_object(delete_res[i], delete_candidates[i]); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
d0a8d3d
to
07dc57f
Compare
07dc57f
to
6ff5ce6
Compare
6ff5ce6
to
9903b56
Compare
There was a problem hiding this 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
src/manage_nsfs/nc_lifecycle.js
Outdated
* @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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
9903b56
to
8e6c4f2
Compare
8e6c4f2
to
66f619b
Compare
Signed-off-by: nadav mizrahi <[email protected]>
66f619b
to
10e1156
Compare
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
Issues
Fixes issues with #8883
####GAPS
Testing Instructions:
sudo npx jest test_nc_lifecycle_cli