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

healthcheck: set appropriate defaults for interval, timeout and retries #225

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,21 @@ func TestBuilder(t *testing.T) {
},
},
},
{
Dockerfile: "dockerclient/testdata/Dockerfile.healthcheckdefaults",
From: "debian",
Config: docker.Config{
Image: "debian",
Cmd: []string{"/bin/sh", "-c", "/app/main.sh"},
Healthcheck: &docker.HealthConfig{
StartPeriod: 0 * time.Second,
Interval: 30 * time.Second,
Timeout: 30 * time.Second,
Retries: 3,
Test: []string{"CMD-SHELL", "/app/check.sh --quiet"},
},
},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm probably overthinking, but I just wonder if we're starting to brush up against DockerHub rate limits. No need to adjust, just thought I'd put that thought out there.

Copy link
Member

Choose a reason for hiding this comment

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

We tend to use one of a handful of base images for various tests, and the docker daemon hangs on to them between tests, but you're not wrong to be concerned that it will become a problem at some point.

{
Dockerfile: "dockerclient/testdata/Dockerfile.envsubst",
From: "busybox",
Expand Down
8 changes: 4 additions & 4 deletions dispatchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,12 +516,12 @@ func healthcheck(b *Builder, args []string, attributes map[string]bool, flagArgs
}

healthcheck := docker.HealthConfig{}

// Use docker defaults for flags https://docs.docker.com/engine/reference/builder/#healthcheck
flags := flag.NewFlagSet("", flag.ContinueOnError)
flags.String("start-period", "", "")
flags.String("interval", "", "")
flags.String("timeout", "", "")
flRetries := flags.String("retries", "", "")
flags.String("interval", "30s", "")
flags.String("timeout", "30s", "")
flRetries := flags.String("retries", "3", "")

if err := flags.Parse(flagArgs); err != nil {
return err
Expand Down
6 changes: 6 additions & 0 deletions dockerclient/testdata/Dockerfile.healthcheckdefaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM debian
CMD /app/main.sh
HEALTHCHECK CMD a b
HEALTHCHECK CMD ["foo"]
HEALTHCHECK CMD /app/check.sh --quiet