-
Notifications
You must be signed in to change notification settings - Fork 691
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 the ability to add healthcheck definition for containers #1742
Conversation
Original issue: bazelbuild#770 Adds follow options for container_image: - healthcheck_test - healthcheck_interval - healthcheck_timeout - healthcheck_start_period - healthcheck_retries
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: svagner The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@googlebot I signed it! |
cc @xingao267 , @alex1545 as you were in the discussion in the original issue |
Hiding whitespace changes definitely makes this diff easier to review: https://github.com/bazelbuild/rules_docker/pull/1742/files?w=1 |
README.md
Outdated
The test to perform to check that the container is healthy.</a></p> | ||
<p>An empty list means to inherit the default.</p> | ||
<p>Possible definition options are:</p> | ||
<p><code>[]</code> : inherit healthcheck</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None
also inherits the healthcheck. It may be nice to specify this for callers who write their own macros wrapping this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added. Thanks!
I don't see a reason why this couldn't be merged. The only concern I have is that we're overloading I'm leaning towards thinking this is fine to include but I'd like the opinion of another maintainer just as a sanity check. |
I think it's cool that you put this together, but I'm a little wary of this as-is for a couple of reasons:
|
Yeah. I also thought that probably it's better to have |
Thanks for the feedback. Let me explain my thoughts about it.
Let me know if my arguments make sense to you. |
I don't see how And it is definitely necessary to parse it, because the configuration for it is not a simple string. It is https://github.com/moby/moby/blob/46cdcd206c56172b95ba5c77b827a722dab426c5/api/types/container/config.go#L16-L35: // HealthConfig holds configuration settings for the HEALTHCHECK feature.
type HealthConfig struct {
// Test is the test to perform to check that the container is healthy.
// An empty slice means to inherit the default.
// The options are:
// {} : inherit healthcheck
// {"NONE"} : disable healthcheck
// {"CMD", args...} : exec arguments directly
// {"CMD-SHELL", command} : run command with system's default shell
Test []string `json:",omitempty"`
// Zero means to inherit. Durations are expressed as integer nanoseconds.
Interval time.Duration `json:",omitempty"` // Interval is the time to wait between checks.
Timeout time.Duration `json:",omitempty"` // Timeout is the time to wait before considering the check to have hung.
StartPeriod time.Duration `json:",omitempty"` // The start period for the container to initialize before the retries starts to count down.
// Retries is the number of consecutive failures needed to consider a container as unhealthy.
// Zero means inherit.
Retries int `json:",omitempty"`
} Part of the parser is here: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/parser/line_parsers.go#L343-L369 But rules_docker has no dependency on moby library, it has a dependency on go-containerregistry, which has the same copy of the config: https://github.com/moby/buildkit/blob/master/frontend/dockerfile/parser/line_parsers.go#L343-L369. Yes, as far as I know, there is no parsing logic in go-containerregistry to transform a string into that config. The parsing logic should be upstreamed there, in the same place that has the config. Once that logic is there, we could call Also, rules_docker should not strive to replicate every feature in docker or a Dockerfile. A noteable absence is the |
Ah, you meant about an unmarshaling line to the struct. Yeah. Makes sense. I'm not sure
|
If we can get a parsing function upstreamed and simplify this PR to add only a single |
@svagner will you continue this PR? |
Hey @jonjohnsonjr what do you think about the proposed upstream change to go-containerregistry? |
That sounds reasonable to me, something like I'm happy to review a PR. |
Any progress on this? Would be great to get this added!! If you want to use ecs with out elb/alb for internal services with service discovery the way they support health checks is through docker health check. Without this it becomes an issue. |
hi, i'm going to take a crack at picking this up and upstreaming said changes. posting to shame myself into followthrough. |
This Pull Request has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
hey @pjjw, any luck? |
no, have not plumbed this upstream yet, but this diff works for us as-is. |
This Pull Request has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
This PR was automatically closed because it went 30 days without a reply since it was labeled "Can Close?" |
Original issue: #770
Adds follow options for container_image: