-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Making the pod.alpha.kubernetes.io/initialized annotation optional in PetSet pods #35739
Making the pod.alpha.kubernetes.io/initialized annotation optional in PetSet pods #35739
Conversation
862cab0
to
0e04556
Compare
func (d *defaultPetHealthChecker) isHealthy(pod *api.Pod) bool { | ||
if pod == nil || pod.Status.Phase != api.PodRunning { | ||
return false | ||
} | ||
initialized, ok := pod.Annotations[PetSetInitAnnotation] | ||
if !ok { | ||
glog.Infof("PetSet pod %v in %v, waiting on annotation %v", api.PodRunning, pod.Name, PetSetInitAnnotation) | ||
return false | ||
// if the annotation was not found, we just perform a readiness check. |
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: we don't perform the check, we just check to see if the pod has passed the check
// isHealthy returns true if the pod is running and has the | ||
// "pod.alpha.kubernetes.io/initialized" set to "true". | ||
// isHealthy returns true if the pod is running and if it has the | ||
// "pod.alpha.kubernetes.io/initialized" annotation, it is set to "true". | ||
func (d *defaultPetHealthChecker) isHealthy(pod *api.Pod) bool { | ||
if pod == nil || pod.Status.Phase != api.PodRunning { | ||
return false | ||
} | ||
initialized, ok := pod.Annotations[PetSetInitAnnotation] |
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 might as well rename the variable holding the annotation to StatefulSetInitAnnotation or whatever we're going to use as the suffix
@@ -297,22 +297,23 @@ type petHealthChecker interface { | |||
// It doesn't update, probe or get the pod. | |||
type defaultPetHealthChecker struct{} | |||
|
|||
// isHealthy returns true if the pod is running and has the | |||
// "pod.alpha.kubernetes.io/initialized" set to "true". | |||
// isHealthy returns true if the pod is running and if it has the |
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: pod is running and ready, and please reword to "if the pod is running and ready. If it has the ... set to false, pod state is ignored."
glog.Infof("PetSet pod %v in %v, waiting on annotation %v", api.PodRunning, pod.Name, PetSetInitAnnotation) | ||
return false | ||
// if the annotation was not found, we just perform a readiness check. | ||
return api.IsPodReady(pod) | ||
} | ||
b, err := strconv.ParseBool(initialized) |
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 slightly prefer something like:
podReady := api.IsPodReady()
// User might've specified a pod readiness override through a debug annotation
initialized, ok := pod.Annotations[PetSetInitAnnotation]
if ok {
if initAnnotation, err := ParseBool(); err != nil {
glog.Infof("failed to parse annotation %v", err)
} else if !initAnnotation {
podReady = initAnnotation
}
}
return podReady
@@ -889,6 +889,9 @@ func newPetSet(name, ns, governingSvcName string, replicas int32, petMounts []ap | |||
ObjectMeta: api.ObjectMeta{ | |||
Name: name, | |||
Namespace: ns, | |||
Annotations: map[string]string { | |||
"pod.alpha.kubernetes.io/initialized": "false", |
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.
so we're not renaming the part after the "/"?
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 we can let it be for now and think about it when we're updating the examples?
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'm ok with letting it be inverted just for this PR.
Jenkins GCI GCE e2e failed for commit 0e04556. Full PR test history. The magic incantation to run this job again is |
0e04556
to
ccae356
Compare
5d2ca90
to
c5ff869
Compare
@bprashanth Updated. PTAL. |
c5ff869
to
5c3792a
Compare
@k8s-bot cvm gke e2e test this |
Jenkins GKE smoke e2e failed for commit 5c3792a. Full PR test history. The magic incantation to run this job again is |
@k8s-bot cvm gke e2e test this |
/lgtm |
LGTM thanks |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue |
@foxish just a reminder that statefulset docs need to be updated too |
Automatic merge from submit-queue Set the annotation only if the test requires it. **What this PR does / why we need it**: Fixes StatefulSet flake **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #36107 **Special notes for your reviewer**: We shouldn't be setting the debug annotation in all our tests, only the ones that bring statefulset pods up one after another. In the absence of the annotation, we have the new default behavior governed by #35739 **Release note**: ```release-note NONE ``` cc @kubernetes/sig-apps @bprashanth @calebamiles
What this PR does / why we need it: As of now, the absence of the annotation
pod.alpha.kubernetes.io/initialized
in PetSets causes the PetSet controller to effectively "pause". Being a debug hook, users expect that its absence has no effect on the working of a PetSet. This PR inverts the logic so that we let the PetSet controller operate as expected in the absence of the annotation.Letting the annotation remain alpha seems ok. Renaming it to something more meaningful needs further discussion.
Which issue this PR fixes (optional, in
fixes #<issue number>(, #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #35498Special notes for your reviewer:
Release note:
cc @erictune @smarterclayton @bprashanth @kubernetes/sig-apps
@kow3ns The examples will need to be cleaned up as well I think later on to remove them.
This change is