Skip to content

Commit 1a3a3a7

Browse files
authored
use oldObj as statefulSet inside IgnoreChangesFunction (#286)
* use oldObj as statefulSet inside IgnoreChangesFunction * fix typo
1 parent 06b6f63 commit 1a3a3a7

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Fixed
2+
body: panic when create object with .spec.pause is true
3+
time: 2025-01-27T14:10:03.497565+08:00

internal/controllers/database/sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,8 @@ func (r *Reconciler) waitForStatefulSetToScale(
359359

360360
func shouldIgnoreDatabaseChange(database *resources.DatabaseBuilder) resources.IgnoreChangesFunction {
361361
return func(oldObj, newObj runtime.Object) bool {
362-
if _, ok := newObj.(*appsv1.StatefulSet); ok {
363-
if database.Spec.Pause && *oldObj.(*appsv1.StatefulSet).Spec.Replicas == 0 {
362+
if statefulSet, ok := oldObj.(*appsv1.StatefulSet); ok {
363+
if database.Spec.Pause && *statefulSet.Spec.Replicas == 0 {
364364
return true
365365
}
366366
}

internal/controllers/storage/sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ func (r *Reconciler) waitForNodeSetsToProvisioned(
292292

293293
func shouldIgnoreStorageChange(storage *resources.StorageClusterBuilder) resources.IgnoreChangesFunction {
294294
return func(oldObj, newObj runtime.Object) bool {
295-
if _, ok := newObj.(*appsv1.StatefulSet); ok {
296-
if storage.Spec.Pause && *oldObj.(*appsv1.StatefulSet).Spec.Replicas == 0 {
295+
if statefulSet, ok := oldObj.(*appsv1.StatefulSet); ok {
296+
if storage.Spec.Pause && *statefulSet.Spec.Replicas == 0 {
297297
return true
298298
}
299299
}

0 commit comments

Comments
 (0)