Skip to content

Commit

Permalink
test/helpers: Fix retry condition for CiliumExecContext
Browse files Browse the repository at this point in the history
Previously, 11cb4d0 assumed that 137 was the exit code for when a
process exists due to a SIGKILL. However, upon reading the Go source
code as of 1.20 rc1, this is not the case, and that -1 is set for all
exit codes due to signals [1].

Fixes: 11cb4d0 ("test: Keep trying exec if killed")
Fixes: cilium#22570

[1]:
https://github.com/golang/go/blob/go1.20rc1/src/os/exec_posix.go#L128-L130

Signed-off-by: Chris Tarazi <chris@isovalent.com>
  • Loading branch information
christarazi authored and pchaigno committed Dec 14, 2022
1 parent bf3fd5f commit dab8723
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/helpers/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2866,15 +2866,17 @@ func (kub *Kubectl) CiliumExecContext(ctx context.Context, pod string, cmd strin
// avoid Kubectl issue.
// https://github.com/openshift/origin/issues/16246
//
// Sometimes kubectl returns 137 exit code, when the command has been
// killed with the stderr "signal: killed", where the same command
// succeeds in a forthcoming sysdump. Keep trying also in this case
// until the 'limitTimes' retries has been exhausted.
// Sometimes kubectl returns -1 exit code, when the command has been killed
// with the stderr "signal: killed" (or generically when a process has been
// killed by a signal [1]), where the same command succeeds in a
// forthcoming sysdump. Keep trying also in this case until the
// 'limitTimes' retries has been exhausted.
// https://github.com/cilium/cilium/issues/22476
// [1]: https://github.com/golang/go/blob/go1.20rc1/src/os/exec_posix.go#L128-L130
for i := 0; i < limitTimes; i++ {
res = execute()
switch res.GetExitCode() {
case 126, 137:
case -1, 126:
// Retry.
default:
kub.Logger().Warningf("command terminated with exit code %d on try %d", res.GetExitCode(), i)
Expand Down

0 comments on commit dab8723

Please sign in to comment.