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

break api.Probe out of api.LivenessProbe #3818

Merged
merged 1 commit into from
Jan 28, 2015

Conversation

mikedanese
Copy link
Member

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

@smarterclayton
Copy link
Contributor

LGTM at a high level.

@mikedanese
Copy link
Member Author

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"`
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

No reason. Done.

@mikedanese mikedanese changed the title break api.Probe out of api.LivenessProbe WIP: break api.Probe out of api.LivenessProbe Jan 27, 2015
@bgrant0607
Copy link
Member

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.

@bgrant0607
Copy link
Member

As per my previous comment, how about Probe rather than LivenessProbe? I think all the same fields can work for Readiness.

As for the bundle of actions, options are:

  • Action
  • Call
  • Hook
  • Handler

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.

@mikedanese
Copy link
Member Author

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"`
Copy link
Member

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" } } } ]

Copy link
Member

Choose a reason for hiding this comment

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

I prefer inlining/embedding.

@bgrant0607
Copy link
Member

LGTM at a high level, also.

@thockin
Copy link
Member

thockin commented Jan 28, 2015

LGTM

@mikedanese mikedanese force-pushed the probe-refactor branch 2 times, most recently from 3d0cfe7 to 348a398 Compare January 28, 2015 05:57
@mikedanese mikedanese changed the title WIP: break api.Probe out of api.LivenessProbe break api.Probe out of api.LivenessProbe Jan 28, 2015
@thockin
Copy link
Member

thockin commented Jan 28, 2015

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?

@mikedanese
Copy link
Member Author

@thockin It will be easier for me if #3695 goes first.

@thockin
Copy link
Member

thockin commented Jan 28, 2015

Needs a rebase, now. Blame yourself :)

@mikedanese
Copy link
Member Author

@thockin this is ready.

@thockin
Copy link
Member

thockin commented Jan 28, 2015

running e2e against this now

@thockin
Copy link
Member

thockin commented Jan 28, 2015

e2e passes

thockin added a commit that referenced this pull request Jan 28, 2015
break api.Probe out of api.LivenessProbe
@thockin thockin merged commit 804643a into kubernetes:master Jan 28, 2015
@mikedanese mikedanese deleted the probe-refactor branch January 28, 2015 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants