Skip to content

Commit

Permalink
fix: fix can not clean sts when rs is nil
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Sep 1, 2023
1 parent bc4409f commit 3ca36da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion controllers/apps/v2beta1/sync_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s *syncSets) reconcile(ctx context.Context, instance *appsv2beta1.EMQX, r
_, _, oldStsList := getStateFulSetList(ctx, s.Client, instance)
stsDiff := int32(len(oldStsList)) - *instance.Spec.RevisionHistoryLimit
if stsDiff > 0 {
for i := 0; i < int(rsDiff); i++ {
for i := 0; i < int(stsDiff); i++ {
sts := oldStsList[i].DeepCopy()
// Avoid delete stateful set with non-zero replica counts
if sts.Status.Replicas != 0 || *(sts.Spec.Replicas) != 0 || sts.Generation > sts.Status.ObservedGeneration || sts.DeletionTimestamp != nil {
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/v2beta1/sync_sets_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

var _ = Describe("Check sync rs", func() {
var _ = Describe("Check sync sts and pvc", func() {
var s *syncSets

var instance *appsv2beta1.EMQX = new(appsv2beta1.EMQX)
Expand Down

0 comments on commit 3ca36da

Please sign in to comment.