mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #14671 from ironcladlou/rolling-rollback-fix
Auto commit by PR queue bot
This commit is contained in:
commit
888f08377e
@ -296,7 +296,10 @@ func RunRollingUpdate(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, arg
|
|||||||
MaxSurge: util.NewIntOrStringFromInt(1),
|
MaxSurge: util.NewIntOrStringFromInt(1),
|
||||||
}
|
}
|
||||||
if cmdutil.GetFlagBool(cmd, "rollback") {
|
if cmdutil.GetFlagBool(cmd, "rollback") {
|
||||||
kubectl.AbortRollingUpdate(config)
|
err = kubectl.AbortRollingUpdate(config)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
client.ReplicationControllers(config.NewRc.Namespace).Update(config.NewRc)
|
client.ReplicationControllers(config.NewRc.Namespace).Update(config.NewRc)
|
||||||
}
|
}
|
||||||
err = updater.Update(config)
|
err = updater.Update(config)
|
||||||
|
@ -564,7 +564,7 @@ func CreateNewControllerFromCurrentController(c *client.Client, namespace, oldNa
|
|||||||
return newRc, nil
|
return newRc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AbortRollingUpdate(c *RollingUpdaterConfig) {
|
func AbortRollingUpdate(c *RollingUpdaterConfig) error {
|
||||||
// Swap the controllers
|
// Swap the controllers
|
||||||
tmp := c.OldRc
|
tmp := c.OldRc
|
||||||
c.OldRc = c.NewRc
|
c.OldRc = c.NewRc
|
||||||
@ -574,12 +574,18 @@ func AbortRollingUpdate(c *RollingUpdaterConfig) {
|
|||||||
c.NewRc.Annotations = map[string]string{}
|
c.NewRc.Annotations = map[string]string{}
|
||||||
}
|
}
|
||||||
c.NewRc.Annotations[sourceIdAnnotation] = fmt.Sprintf("%s:%s", c.OldRc.Name, c.OldRc.UID)
|
c.NewRc.Annotations[sourceIdAnnotation] = fmt.Sprintf("%s:%s", c.OldRc.Name, c.OldRc.UID)
|
||||||
desiredSize, found := c.OldRc.Annotations[desiredReplicasAnnotation]
|
|
||||||
if found {
|
// Use the original value since the replica count change from old to new
|
||||||
fmt.Printf("Found desired replicas.")
|
// could be asymmetric. If we don't know the original count, we can't safely
|
||||||
c.NewRc.Annotations[desiredReplicasAnnotation] = desiredSize
|
// roll back to a known good size.
|
||||||
|
originalSize, foundOriginal := tmp.Annotations[originalReplicasAnnotation]
|
||||||
|
if !foundOriginal {
|
||||||
|
return fmt.Errorf("couldn't find original replica count of %q", tmp.Name)
|
||||||
}
|
}
|
||||||
|
fmt.Fprintf(c.Out, "Setting %q replicas to %s\n", c.NewRc.Name, originalSize)
|
||||||
|
c.NewRc.Annotations[desiredReplicasAnnotation] = originalSize
|
||||||
c.CleanupPolicy = DeleteRollingUpdateCleanupPolicy
|
c.CleanupPolicy = DeleteRollingUpdateCleanupPolicy
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetNextControllerAnnotation(rc *api.ReplicationController) (string, bool) {
|
func GetNextControllerAnnotation(rc *api.ReplicationController) (string, bool) {
|
||||||
|
Loading…
Reference in New Issue
Block a user