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

NC | CLI | Updated the CLI response to have more info when account/bucket has been deleted #8723

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

achouhan09
Copy link
Member

@achouhan09 achouhan09 commented Jan 24, 2025

Explain the changes

  1. Improved the response to provide a clearer message about the operations.
  2. Now, the name of the object would also be printed in the response message for more info.

Issues: Fixed #xxx / Gap #xxx

  1. Fixed: NC | NSFS | CLI | Improve Response (To have Details) #8200

Testing Instructions:

  1. Try creating/deleting(or any other operation) on objects(account, bucket, etc.) using noobaa-cli and check the response returned.
  • Tests added

@achouhan09 achouhan09 requested review from liranmauda, romayalon, shirady, a team and vh05 and removed request for a team January 24, 2025 14:51
src/manage_nsfs/manage_nsfs_cli_responses.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
@achouhan09 achouhan09 force-pushed the account-res-fix branch 2 times, most recently from 552ba45 to 390d2b4 Compare January 29, 2025 10:04
src/manage_nsfs/manage_nsfs_cli_responses.js Outdated Show resolved Hide resolved
src/manage_nsfs/manage_nsfs_cli_responses.js Outdated Show resolved Hide resolved
src/manage_nsfs/manage_nsfs_cli_responses.js Outdated Show resolved Hide resolved
src/cmd/manage_nsfs.js Outdated Show resolved Hide resolved
@@ -131,16 +148,19 @@ ManageCLIResponse.LoggingExported = Object.freeze({

ManageCLIResponse.UpgradeSuccessful = Object.freeze({
code: 'UpgradeSuccessful',
message: 'Upgrade completed successfully',
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add to all the Upgrade functions Config Directory Upgrade prefix? for example - Config Directory Upgrade completed successfully etc

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure

@@ -150,25 +170,30 @@ ManageCLIResponse.UpgradeHistory = Object.freeze({

ManageCLIResponse.ConnectionCreated = Object.freeze({
code: 'ConnectionCreated',
message: 'Connection has been successfully created',
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that here as well maybe Notification Connection
@alphaprinz probably can help with this response details

@@ -94,25 +105,30 @@ ManageCLIResponse.AccountList = Object.freeze({

ManageCLIResponse.BucketCreated = Object.freeze({
code: 'BucketCreated',
message: 'Bucket has been successfully created',
Copy link
Contributor

Choose a reason for hiding this comment

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

I would put the 'successfully' in the end of the sentance

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I should do this for all the operations. Thanks

}

to_string(detail) {
const json = {
response: {
code: this.code,
message: detail.name ? `${this.message}: ${detail.name}` : this.message,
Copy link
Contributor

Choose a reason for hiding this comment

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

does adding the detail after the message makes sense in all cases?
and also, do we always have detail and detail.name?

Copy link
Member Author

Choose a reason for hiding this comment

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

whenever we want to print the name of the object in the operation then only we are adding detail at the end of message otherwise only the set message would be printed for every operation

Copy link
Contributor

Choose a reason for hiding this comment

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

the issue I see here is with accessing directly to detail.name while detail can be undefined

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated to optional chain. Thanks

@@ -252,7 +252,7 @@ async function delete_bucket(data, force) {
}
await native_fs_utils.folder_delete(bucket_temp_dir_path, fs_context_fs_backend, true);
await config_fs.delete_bucket_config_file(data.name);
return { code: ManageCLIResponse.BucketDeleted, detail: '', event_arg: { bucket: data.name } };
return { code: ManageCLIResponse.BucketDeleted, detail: { name: data.name }, event_arg: { bucket: data.name } };
Copy link
Contributor

Choose a reason for hiding this comment

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

are there more cases where we want to add detail?

Copy link
Member Author

Choose a reason for hiding this comment

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

for now I have added this in delete_account() and delete_bucket() operation only. We can print the name of object in message by setting the name property in detail(for any operation) otherwise the set message would be printed

Copy link
Contributor

Choose a reason for hiding this comment

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

please fix all the cases in this PR or open another gap for the rest of the cases so we will handle it in the future

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, I will open gap if there are more operations.

Copy link
Member Author

Choose a reason for hiding this comment

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

@romayalon I just verified other then connection_management there is no need add details explicitly. I have updated it. Thanks

For every operation we are printing the name of the object in the message(the code parsed the name automatically if detail.name is defined).

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.

NC | NSFS | CLI | Improve Response (To have Details)
4 participants