Skip to content
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

fix(executor): Retry kubectl on internal transient error #8092

Merged
merged 3 commits into from
Mar 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add ut
add ut
Signed-off-by: wujayway <[email protected]>
  • Loading branch information
wujayway committed Mar 8, 2022
commit a05542ab40cda30d091678ba07b7054164b637c7
7 changes: 7 additions & 0 deletions util/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net"
"net/url"
"os"
"os/exec"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -23,6 +24,10 @@ var (
ioTimeoutErr net.Error = netError("i/o timeout")
connectionTimedout net.Error = netError("connection timed out")
transientErr net.Error = netError("this error is transient")
transientExitErr = exec.ExitError{
ProcessState: &os.ProcessState{},
Stderr: []byte("this error is transient"),
}
)

const transientEnvVarKey = "TRANSIENT_ERROR_PATTERN"
Expand Down Expand Up @@ -67,9 +72,11 @@ func TestIsTransientErr(t *testing.T) {
t.Run("TransientErrorPattern", func(t *testing.T) {
_ = os.Setenv(transientEnvVarKey, "this error is transient")
assert.True(t, IsTransientErr(transientErr))
assert.True(t, IsTransientErr(&transientExitErr))

_ = os.Setenv(transientEnvVarKey, "this error is not transient")
assert.False(t, IsTransientErr(transientErr))
assert.False(t, IsTransientErr(&transientExitErr))

_ = os.Setenv(transientEnvVarKey, "")
assert.False(t, IsTransientErr(transientErr))
Expand Down