Skip to content

Commit

Permalink
complete rollback function when upgrade failed
Browse files Browse the repository at this point in the history
Signed-off-by: hxcGit <houxc_mail@163.com>
  • Loading branch information
xavier-hou committed Apr 13, 2023
1 parent 87e0e47 commit 6346766
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/node-servant/static-pod-upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ func (ctrl *Controller) AutoUpgrade() error {
// (3) Verify the new static pod is running
ok, err := ctrl.verify()
if err != nil {
if err := ctrl.rollbackManifest(); err != nil {
klog.Errorf("Fail to rollback manifest when upgrade failed, %v", err)
}
return err
}
if !ok {
Expand Down
3 changes: 1 addition & 2 deletions pkg/node-servant/static-pod-upgrade/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func WaitForPodRunning(namespace, name, hash string, timeout time.Duration) (boo
select {
case <-ctx.Done():
return false, fmt.Errorf("timeout waiting for static pod %s/%s to be running", namespace, name)
default:
case <-ticker.C:
pod, err := GetPodFromYurtHub(namespace, name)
if err != nil {
klog.V(4).Infof("Temporarily fail to get pod from YurtHub, %v", err)
Expand All @@ -108,6 +108,5 @@ func WaitForPodRunning(namespace, name, hash string, timeout time.Duration) (boo
}
}
}
<-ticker.C
}
}

0 comments on commit 6346766

Please sign in to comment.