-
Notifications
You must be signed in to change notification settings - Fork 95
Conversation
esx_service/cli/vmdkops_admin.py
Outdated
@@ -1301,16 +1305,38 @@ def config_rm(args): | |||
# This asks for double confirmation, and removes the local link or DB (if any) | |||
# NEVER deletes the shared database - instead prints help | |||
|
|||
if not args.local: | |||
if not args.local and not args.unlink: | |||
return err_out(""" | |||
Shared DB removal is not supported. For removing local configuration, use --local flag. |
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.
Nit: remove extra space - "removing local"
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.
The whole message has been rewritten per Mark's comments.
esx_service/cli/vmdkops_admin.py
Outdated
return err_out(""" | ||
Shared DB removal is not supported. For removing local configuration, use --local flag. | ||
For removing shared DB, run 'vmdkops_admin config rm --local' on ESX hosts using this DB, | ||
For removing shared DB, run 'vmdkops_admin config rm --unlink' on ESX hosts using this DB, |
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.
Nit: remove extra space - "DB, run"
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.
Same above.
esx_service/cli/vmdkops_admin.py
Outdated
@@ -1301,16 +1305,38 @@ def config_rm(args): | |||
# This asks for double confirmation, and removes the local link or DB (if any) | |||
# NEVER deletes the shared database - instead prints help | |||
|
|||
if not args.local: | |||
if not args.local and not args.unlink: | |||
return err_out(""" | |||
Shared DB removal is not supported. For removing local configuration, use --local flag. |
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.
Nit: I'd suggest to move "Shared DB removal is not supported" to the last statement.
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.
Same above.
esx_service/cli/vmdkops_admin.py
Outdated
and manually remove the {} file from shared storage. | ||
""".format(auth_data.CONFIG_DB_NAME)) | ||
|
||
# Check the existing config mode |
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.
Can we extract this section as a separate method for code reuse?
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.
Issue #1187 is filed to track this.
esx_service/cli/vmdkops_admin.py
Outdated
mode = auth.mode # for usage outside of the 'with' | ||
except auth_data.DbAccessError as ex: | ||
return err_out(str(ex)) | ||
|
||
if not args.confirm: |
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.
Let's move this argument check before line 1315.
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.
Done
esx_service/cli/vmdkops_admin.py
Outdated
pass | ||
elif mode == auth_data.DBMode.MultiNode: | ||
if args.local: | ||
return err_out("'rm --local' is not supported when " + DB_REF + "is in MultiNode mode." |
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.
Nit: add a space before and after "is in MultiNode mode."
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.
DB_REF already included the space.
esx_service/cli/vmdkops_admin.py
Outdated
elif mode == auth_data.DBMode.SingleNode: | ||
if args.unlink: | ||
return err_out("'rm --unlink' is not supported when " + DB_REF + " is in SingleNode mode." | ||
" Use 'rm --local' to remove the local link or local DB.") |
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.
Why "local link or local DB"? Do we also create a symlink to local DB? If yes, we should say "remove local link and local DB" or simply "remove local DB configuration"
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.
Done.
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.
Thanks for putting it together. Some of the messages need rework (suggestions included) , but mainly - the new code is unnecessary complex. Suggestions are also included - please take a loo
esx_service/cli/vmdkops_admin.py
Outdated
return err_out(""" | ||
Shared DB removal is not supported. For removing local configuration, use --local flag. | ||
For removing shared DB, run 'vmdkops_admin config rm --local' on ESX hosts using this DB, | ||
For removing shared DB, run 'vmdkops_admin config rm --unlink' on ESX hosts using this DB, | ||
and manually remove the {} file from shared storage. |
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.
I think the message no longer matches the functionality.
Here it should say:
"""
DB removal is irreversible operation. Please use --local
flag for removing DB in SingeNode mode,
and use --unlink to unlink from DB in MultiNode mode".
Note that --unlink will not remove a shared DB, but simply configure the current ESXi host to stop using it.
For removing shared DB, run 'vmdkops_admin config rm --unlink' on ESXi hosts using this DB, and then manually remove the actual DB file from shared storage."""
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.
Done.
esx_service/cli/vmdkops_admin.py
Outdated
if not args.confirm: | ||
return err_out("Warning: For extra safety, removal operation requires '--confirm' flag.") | ||
|
||
if mode == auth_data.DBMode.NotConfigured: | ||
pass |
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.
I think it should say "Nothing to do - DB is not configured".
It also should be handled together with all other "noops" csses - see below
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.
Done
esx_service/cli/vmdkops_admin.py
Outdated
and manually remove the {} file from shared storage. | ||
""".format(auth_data.CONFIG_DB_NAME)) | ||
|
||
# Check the existing config mode |
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.
Missing check
`if args.local and args.unlink: err_out("cannot use both flags together" + help message above about when to use what)
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.
Done.
esx_service/cli/vmdkops_admin.py
Outdated
if mode == auth_data.DBMode.NotConfigured: | ||
pass | ||
elif mode == auth_data.DBMode.MultiNode: | ||
if args.local: |
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.
the whole code should be simpler , something like this:
if mode == DBMode.MutiNode:
if arg.local:
err_out(...)
else:
move_to_backup
return service_reset
if mode == DBMode.SingleNode:
if args.unlink:
err_out
else:
rm link
return service_reset
# all other cases
print("Noting to do. Mode =<mode>"
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.
Done.
auth.connect() | ||
info = auth.get_info() | ||
mode = auth.mode # for usage outside of the 'with' | ||
except auth_data.DbAccessError as ex: |
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.
I think it's generally a bad idea to catch exception half way in command line.
We should let them bubble to main and just print proper error message there.
I think that's what we already do, don't we ?
Can you check what's the behavior if there is no catch here, and connect() does throw DBAccessError ? (this is not a blocker so if you are out of time feel free to skip this comment)
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.
Here we cannot let the code go through. When the exception happens, we cannot get the correct config mode from DB. And our following code depends on the config mode. We have similar logic in the "config_init()" too.
@shaominchen @msterin I have addressed your comments, please take a look. Thanks! |
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.
LGTM.
@lipingxue, pls. add tests as below,
|
if mode == auth_data.DBMode.MultiNode: | ||
if args.local: | ||
return err_out("'rm --local' is not supported when " + DB_REF + "is in MultiNode mode." | ||
" Use 'rm --unlink' to remove the local link to shared DB.") |
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.
Is it necessary to have a --local and --unlink. A --unlink is sufficient for both single and multi-node cases. In the single node case it destroys the DB (or backs it up) and in the multi-node case simply delinks the host from the shared DB. Since the configured mode is already known to the system, it can differentiate the cases and figure how to interpret the unlink.
The --local just seems extra and user needs to keep track of the mode.
A host may have a local datastore and have a DB on that and a shared DS with a DB on that. How does the user decide which DB on which DS to remove? Don't we need to pass the DS name on the command line?? Or multiple shared DS'es on the same host.
and use '--unlink' to unlink from DB in MultiNode mode. | ||
""" | ||
) | ||
|
||
if not args.confirm: | ||
return err_out("Warning: For extra safety, removal operation requires '--confirm' flag.") |
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.
Not this change, why does the user need to provide two options?? --local and --confirm, it would make sense if the confirmation is asked by the CLI. If the user provides "rm --local" then they want to remove the DB, the user typing out another "--confirm" doesn't make any difference - they still want to remove the DB.
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.
Can you also try this out on VSAN and say how the DB is configured there? Is it local or multi-node?
@govint
I did the above tests for shared mode on VSAN itself. It's configured the same way. Were you implying something else? |
@pshahzeb, thanks for this verification. For VSAN my doubt was since its a single datastore across all hosts in the cluster (yes?) is the DB visible to all nodes and hence is it local or multi-node? And whether the link to the DB is visible to all nodes (its a single datastore). Is it then a single link or per node? |
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.
Looks good.
Fixed #1138.
This PR includes the change to implement "config rm --unlink".
[ ] In SingleNode,
rm --local
will remove the local DB,rm --unlink
will return an error message to say this command is not supported in SingleNode configuration.[ ] In MultiNode,
rm --unlink
will print a message and remove the local symlink.rm --local
will return an error message to sayrm --unlink
is not support in MultiNode configuration.Testing:
Configured in SingleNodeMode:
config rm
config rm --unlink
config rm --local
Configured in MultiNodeMode:
config rm
config rm --local
config rm --unlink