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

rkt: fix panic on rm a non-existing pod with uuid-file #2679

Merged
merged 2 commits into from May 24, 2016
Jump to file or symbol
Failed to load files and symbols.
+7 −5
Diff settings

Always

Just for now

Next

rkt: fix panic on rm a non-existing pod with uuid-file

We were trusting that the value in the uuid file referred to an existing
pod, which caused a panic if that wasn't the case.

In this commit we resolve the UUID to check if the pod actually exists.

Also, make rm's behavior consistent between caling it with a pod UUID
and with `--uuid-file`:

* Print a similar error message
* Set the exit status to 1 if we fail to remove any pod
  • Loading branch information...
iaguis committed May 24, 2016
commit 99ae3bec39a1e3e923ffb64a4779f326c82e165d
View
@@ -43,20 +43,23 @@ func runRm(cmd *cobra.Command, args []string) (exit int) {
var podUUIDs []*types.UUID
var err error
ret := 0
switch {
case len(args) == 0 && flagUUIDFile != "":
podUUID, err = readUUIDFromFile(flagUUIDFile)
if err != nil {
stderr.PrintE("unable to read UUID from file", err)
return 1
stderr.PrintE("unable to resolve UUID from file", err)
ret = 1
} else {
podUUIDs = append(podUUIDs, podUUID)
}
podUUIDs = append(podUUIDs, podUUID)
case len(args) > 0 && flagUUIDFile == "":
for _, uuid := range args {
podUUID, err := resolveUUID(uuid)
if err != nil {
stderr.PrintE("unable to resolve UUID", err)
ret = 1
} else {
podUUIDs = append(podUUIDs, podUUID)
}
@@ -67,7 +70,6 @@ func runRm(cmd *cobra.Command, args []string) (exit int) {
return 1
}
ret := 0
for _, podUUID = range podUUIDs {
p, err := getPod(podUUID)
if err != nil {
View
@@ -77,7 +77,7 @@ func readUUIDFromFile(path string) (*types.UUID, error) {
}
uuid = bytes.TrimSpace(uuid)
return types.NewUUID(string(uuid))
return resolveUUID(string(uuid))
}
func writeUUIDToFile(uuid *types.UUID, path string) error {
ProTip! Use n and p to navigate between commits in a pull request.