Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/controller/batchrelease/control/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package control

import "k8s.io/apimachinery/pkg/util/intstr"

// OriginalDeploymentStrategy stores part of the fileds of a workload,
// OriginalDeploymentStrategy stores part of the fields of a workload,
// so that it can be restored when finalizing.
// It is only used for BlueGreen Release
// Similar to DeploymentStrategy, it is an annotation used in workload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/klog/v2"
utilpointer "k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/openkruise/rollouts/api/v1beta1"
Expand Down Expand Up @@ -109,6 +110,7 @@ func (rc *realController) Initialize(release *v1beta1.BatchRelease) error {
patchData.UpdateMaxSurge(&maxSurge)
patchData.UpdateMaxUnavailable(&maxUnavailable)
patchData.UpdateMinReadySeconds(v1beta1.MaxReadySeconds)
patchData.UpdateProgressDeadlineSeconds(utilpointer.Int32(v1beta1.MaxProgressSeconds))
klog.InfoS("Initialize: try to update cloneset", "cloneset", klog.KObj(rc.object), "patchData", patchData.String())
return rc.client.Patch(context.TODO(), util.GetEmptyObjectWithKey(rc.object), patchData)
}
Expand Down Expand Up @@ -153,6 +155,7 @@ func (rc *realController) Finalize(release *v1beta1.BatchRelease) error {
}
patchData := patch.NewClonesetPatch()
patchData.UpdateMinReadySeconds(setting.MinReadySeconds)
patchData.UpdateProgressDeadlineSeconds(setting.ProgressDeadlineSeconds)
patchData.UpdateMaxSurge(setting.MaxSurge)
patchData.UpdateMaxUnavailable(setting.MaxUnavailable)
patchData.DeleteAnnotation(v1beta1.OriginalDeploymentStrategyAnnotation)
Expand Down
6 changes: 4 additions & 2 deletions pkg/controller/batchrelease/control/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@
return fmt.Errorf("cloneSet strategy type is not ReCreate")
}
// MinReadySeconds and ProgressDeadlineSeconds must be set
if o.Spec.MinReadySeconds != v1beta1.MaxReadySeconds {
return fmt.Errorf("cloneSet strategy minReadySeconds is not MaxReadySeconds")
if o.Spec.MinReadySeconds != v1beta1.MaxReadySeconds || o.Spec.ProgressDeadlineSeconds == nil || *o.Spec.ProgressDeadlineSeconds != v1beta1.MaxProgressSeconds {

Check failure on line 95 in pkg/controller/batchrelease/control/util.go

View workflow job for this annotation

GitHub Actions / golangci-lint

o.Spec.ProgressDeadlineSeconds undefined (type "github.com/openkruise/kruise-api/apps/v1alpha1".CloneSetSpec has no field or method ProgressDeadlineSeconds)

Check failure on line 95 in pkg/controller/batchrelease/control/util.go

View workflow job for this annotation

GitHub Actions / golangci-lint

o.Spec.ProgressDeadlineSeconds undefined (type "github.com/openkruise/kruise-api/apps/v1alpha1".CloneSetSpec has no field or method ProgressDeadlineSeconds)

Check failure on line 95 in pkg/controller/batchrelease/control/util.go

View workflow job for this annotation

GitHub Actions / golangci-lint

o.Spec.ProgressDeadlineSeconds undefined (type "github.com/openkruise/kruise-api/apps/v1alpha1".CloneSetSpec has no field or method ProgressDeadlineSeconds)

Check failure on line 95 in pkg/controller/batchrelease/control/util.go

View workflow job for this annotation

GitHub Actions / golangci-lint

o.Spec.ProgressDeadlineSeconds undefined (type "github.com/openkruise/kruise-api/apps/v1alpha1".CloneSetSpec has no field or method ProgressDeadlineSeconds)

Check failure on line 95 in pkg/controller/batchrelease/control/util.go

View workflow job for this annotation

GitHub Actions / unit-tests

o.Spec.ProgressDeadlineSeconds undefined (type "github.com/openkruise/kruise-api/apps/v1alpha1".CloneSetSpec has no field or method ProgressDeadlineSeconds)
return fmt.Errorf("cloneSet strategy minReadySeconds or progressDeadlineSeconds is not MaxReadySeconds or MaxProgressSeconds")
}

default:
Expand Down Expand Up @@ -198,6 +198,8 @@
}
if setting.ProgressDeadlineSeconds == nil {
// cloneset is planned to support progressDeadlineSeconds field
setting.ProgressDeadlineSeconds = getIntPtrOrDefault(o.Spec.ProgressDeadlineSeconds, 600)

Check failure on line 201 in pkg/controller/batchrelease/control/util.go

View workflow job for this annotation

GitHub Actions / golangci-lint

o.Spec.ProgressDeadlineSeconds undefined (type "github.com/openkruise/kruise-api/apps/v1alpha1".CloneSetSpec has no field or method ProgressDeadlineSeconds)) (typecheck)

Check failure on line 201 in pkg/controller/batchrelease/control/util.go

View workflow job for this annotation

GitHub Actions / golangci-lint

o.Spec.ProgressDeadlineSeconds undefined (type "github.com/openkruise/kruise-api/apps/v1alpha1".CloneSetSpec has no field or method ProgressDeadlineSeconds)) (typecheck)

Check failure on line 201 in pkg/controller/batchrelease/control/util.go

View workflow job for this annotation

GitHub Actions / golangci-lint

o.Spec.ProgressDeadlineSeconds undefined (type "github.com/openkruise/kruise-api/apps/v1alpha1".CloneSetSpec has no field or method ProgressDeadlineSeconds) (typecheck)

Check failure on line 201 in pkg/controller/batchrelease/control/util.go

View workflow job for this annotation

GitHub Actions / unit-tests

o.Spec.ProgressDeadlineSeconds undefined (type "github.com/openkruise/kruise-api/apps/v1alpha1".CloneSetSpec has no field or method ProgressDeadlineSeconds)
changeLogs = append(changeLogs, fmt.Sprintf("progressDeadlineSeconds changed from nil to %d", *setting.ProgressDeadlineSeconds))
}
if setting.MinReadySeconds == 0 {
setting.MinReadySeconds = o.Spec.MinReadySeconds
Expand Down
12 changes: 12 additions & 0 deletions pkg/util/patch/patch_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,18 @@ func (s *ClonesetPatch) UpdateMinReadySeconds(seconds int32) *ClonesetPatch {
return s
}

func (s *ClonesetPatch) UpdateProgressDeadlineSeconds(seconds *int32) *ClonesetPatch {
switch s.PatchType {
case types.StrategicMergePatchType, types.MergePatchType:
if _, ok := s.PatchData["spec"]; !ok {
s.PatchData["spec"] = make(map[string]interface{})
}
spec := s.PatchData["spec"].(map[string]interface{})
spec["progressDeadlineSeconds"] = seconds
}
return s
}

func (s *ClonesetPatch) UpdatePaused(paused bool) *ClonesetPatch {
switch s.PatchType {
case types.StrategicMergePatchType, types.MergePatchType:
Expand Down
Loading