-
Notifications
You must be signed in to change notification settings - Fork 883
rkt/uuid: fix match when uuid is an empty string #2807
Conversation
Can one of the admins verify this patch? |
ok to test |
How does it look like with this patch when users run |
|
Maybe the second line of the error message can be avoided when there are no matches. |
Two comments here:
|
I agree on the wildcard, but before if you were running 'sudo rkt rm ""' On Thursday, June 16, 2016, Luca Bruno notifications@github.com wrote:
|
70aafe9
to
4ef67fe
Compare
Patch updated. @lucab I will open a specific an issue for wildcard |
New error output
|
4ef67fe
to
f83db18
Compare
@@ -30,6 +30,10 @@ import ( | |||
// matchUUID attempts to match the uuid specified as uuid against all pods present. | |||
// An array of matches is returned, which may be empty when nothing matches. | |||
func matchUUID(uuid string) ([]string, error) { | |||
if uuid == "" { | |||
return []string{}, types.ErrNoEmptyUUID |
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.
You can directly return nil, types.ErrNoEmptyUUID
here.
One comment inline and some additional notes:
|
00f3b32
to
4a2a791
Compare
Patch updated. @lucab test added. |
uuidFile := filepath.Join(tmpDir, "uuid-file") | ||
if err := ioutil.WriteFile(uuidFile, []byte(nonexistentUUID), 0600); err != nil { | ||
t.Fatalf("cannot write uuid-file: %v", err) | ||
} |
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'm not sure I understood why you are creating this nonexistentUUID
file here. What's its purpose?
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.
Yeah this can be deleted, I was not sure if it was necessary to have a some kind of data to be able to run rkt rm
correctly, like the example before. I suppose that the creation of the uuid-file it is a precaution to avoid deleting an existing pod, isn't it?.
After the patch, if the uuid is an empty string then matchUUID(uuid string) returns `UUID cannot be empty` error message instead of all the pods. This is done to avoid `rkt rm` or `rkt enter` to delete or enter pods without intending to. Fixes rkt#2806
4a2a791
to
166b560
Compare
patch updated. @lucab this should be cleaner |
Yes, thanks! LGTM, mergeable once builders are done. |
TestRmEmptyUUID passed, fedora-23 failure seems unrelated. |
@alepuccetti yes that's #2287. I'm merging this. |
After the patch, if the uuid is an empty string then matchUUID(uuid string)
returns no matches instead of all the pods.
This is done to avoid
rkt rm
orrkt enter
to delete or enter podswithout intending to.
Fixes #2806