-
Notifications
You must be signed in to change notification settings - Fork 40k
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
break api.Probe out of api.LivenessProbe #3818
Conversation
LGTM at a high level. |
For some extra context, I'll copy over a comment from a previous discussion where @bgrant0607 said that api.LivenessProbe could be renamed to api.Probe. Rather than renaming LivenessProbe, we could break the Actions into a Probe type and maintain {Context}Probes that hold a Probe and context specific configuration. e.g. type Probe struct {
HTTPGet *HTTPGetAction `json:"httpGet,omitempty"`
TCPSocket *TCPSocketAction `json:"tcpSocket,omitempty"`
Exec *ExecAction `json:"exec,omitempty"`
}
type LivenessProbe struct {
Probe Probe `json:",inline"`
InitialDelaySeconds int64 `json:"initialDelaySeconds,omitempty"`
}
type ReadinessProbe struct {
Probe Probe `json:",inline"`
TimeoutSeconds int64 `json:"timeoutSeconds,omitempty"`
FrequencySeconds int64 `json:"frequencySeconds,omitempty"`
UnhealthyThreshold int64 `json:"unhealthyThreshold,omitempty"`
HealthyThreshold int64 `json:"healthyThreshold,omitempty"`
} I'm not sure if this is over thinking it as most settings could make sense for most contexts, but I can see a few benefits to this approach. We could add configs to ContextProbes as they become implemented (i.e. we wouldn't have config fields that do things in some spots and are unimplemented in others). We could also have Context specific configs. Alternatively, we could rename LivenessProbe to Probe and break out ContextProbes later on if needed. |
type LivenessProbe struct { | ||
// The action taken to determine the health of a container | ||
Probe Probe `json:",inline"` |
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.
Why give the field a name? Why not just embed it?
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.
No reason. Done.
2e0e471
to
fd08b33
Compare
Copying over my response from #3695: I think all the fields you specify make sense for both types of probes. I do, however, like the factoring in your ReadinessProbe example -- splitting the probe specification from the control and interpretation parameters. That's similar to the factoring of Volume vs. VolumeSource. If we could unify it with the Handler type, it would be pretty compelling, addressing a long-standing TODO. Otherwise, I don't know that there's a practical benefit to clients. We could consider inlining the inner struct into the outer, if that's the case. |
As per my previous comment, how about As for the bundle of actions, options are:
Obviously, if we did unify with Handler, we should implement TCP lifecycle hooks, though I'm happy to TODO that initially and just document it as a caveat. |
fd08b33
to
6f878c1
Compare
I've renamed LivenessProbe to Probe and attempted to use the Handler type for the Actions so take a look. I'm happy to break the bundle into another type if Handler doesn't make sense yet. I'm having trouble imagining what a TCPSocket lifecycle handler would do/look like in configuration. |
// Probe describes a liveness probe to be examined to the container. | ||
type Probe struct { | ||
// The action taken to determine the health of a container | ||
Handler `json:",inline"` |
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 suggested embedding here. However, I realized this is inconsistent with VolumeSource.
@bgrant0607 preference for style? The difference in JSON comes down to:
"livenessProbe": { "initalDelaySeconds": 10, "exec": { ... } }
"volumes": [ { "name": "vol1", "hostDir": { "path": "/tmp" } } ]
vs
"livenessProbe": { "initalDelaySeconds": 10, "handler": { "exec": { ... } } }
"volumes": [ { "name": "vol1", "source": { "hostDir": { "path": "/tmp" } } } ]
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 prefer inlining/embedding.
LGTM at a high level, also. |
LGTM |
3d0cfe7
to
348a398
Compare
I also want to run e2e on this. Assuming both of your PRs in this area pass, which do you want to go in first in case of merge? |
Needs a rebase, now. Blame yourself :) |
348a398
to
78f33e9
Compare
@thockin this is ready. |
running e2e against this now |
e2e passes |
break api.Probe out of api.LivenessProbe
This PR breaks an api.Probe out of api.LivenessProbe so that it can be used in api types to be added. The breakout was chosen rather than renaming LivenessProbe so that future Probes need not share all configuration fields. For instance InitialDelaySeconds may not be relevant in a ReadinessProbe. This will cause conflicts with #3695 but it would make sense for this to be merged first.
/cc @bgrant0607