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

Retry exec commands on text file busy #763

Merged
merged 1 commit into from
Apr 22, 2020
Merged
Changes from all commits
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
21 changes: 20 additions & 1 deletion pkg/invoke/raw_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"fmt"
"io"
"os/exec"
"strings"
"time"

"github.com/containernetworking/cni/pkg/types"
)
Expand All @@ -37,7 +39,24 @@ func (e *RawExec) ExecPlugin(ctx context.Context, pluginPath string, stdinData [
c.Stdin = bytes.NewBuffer(stdinData)
c.Stdout = stdout
c.Stderr = stderr
if err := c.Run(); err != nil {

// Retry the command on "text file busy" errors
for i := 0; i <= 5; i++ {
err := c.Run()

// Command succeeded
if err == nil {
break
}

// If the plugin is currently about to be written, then we wait a
// second and try it again
if strings.Contains(err.Error(), "text file busy") {
time.Sleep(time.Second)
continue
}

// All other errors except than the busy text file
return nil, e.pluginErr(err, stdout.Bytes(), stderr.Bytes())
}
Comment on lines +43 to 61
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcbw I moved the logic over here, should me make it configurable somehow?


Expand Down