-
Notifications
You must be signed in to change notification settings - Fork 2k
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
CSI: volume cli prefix matching should accept exact match #12051
Conversation
The `volume detach`, `volume deregister`, and `volume status` commands accept a prefix argument for the volume ID. Update the behavior on exact matches so that if there is more than one volume that matches the prefix, we should only return an error if one of the volume IDs is not an exact match. Otherwise we won't be able to use these commands at all on those volumes. This also makes the behavior of these commands consistent with `job stop`.
006c498
to
1c5597a
Compare
if len(vols) == 0 { | ||
c.Ui.Error(fmt.Sprintf("No volumes(s) with prefix or ID %q found", volID)) | ||
return 1 | ||
} | ||
if len(vols) > 1 { | ||
if (volID != vols[0].ID) || (c.allNamespaces() && vols[0].ID == vols[1].ID) { |
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.
Just checking my understanding of the state store, when looking by ID prefix, vols
would be sorted by prefix length, so if the first element is not an exact match, we don't need to check the rest because it would be a longer value. Is this right? 😅
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.
Exactly. This property arises from go-immutable-radix
.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
Fixes #12005
The
volume detach
,volume deregister
, andvolume status
commandsaccept a prefix argument for the volume ID. Update the behavior on
exact matches so that if there is more than one volume that matches
the prefix, we should only return an error if one of the volume IDs is
not an exact match. Otherwise we won't be able to use these commands
at all on those volumes. This also makes the behavior of these commands
consistent with
job stop
.