kubernetes-retired / rktlet

[EOL] The rkt implementation of the Kubernetes Container Runtime Interface
Apache License 2.0
137 stars 43 forks source link

rktlet/cli: fix regexp to check for error string #139

Closed dongsupark closed 7 years ago

dongsupark commented 7 years ago

When rkt stop returns error because of UUID mismatch, the output Error string is not simply like "cannot get pod: no matches found for ...", but actually like below:

failed to run stop [--force=false 3c0ec67e-c02a-41b5-b053-e1b5d6e2fe06]: exit status 254 output: stop: cannot get pod: no matches found for "3c0ec67e-c02a-41b5-b053-e1b5d6e2fe06" stop: failed to stop 1 pod(s)

(in one string)

That's why regexp matching doesn't work. The substring cannot get pod... is neither located in the beginning of the input string, nor at the end of the string. As a result, rkt stop always fails in case of UUID mismatch, as RktStopIsNotExistError() always returns false. That's why critools tests fail like:

E0927 16:45:09.004685    7605 remote_runtime.go:115] StopPodSandbox "51b1d5fb-9546-4e78-b11d-63dd5029adf0" from runtime service failed: rpc error: code = Unknown desc = failed to run stop [--force=false 51b1d5fb-9546-4e78-b11d-63dd5029adf0]: exit status 254
output: stop: cannot get pod: no matches found for "51b1d5fb-9546-4e78-b11d-63dd5029adf0"

Fix regexp by removing ^ and $ from regexp.

Fixes https://github.com/kubernetes-incubator/rktlet/issues/138