mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Flipping behavior when annotation is absent.
This commit is contained in:
parent
e6b2517feb
commit
5c3792a4db
@ -297,22 +297,25 @@ type petHealthChecker interface {
|
|||||||
// It doesn't update, probe or get the pod.
|
// It doesn't update, probe or get the pod.
|
||||||
type defaultPetHealthChecker struct{}
|
type defaultPetHealthChecker struct{}
|
||||||
|
|
||||||
// isHealthy returns true if the pod is running and has the
|
// isHealthy returns true if the pod is ready & running. If the pod has the
|
||||||
// "pod.alpha.kubernetes.io/initialized" set to "true".
|
// "pod.alpha.kubernetes.io/initialized" annotation set to "false", pod state is ignored.
|
||||||
func (d *defaultPetHealthChecker) isHealthy(pod *api.Pod) bool {
|
func (d *defaultPetHealthChecker) isHealthy(pod *api.Pod) bool {
|
||||||
if pod == nil || pod.Status.Phase != api.PodRunning {
|
if pod == nil || pod.Status.Phase != api.PodRunning {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
podReady := api.IsPodReady(pod)
|
||||||
|
|
||||||
|
// User may have specified a pod readiness override through a debug annotation.
|
||||||
initialized, ok := pod.Annotations[StatefulSetInitAnnotation]
|
initialized, ok := pod.Annotations[StatefulSetInitAnnotation]
|
||||||
if !ok {
|
if ok {
|
||||||
glog.Infof("StatefulSet pod %v in %v, waiting on annotation %v", api.PodRunning, pod.Name, StatefulSetInitAnnotation)
|
if initAnnotation, err := strconv.ParseBool(initialized); err != nil {
|
||||||
return false
|
glog.Infof("Failed to parse %v annotation on pod %v: %v", StatefulSetInitAnnotation, pod.Name, err)
|
||||||
|
} else if !initAnnotation {
|
||||||
|
glog.Infof("StatefulSet pod %v waiting on annotation %v", pod.Name, StatefulSetInitAnnotation)
|
||||||
|
podReady = initAnnotation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
b, err := strconv.ParseBool(initialized)
|
return podReady
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return b && api.IsPodReady(pod)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// isDying returns true if the pod has a non-nil deletion timestamp. Since the
|
// isDying returns true if the pod has a non-nil deletion timestamp. Since the
|
||||||
|
@ -889,6 +889,9 @@ func newStatefulSet(name, ns, governingSvcName string, replicas int32, petMounts
|
|||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
Namespace: ns,
|
Namespace: ns,
|
||||||
|
Annotations: map[string]string{
|
||||||
|
"pod.alpha.kubernetes.io/initialized": "false",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Spec: apps.StatefulSetSpec{
|
Spec: apps.StatefulSetSpec{
|
||||||
Selector: &unversioned.LabelSelector{
|
Selector: &unversioned.LabelSelector{
|
||||||
|
Loading…
Reference in New Issue
Block a user