Add support for --rollback.

This commit is contained in:
Brendan Burns
2015-04-30 10:28:36 -07:00
parent b2c0ea37b4
commit c9e33e197d
6 changed files with 43 additions and 8 deletions

View File

@@ -85,6 +85,24 @@ const (
nextControllerAnnotation = kubectlAnnotationPrefix + "next-controller-id"
)
func AbortRollingUpdate(c *RollingUpdaterConfig) {
// Swap the controllers
tmp := c.OldRc
c.OldRc = c.NewRc
c.NewRc = tmp
if c.NewRc.Annotations == nil {
c.NewRc.Annotations = map[string]string{}
}
c.NewRc.Annotations[sourceIdAnnotation] = fmt.Sprintf("%s:%s", c.OldRc.Name, c.OldRc.UID)
desiredSize, found := c.OldRc.Annotations[desiredReplicasAnnotation]
if found {
fmt.Printf("Found desired replicas.")
c.NewRc.Annotations[desiredReplicasAnnotation] = desiredSize
}
c.CleanupPolicy = DeleteRollingUpdateCleanupPolicy
}
func GetNextControllerAnnotation(rc *api.ReplicationController) (string, bool) {
res, found := rc.Annotations[nextControllerAnnotation]
return res, found
@@ -237,7 +255,7 @@ func (r *RollingUpdater) getExistingNewRc(sourceId, name string) (rc *api.Replic
source := annotations[sourceIdAnnotation]
_, ok := annotations[desiredReplicasAnnotation]
if source != sourceId || !ok {
err = fmt.Errorf("Missing/unexpected annotations for controller %s: %s", name, annotations)
err = fmt.Errorf("Missing/unexpected annotations for controller %s, expected %s : %s", name, sourceId, annotations)
}
return
}