[Backport release-1.6] Feat: rollout support statefulsets (#5203)

* rollout support workload

Signed-off-by: suwanliang_yewu <suwanliang_yewu@cmss.chinamobile.com>
(cherry picked from commit ab36f3b7c3)

* modify the error output

Signed-off-by: suwanliang_yewu <suwanliang_yewu@cmss.chinamobile.com>
(cherry picked from commit 1ed43cc282)

Co-authored-by: suwanliang_yewu <suwanliang_yewu@cmss.chinamobile.com>
This commit is contained in:
github-actions[bot]
2022-12-19 12:10:08 +08:00
committed by GitHub
co-authored by suwanliang_yewu
parent 18639ccbae
commit 5085a99a12
2 changed files with 4 additions and 0 deletions
@@ -114,6 +114,7 @@ func HandleReplicas(ctx context.Context, rolloutComp string, c client.Client) as
klog.InfoS("assemble force set workload replicas to 0", "Kind", u.GetKind(), "name", u.GetName())
return nil
}
klog.Errorf("fail to get workload %s: %v", u.GetName(), err)
return err
}
// the workload already exist, we cannot reset the replicas with manifest
@@ -122,6 +123,7 @@ func HandleReplicas(ctx context.Context, rolloutComp string, c client.Client) as
wlpv := fieldpath.Pave(workload.UnstructuredContent())
replicas, err := wlpv.GetInteger(replicasFieldPath)
if err != nil {
klog.Errorf("fail to get `spec.replicas` field from workload %s: %v", u.GetName(), err)
return err
}
if err = pv.SetNumber(replicasFieldPath, float64(replicas)); err != nil {
@@ -49,6 +49,8 @@ rules:
- apiGroups:
- "apps"
resources:
- statefulsets
- statefulsets/status
- deployments
- deployments/status
- controllerrevisions