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

Add retry for docker pull to deal with occasional errors from ghcr #111

Merged
merged 6 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions internal/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ func RunDockerCommand(workingDir string, showCommand bool, pipeStdout bool, comm
return runCommand(dockerCmd, showCommand, pipeStdout, command...)
}

func RunDockerComposeCommandWithRetry(workingDir string, showCommand bool, pipeStdout bool, command ...string) (err error) {
for i := 0; err != nil && i < 3; i++ {
err = RunDockerComposeCommand(workingDir, showCommand, pipeStdout, command...)
}
return err
}

func RunDockerComposeCommand(workingDir string, showCommand bool, pipeStdout bool, command ...string) error {
dockerCmd := exec.Command("docker-compose", command...)
dockerCmd.Dir = workingDir
Expand Down
5 changes: 5 additions & 0 deletions internal/stacks/stack_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ func (s *StackManager) runStartupSequence(workingDir string, verbose bool, first
}

s.Log.Info("starting FireFly dependencies")

if err := docker.RunDockerComposeCommandWithRetry(workingDir, verbose, verbose, "pull"); err != nil {
return err
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We already do a pull (if --no-pull is not set) here:

if !options.NoPull {
s.Log.Info("pulling latest versions")
if err := docker.RunDockerComposeCommand(workingDir, verbose, verbose, "pull"); err != nil {
return err
}
}

Should we just change that existing call to RunDockerComposeCommandWithRetry?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha, this is a great point… but what it points at (which I totally missed) is the problem is the e2e test is doing a no-pull 🤦‍♂️

So 👍 to moving the retry on the existing pull, but it means this won’t actually fix the issue.

We might need to punt this to after your manifest work, and have a new behavior for the e2e test where it no long specifies no-pull, but instead uses a different (local) image name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made the change on this PR, and am up for working on the follow-on change to generate a special manifest in the e2e test code once the manifest work is ready

if err := docker.RunDockerComposeCommand(workingDir, verbose, verbose, "up", "-d"); err != nil {
return err
}
Expand Down