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
feat(manifest): add HTTP Health Check hidden fields #1592
Conversation
Heya @huanjani I haven't read the PR but is it possible to update the fields in the manifest to be separated by underscores instead of camelCase (for consistency) and be under the # Option 1. Provide only a path and assume Copilot's default
healthcheck: '/' # Option 2. Advanced configuration:
healthcheck:
path: '/'
healthy_threshold: 5
unhealthy_threshold: 5
interval: 30s # Uses golang time.Duration type
timeout: 5s # Uses golang time.Duration type We do this sort of advanced configuration for both the |
manifest option 1:
stack for option 1:
manifest option 2:
stack for option 2
|
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.
This looks great! This will be so helpful to fix some of those annoying flapping container deployments due to failed healthchecks on startup!
"error if unmarshalable": { | ||
inContent: []byte(` healthcheck: | ||
bath: to ruin | ||
unwealthy_threshold: berry`), |
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.
😂
) | ||
|
||
var ( | ||
errUnmarshalHealthCheckArgs = errors.New("can't unmarshal healthcheck field into string or compose-style map") |
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.
nit: let's remove words like cannot from the error message unless it's in the cli
pkg (the root pkg)
When adding context to returned errors, keep the context succinct by avoiding phrases like "failed to", which state the obvious and pile up as the error percolates up through the stack:
https://github.com/uber-go/guide/blob/master/style.md#error-wrapping
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.
I think it is fine to keep can't
in this scenario since it is already the root error instead of wrapping the other error. Agree if we are wrapping error we want to avoid piling up like failed to get health check: can't unmarshal health check
. And instead we want get health check: can't unmarshal health check
. What do you all think?
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.
More the opposite, cannot get health check: unmarshal health check
. Where the root error that wraps others can use "cannot" to make it more human friendly but "library" pkgs shouldn't put cannot in their error messages
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.
But according to https://github.com/uber-go/guide/blob/master/style.md#error-wrapping, isn't cannot get health check: unmarshal health check
a bad example?
internal/pkg/manifest/lb_web_svc.go
Outdated
// TargetContainer is the container load balancer routes traffic to. | ||
TargetContainer *string `yaml:"targetContainer"` | ||
TargetContainer *string `yaml:"target_container"` |
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.
Ah I wish we could change this :'( but we would need to support both targetContainer
and target_container
to maintain backwards compatibility.
Right now this will break users that have targetContainer
as a field. We'd need to figure out a way of assigning two yaml fields to TargetContainer
.
Maybe this works?
TargetContainer *string `yaml:"target_container"` | |
TargetContainer *string `yaml:"target_container" yaml:"targetContainer"` // "targetContainer" for backwards compatibility |
If it does great, otherwise can we punt this change to a separate PR?
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.
Okay, so that ☝️ didn't work and some digging/reading makes me think there isn't a built-in way to do this, but this little hack works:
In manifest/lb_web_svc.go
, I added another field to the struct for camel case.
In stack/lb_web_svc.go
:
if s.manifest.TargetContainer == nil && s.manifest.TargetContainerCamelCase != nil {
s.manifest.TargetContainer = s.manifest.TargetContainerCamelCase
}
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.
brilliant! that sounds good to me!
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.
samesies thanks for diving deep on this!
<span class="parent-field">http.</span><a id="http-healthcheck" href="#http-healthcheck" class="field">`healthcheck`</a> <span class="type">String or Map</span> | ||
If you specify a string, Copilot interprets it as the path exposed in your container to handle target group health check requests. The default is "/". |
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.
😍 thank you for updating the docs!
You can also specify healthcheck as a map: | ||
```yaml | ||
http: | ||
healthcheck: | ||
path: '/' | ||
healthy_threshold: 3 | ||
unhealthy_threshold: 2 | ||
interval: 15s | ||
timeout: 10s | ||
``` |
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.
Awesome! This is gorgeous!
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.
+1
) | ||
|
||
var ( | ||
errUnmarshalHealthCheckArgs = errors.New("can't unmarshal healthcheck field into string or compose-style map") |
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.
But according to https://github.com/uber-go/guide/blob/master/style.md#error-wrapping, isn't cannot get health check: unmarshal health check
a bad example?
Great job @huanjani looking forward to the release! |
This enables the customization of four Load Balanced Web Service health check variables: HealthyThreshold, UnhealthyThreshold, Interval, and Timeout are now hidden fields in the manifest. Resolves aws#1195. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
This enables the customization of four Load Balanced Web Service health check variables: HealthyThreshold, UnhealthyThreshold, Interval, and Timeout are now hidden fields in the manifest.
Resolves #1195.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.