Do rolling update after creating of a statefulset if pods were present. (#110)
Make sure we always re-create pods if we had to create the statefulset, even if the pods from the old statefulset were already there.
This commit is contained in:
parent
49cb395aed
commit
9f9a89185f
|
|
@ -96,8 +96,18 @@ func (c *Cluster) syncEndpoint() error {
|
|||
|
||||
func (c *Cluster) syncStatefulSet() error {
|
||||
cSpec := c.Spec
|
||||
var rollUpdate bool
|
||||
if c.Statefulset == nil {
|
||||
c.logger.Infof("Can't find the cluster's StatefulSet")
|
||||
pods, err := c.listPods()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Can't list pods of the StatefulSet: %s", err)
|
||||
}
|
||||
|
||||
if len(pods) > 0 {
|
||||
c.logger.Infof("Found pods without the statefulset: trigger rolling update")
|
||||
rollUpdate = true
|
||||
}
|
||||
ss, err := c.createStatefulSet()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Can't create missing StatefulSet: %s", err)
|
||||
|
|
@ -107,11 +117,17 @@ func (c *Cluster) syncStatefulSet() error {
|
|||
return fmt.Errorf("Cluster is not ready: %s", err)
|
||||
}
|
||||
c.logger.Infof("Created missing StatefulSet '%s'", util.NameFromMeta(ss.ObjectMeta))
|
||||
if !rollUpdate {
|
||||
return nil
|
||||
}
|
||||
|
||||
}
|
||||
if !rollUpdate {
|
||||
var (
|
||||
match bool
|
||||
reason string
|
||||
)
|
||||
desiredSS := c.genStatefulSet(cSpec)
|
||||
match, rollUpdate, reason := c.compareStatefulSetWith(desiredSS)
|
||||
match, rollUpdate, reason = c.compareStatefulSetWith(desiredSS)
|
||||
if match {
|
||||
return nil
|
||||
}
|
||||
|
|
@ -125,6 +141,7 @@ func (c *Cluster) syncStatefulSet() error {
|
|||
c.logger.Debugln("No rolling update is needed")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
c.logger.Debugln("Performing rolling update")
|
||||
if err := c.recreatePods(); err != nil {
|
||||
return fmt.Errorf("Can't recreate Pods: %s", err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue