add TODOs for moving rooling update label on pods
This commit is contained in:
parent
2c3cd3ae02
commit
d150a477f0
|
|
@ -1279,6 +1279,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||||
}
|
}
|
||||||
|
|
||||||
stsAnnotations := make(map[string]string)
|
stsAnnotations := make(map[string]string)
|
||||||
|
// TODO remove from sts
|
||||||
stsAnnotations[rollingUpdateStatefulsetAnnotationKey] = strconv.FormatBool(false)
|
stsAnnotations[rollingUpdateStatefulsetAnnotationKey] = strconv.FormatBool(false)
|
||||||
stsAnnotations = c.AnnotationsToPropagate(c.annotationsSet(nil))
|
stsAnnotations = c.AnnotationsToPropagate(c.annotationsSet(nil))
|
||||||
|
|
||||||
|
|
@ -1305,6 +1306,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
|
||||||
|
|
||||||
func (c *Cluster) generatePodAnnotations(spec *acidv1.PostgresSpec) map[string]string {
|
func (c *Cluster) generatePodAnnotations(spec *acidv1.PostgresSpec) map[string]string {
|
||||||
annotations := make(map[string]string)
|
annotations := make(map[string]string)
|
||||||
|
// TODO annotations[rollingUpdatePodAnnotationKey] = strconv.FormatBool(false)
|
||||||
for k, v := range c.OpConfig.CustomPodAnnotations {
|
for k, v := range c.OpConfig.CustomPodAnnotations {
|
||||||
annotations[k] = v
|
annotations[k] = v
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -384,6 +384,7 @@ func (c *Cluster) recreatePods() error {
|
||||||
|
|
||||||
if masterPod != nil {
|
if masterPod != nil {
|
||||||
// failover if we have not observed a master pod when re-creating former replicas.
|
// failover if we have not observed a master pod when re-creating former replicas.
|
||||||
|
// TODO if masterPod has no rolling update label anymore skip switchover too
|
||||||
if newMasterPod == nil && len(replicas) > 0 {
|
if newMasterPod == nil && len(replicas) > 0 {
|
||||||
if err := c.Switchover(masterPod, masterCandidate(replicas)); err != nil {
|
if err := c.Switchover(masterPod, masterCandidate(replicas)); err != nil {
|
||||||
c.logger.Warningf("could not perform switch over: %v", err)
|
c.logger.Warningf("could not perform switch over: %v", err)
|
||||||
|
|
@ -393,6 +394,7 @@ func (c *Cluster) recreatePods() error {
|
||||||
}
|
}
|
||||||
c.logger.Infof("recreating old master pod %q", util.NameFromMeta(masterPod.ObjectMeta))
|
c.logger.Infof("recreating old master pod %q", util.NameFromMeta(masterPod.ObjectMeta))
|
||||||
|
|
||||||
|
// TODO only if rolling update label is present
|
||||||
if _, err := c.recreatePod(util.NameFromMeta(masterPod.ObjectMeta)); err != nil {
|
if _, err := c.recreatePod(util.NameFromMeta(masterPod.ObjectMeta)); err != nil {
|
||||||
return fmt.Errorf("could not recreate old master pod %q: %v", util.NameFromMeta(masterPod.ObjectMeta), err)
|
return fmt.Errorf("could not recreate old master pod %q: %v", util.NameFromMeta(masterPod.ObjectMeta), err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// TODO rollingUpdatePodAnnotationKey = "zalando-postgres-operator-rolling-update-required"
|
||||||
rollingUpdateStatefulsetAnnotationKey = "zalando-postgres-operator-rolling-update-required"
|
rollingUpdateStatefulsetAnnotationKey = "zalando-postgres-operator-rolling-update-required"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -147,6 +148,7 @@ func (c *Cluster) preScaleDown(newStatefulSet *appsv1.StatefulSet) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO setRollingUpdateFlagForPod
|
||||||
// setRollingUpdateFlagForStatefulSet sets the indicator or the rolling update requirement
|
// setRollingUpdateFlagForStatefulSet sets the indicator or the rolling update requirement
|
||||||
// in the StatefulSet annotation.
|
// in the StatefulSet annotation.
|
||||||
func (c *Cluster) setRollingUpdateFlagForStatefulSet(sset *appsv1.StatefulSet, val bool, msg string) {
|
func (c *Cluster) setRollingUpdateFlagForStatefulSet(sset *appsv1.StatefulSet, val bool, msg string) {
|
||||||
|
|
@ -160,6 +162,7 @@ func (c *Cluster) setRollingUpdateFlagForStatefulSet(sset *appsv1.StatefulSet, v
|
||||||
c.logger.Debugf("set statefulset's rolling update annotation to %t: caller/reason %s", val, msg)
|
c.logger.Debugf("set statefulset's rolling update annotation to %t: caller/reason %s", val, msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO applyRollingUpdateFlagForPod
|
||||||
// applyRollingUpdateFlagforStatefulSet sets the rolling update flag for the cluster's StatefulSet
|
// applyRollingUpdateFlagforStatefulSet sets the rolling update flag for the cluster's StatefulSet
|
||||||
// and applies that setting to the actual running cluster.
|
// and applies that setting to the actual running cluster.
|
||||||
func (c *Cluster) applyRollingUpdateFlagforStatefulSet(val bool) error {
|
func (c *Cluster) applyRollingUpdateFlagforStatefulSet(val bool) error {
|
||||||
|
|
@ -172,6 +175,7 @@ func (c *Cluster) applyRollingUpdateFlagforStatefulSet(val bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO getRollingUpdateFlagFromPod
|
||||||
// getRollingUpdateFlagFromStatefulSet returns the value of the rollingUpdate flag from the passed
|
// getRollingUpdateFlagFromStatefulSet returns the value of the rollingUpdate flag from the passed
|
||||||
// StatefulSet, reverting to the default value in case of errors
|
// StatefulSet, reverting to the default value in case of errors
|
||||||
func (c *Cluster) getRollingUpdateFlagFromStatefulSet(sset *appsv1.StatefulSet, defaultValue bool) (flag bool) {
|
func (c *Cluster) getRollingUpdateFlagFromStatefulSet(sset *appsv1.StatefulSet, defaultValue bool) (flag bool) {
|
||||||
|
|
@ -192,6 +196,7 @@ func (c *Cluster) getRollingUpdateFlagFromStatefulSet(sset *appsv1.StatefulSet,
|
||||||
return flag
|
return flag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO mergeRollingUpdateFlagUsingCache(runningPod *v1.Pod) bool {
|
||||||
// mergeRollingUpdateFlagUsingCache returns the value of the rollingUpdate flag from the passed
|
// mergeRollingUpdateFlagUsingCache returns the value of the rollingUpdate flag from the passed
|
||||||
// statefulset, however, the value can be cleared if there is a cached flag in the cluster that
|
// statefulset, however, the value can be cleared if there is a cached flag in the cluster that
|
||||||
// is set to false (the discrepancy could be a result of a failed StatefulSet update)
|
// is set to false (the discrepancy could be a result of a failed StatefulSet update)
|
||||||
|
|
@ -220,6 +225,7 @@ func (c *Cluster) mergeRollingUpdateFlagUsingCache(runningStatefulSet *appsv1.St
|
||||||
return podsRollingUpdateRequired
|
return podsRollingUpdateRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// updatePodAnnotations
|
||||||
func (c *Cluster) updateStatefulSetAnnotations(annotations map[string]string) (*appsv1.StatefulSet, error) {
|
func (c *Cluster) updateStatefulSetAnnotations(annotations map[string]string) (*appsv1.StatefulSet, error) {
|
||||||
c.logger.Debugf("patching statefulset annotations")
|
c.logger.Debugf("patching statefulset annotations")
|
||||||
patchData, err := metaAnnotationsPatch(annotations)
|
patchData, err := metaAnnotationsPatch(annotations)
|
||||||
|
|
@ -237,8 +243,8 @@ func (c *Cluster) updateStatefulSetAnnotations(annotations map[string]string) (*
|
||||||
return nil, fmt.Errorf("could not patch statefulset annotations %q: %v", patchData, err)
|
return nil, fmt.Errorf("could not patch statefulset annotations %q: %v", patchData, err)
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cluster) updateStatefulSet(newStatefulSet *appsv1.StatefulSet) error {
|
func (c *Cluster) updateStatefulSet(newStatefulSet *appsv1.StatefulSet) error {
|
||||||
c.setProcessName("updating statefulset")
|
c.setProcessName("updating statefulset")
|
||||||
if c.Statefulset == nil {
|
if c.Statefulset == nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue