Skip to content

Commit c82e122

Browse files
committed
Update interfaces and unit tests for Finalize method
Signed-off-by: GautamBytes <manchandanigautam@gmail.com>
1 parent 505b937 commit c82e122

File tree

14 files changed

+21
-21
lines changed

14 files changed

+21
-21
lines changed

pkg/controller/batchrelease/control/bluegreenstyle/cloneset/control_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ var _ = Describe("CloneSet Control", func() {
244244
Expect(err).NotTo(HaveOccurred())
245245
// call Finalize method
246246
err = retryFunction(3, func() error {
247-
return rc.Finalize(release)
247+
return rc.Finalize(release, false)
248248
})
249249
Expect(err).NotTo(HaveOccurred())
250250

@@ -526,7 +526,7 @@ func TestRealController(t *testing.T) {
526526
MinReadySeconds: 0,
527527
})))
528528

529-
controller.Finalize(release)
529+
controller.Finalize(release, false)
530530
fetch = &kruiseappsv1alpha1.CloneSet{}
531531
Expect(cli.Get(context.TODO(), cloneKey, fetch)).NotTo(HaveOccurred())
532532
Expect(fetch.Spec.UpdateStrategy.MaxSurge.StrVal).Should(Equal("0%"))

pkg/controller/batchrelease/control/bluegreenstyle/control_plane.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ limitations under the License.
1717
package bluegreenstyle
1818

1919
import (
20+
"github.com/openkruise/rollouts/pkg/feature"
21+
utilfeature "github.com/openkruise/rollouts/pkg/util/feature"
2022
"k8s.io/apimachinery/pkg/api/errors"
2123
"k8s.io/apimachinery/pkg/runtime/schema"
2224
"k8s.io/apimachinery/pkg/types"
23-
"github.com/openkruise/rollouts/pkg/feature"
2425
"k8s.io/client-go/tools/record"
2526
"k8s.io/klog/v2"
26-
utilfeature "github.com/openkruise/rollouts/pkg/util/feature"
2727
"sigs.k8s.io/controller-runtime/pkg/client"
2828

2929
"github.com/openkruise/rollouts/api/v1beta1"

pkg/controller/batchrelease/control/bluegreenstyle/deployment/control_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ var _ = Describe("Deployment Control", func() {
311311
Expect(err).NotTo(HaveOccurred())
312312
// call Finalize method
313313
err = retryFunction(3, func() error {
314-
return rc.Finalize(release)
314+
return rc.Finalize(release, false)
315315
})
316316
Expect(err).NotTo(HaveOccurred())
317317

@@ -612,7 +612,7 @@ func TestRealController(t *testing.T) {
612612
Expect(reflect.DeepEqual(fetch.Spec.Strategy.RollingUpdate.MaxSurge, &intstr.IntOrString{Type: intstr.String, StrVal: "50%"})).Should(BeTrue())
613613

614614
release.Spec.ReleasePlan.BatchPartition = nil
615-
err = controller.Finalize(release)
615+
err = controller.Finalize(release, false)
616616
Expect(errors.IsRetryError(err)).Should(BeTrue())
617617
fetch = &apps.Deployment{}
618618
Expect(cli.Get(context.TODO(), deploymentKey, fetch)).NotTo(HaveOccurred())

pkg/controller/batchrelease/control/bluegreenstyle/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ type Interface interface {
4545
UpgradeBatch(ctx *batchcontext.BatchContext) error
4646
// Finalize do something after rolling out, for example:
4747
// - set pause to false, restore the original setting, delete annotation
48-
Finalize(release *v1beta1.BatchRelease) error
48+
Finalize(release *v1beta1.BatchRelease, keepPaused bool) error
4949
}

pkg/controller/batchrelease/control/canarystyle/control_plane.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import (
2727

2828
"github.com/openkruise/rollouts/api/v1beta1"
2929
"github.com/openkruise/rollouts/pkg/controller/batchrelease/control"
30-
"github.com/openkruise/rollouts/pkg/feature"
31-
utilfeature "github.com/openkruise/rollouts/pkg/util/feature"
3230
"github.com/openkruise/rollouts/pkg/controller/batchrelease/labelpatch"
31+
"github.com/openkruise/rollouts/pkg/feature"
3332
"github.com/openkruise/rollouts/pkg/util"
33+
utilfeature "github.com/openkruise/rollouts/pkg/util/feature"
3434
)
3535

3636
// CloneSetRolloutController is responsible for handling rollout CloneSet type of workloads

pkg/controller/batchrelease/control/canarystyle/deployment/control_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func TestRealStableController(t *testing.T) {
252252
Expect(fetch.Annotations[util.BatchReleaseControlAnnotation]).Should(Equal(getControlInfo(release)))
253253
c.stableObject = fetch // mock
254254

255-
err = controller.Finalize(release)
255+
err = controller.Finalize(release, false)
256256
Expect(err).NotTo(HaveOccurred())
257257
fetch = &apps.Deployment{}
258258
Expect(cli.Get(context.TODO(), deploymentKey, fetch)).NotTo(HaveOccurred())

pkg/controller/batchrelease/control/canarystyle/deployment/stable.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ func (rc *realStableController) Finalize(release *v1beta1.BatchRelease, keepPaus
6767
// if batchPartition == nil, workload should be promoted;
6868
pause := release.Spec.ReleasePlan.BatchPartition != nil
6969
body = fmt.Sprintf(`{"metadata":{"annotations":{"%s":null}},"spec":{"paused":%v}}`,
70-
util.BatchReleaseControlAnnotation, pause)
71-
}
70+
util.BatchReleaseControlAnnotation, pause)
71+
}
7272

7373
if err := rc.stableClient.Patch(context.TODO(), d, client.RawPatch(types.StrategicMergePatchType, []byte(body))); err != nil {
7474
return err

pkg/controller/batchrelease/control/canarystyle/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ type StableInterface interface {
5757
// Finalize do something after rolling out, for example:
5858
// - free the stable workload from rollout control;
5959
// - resume stable workload and wait all pods updated if we need.
60-
Finalize(controller *v1beta1.BatchRelease) error
60+
Finalize(controller *v1beta1.BatchRelease, keepPaused bool) error
6161
}

pkg/controller/batchrelease/control/partitionstyle/cloneset/control_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func TestRealController(t *testing.T) {
313313
Expect(cli.Get(context.TODO(), cloneKey, fetch)).NotTo(HaveOccurred())
314314
Expect(fetch.Spec.UpdateStrategy.Partition.StrVal).Should(Equal("90%"))
315315

316-
err = controller.Finalize(release)
316+
err = controller.Finalize(release, false)
317317
Expect(err).NotTo(HaveOccurred())
318318
fetch = &kruiseappsv1alpha1.CloneSet{}
319319
Expect(cli.Get(context.TODO(), cloneKey, fetch)).NotTo(HaveOccurred())

pkg/controller/batchrelease/control/partitionstyle/control_plane.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ import (
3030
"sigs.k8s.io/controller-runtime/pkg/client"
3131

3232
"github.com/openkruise/rollouts/api/v1alpha1"
33-
"github.com/openkruise/rollouts/pkg/feature"
34-
utilfeature "github.com/openkruise/rollouts/pkg/util/feature"
3533
"github.com/openkruise/rollouts/api/v1beta1"
3634
"github.com/openkruise/rollouts/pkg/controller/batchrelease/control"
3735
"github.com/openkruise/rollouts/pkg/controller/batchrelease/labelpatch"
36+
"github.com/openkruise/rollouts/pkg/feature"
3837
"github.com/openkruise/rollouts/pkg/util"
38+
utilfeature "github.com/openkruise/rollouts/pkg/util/feature"
3939
)
4040

4141
type realBatchControlPlane struct {

0 commit comments

Comments
 (0)