-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Support readiness checks #4048
Merged
Merged
Support readiness checks #4048
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,10 +339,11 @@ type Container struct { | |
Ports []Port `json:"ports,omitempty"` | ||
Env []EnvVar `json:"env,omitempty"` | ||
// Compute resource requirements. | ||
Resources ResourceRequirements `json:"resources,omitempty"` | ||
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty"` | ||
LivenessProbe *Probe `json:"livenessProbe,omitempty"` | ||
Lifecycle *Lifecycle `json:"lifecycle,omitempty"` | ||
Resources ResourceRequirements `json:"resources,omitempty"` | ||
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty"` | ||
LivenessProbe *Probe `json:"livenessProbe,omitempty"` | ||
ReadinessProbe *Probe `json:"readinessProbe,omitempty"` | ||
Lifecycle *Lifecycle `json:"lifecycle,omitempty"` | ||
// Optional: Defaults to /dev/termination-log | ||
TerminationMessagePath string `json:"terminationMessagePath,omitempty"` | ||
// Optional: Default to false. | ||
|
@@ -380,27 +381,16 @@ type Lifecycle struct { | |
|
||
// The below types are used by kube_client and api_server. | ||
|
||
// PodPhase is a label for the condition of a pod at the current time. | ||
type PodPhase string | ||
type ConditionStatus string | ||
|
||
// These are the valid statuses of pods. | ||
// These are valid condition statuses. "ConditionFull" means a resource is in the condition; | ||
// "ConditionNone" means a resource is not in the condition; "ConditionUnknown" means kubernetes | ||
// can't decide if a resource is in the condition or not. In the future, we could add other | ||
// intermediate conditions, e.g. ConditionDegraded. | ||
const ( | ||
// PodPending means the pod has been accepted by the system, but one or more of the containers | ||
// has not been started. This includes time before being bound to a node, as well as time spent | ||
// pulling images onto the host. | ||
PodPending PodPhase = "Pending" | ||
// PodRunning means the pod has been bound to a node and all of the containers have been started. | ||
// At least one container is still running or is in the process of being restarted. | ||
PodRunning PodPhase = "Running" | ||
// PodSucceeded means that all containers in the pod have voluntarily terminated | ||
// with a container exit code of 0, and the system is not going to restart any of these containers. | ||
PodSucceeded PodPhase = "Succeeded" | ||
// PodFailed means that all containers in the pod have terminated, and at least one container has | ||
// terminated in a failure (exited with a non-zero exit code or was stopped by the system). | ||
PodFailed PodPhase = "Failed" | ||
// PodUnknown means that for some reason the state of the pod could not be obtained, typically due | ||
// to an error in communicating with the host of the pod. | ||
PodUnknown PodPhase = "Unknown" | ||
ConditionFull ConditionStatus = "Full" | ||
ConditionNone ConditionStatus = "None" | ||
ConditionUnknown ConditionStatus = "Unknown" | ||
) | ||
|
||
type ContainerStateWaiting struct { | ||
|
@@ -434,6 +424,8 @@ type ContainerStatus struct { | |
// TODO(dchen1107): Should we rename PodStatus to a more generic name or have a separate states | ||
// defined for container? | ||
State ContainerState `json:"state,omitempty"` | ||
// Ready specifies whether the conatiner has passed its readiness check. | ||
Ready bool `json:"ready"` | ||
// Note that this is calculated from dead containers. But those containers are subject to | ||
// garbage collection. This value will get capped at 5 by GC. | ||
RestartCount int `json:"restartCount"` | ||
|
@@ -446,6 +438,44 @@ type ContainerStatus struct { | |
ContainerID string `json:"containerID,omitempty" description:"container's ID in the format 'docker://<container_id>'"` | ||
} | ||
|
||
// PodPhase is a label for the condition of a pod at the current time. | ||
type PodPhase string | ||
|
||
// These are the valid statuses of pods. | ||
const ( | ||
// PodPending means the pod has been accepted by the system, but one or more of the containers | ||
// has not been started. This includes time before being bound to a node, as well as time spent | ||
// pulling images onto the host. | ||
PodPending PodPhase = "Pending" | ||
// PodRunning means the pod has been bound to a node and all of the containers have been started. | ||
// At least one container is still running or is in the process of being restarted. | ||
PodRunning PodPhase = "Running" | ||
// PodSucceeded means that all containers in the pod have voluntarily terminated | ||
// with a container exit code of 0, and the system is not going to restart any of these containers. | ||
PodSucceeded PodPhase = "Succeeded" | ||
// PodFailed means that all containers in the pod have terminated, and at least one container has | ||
// terminated in a failure (exited with a non-zero exit code or was stopped by the system). | ||
PodFailed PodPhase = "Failed" | ||
// PodUnknown means that for some reason the state of the pod could not be obtained, typically due | ||
// to an error in communicating with the host of the pod. | ||
PodUnknown PodPhase = "Unknown" | ||
) | ||
|
||
type PodConditionKind string | ||
|
||
// These are valid conditions of pod. | ||
const ( | ||
// PodReady means the pod is able to service requests and should be added to the | ||
// load balancing pools of all matching services. | ||
PodReady PodConditionKind = "Ready" | ||
) | ||
|
||
// TODO: add LastTransitionTime, Reason, Message to match NodeCondition api. | ||
type PodCondition struct { | ||
Kind PodConditionKind `json:"kind"` | ||
Status ConditionStatus `json:"status"` | ||
} | ||
|
||
// PodInfo contains one entry for every container with available info. | ||
type PodInfo map[string]ContainerStatus | ||
|
||
|
@@ -516,8 +546,8 @@ type PodSpec struct { | |
// PodStatus represents information about the status of a pod. Status may trail the actual | ||
// state of a system. | ||
type PodStatus struct { | ||
Phase PodPhase `json:"phase,omitempty"` | ||
|
||
Phase PodPhase `json:"phase,omitempty"` | ||
Conditions []PodCondition `json:"Condition,omitempty"` | ||
// A human readable message indicating details about why the pod is in this state. | ||
Message string `json:"message,omitempty"` | ||
|
||
|
@@ -759,25 +789,13 @@ const ( | |
NodeReady NodeConditionKind = "Ready" | ||
) | ||
|
||
type NodeConditionStatus string | ||
|
||
// These are valid condition status. "ConditionFull" means node is in the condition; | ||
// "ConditionNone" means node is not in the condition; "ConditionUnknown" means kubernetes | ||
// can't decide if node is in the condition or not. In the future, we could add other | ||
// intermediate conditions, e.g. ConditionDegraded. | ||
const ( | ||
ConditionFull NodeConditionStatus = "Full" | ||
ConditionNone NodeConditionStatus = "None" | ||
ConditionUnknown NodeConditionStatus = "Unknown" | ||
) | ||
|
||
type NodeCondition struct { | ||
Kind NodeConditionKind `json:"kind"` | ||
Status NodeConditionStatus `json:"status"` | ||
LastProbeTime util.Time `json:"lastProbeTime,omitempty"` | ||
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty"` | ||
Reason string `json:"reason,omitempty"` | ||
Message string `json:"message,omitempty"` | ||
Kind NodeConditionKind `json:"kind"` | ||
Status ConditionStatus `json:"status"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for doing this refactoring. FYI, I'm going to try to merge #4241 first, since we're having a bunch of problems in that area right now. |
||
LastProbeTime util.Time `json:"lastProbeTime,omitempty"` | ||
LastTransitionTime util.Time `json:"lastTransitionTime,omitempty"` | ||
Reason string `json:"reason,omitempty"` | ||
Message string `json:"message,omitempty"` | ||
} | ||
|
||
// NodeResources is an object for conveying resource information about a node. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It's not clear to me why this is an array?
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.
As per @bgrant0607's suggestion, this is intended to be like NodCondition as he expects to add more conditions in the future. I stopped short of creating the PodCondition struct but I could in order to fully mirror NodeCondition api. Until more PodConditions are added, Ready bool would be a functional substitute for Conditions. So I guess it comes down to whether we want to add PodCondition to the api now or hold off until later.
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.
OK
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 would like to add PodCondition now. I'm ok we initially omit some fields, such as LastTransitionTime, Reason, and Message.