diff --git a/pkg/controller/redis/object_generator.go b/pkg/controller/redis/object_generator.go index 3c7b37b4..c28c10d1 100644 --- a/pkg/controller/redis/object_generator.go +++ b/pkg/controller/redis/object_generator.go @@ -458,7 +458,10 @@ func statefulSetUpdateNeeded(got, want *appsv1.StatefulSet) (needed bool) { needed = true } - if !deepContains(got.Spec.Template, want.Spec.Template) || (got.Annotations[hashAnnotationKey] != want.Annotations[hashAnnotationKey]) { + // compare container resources explicitly. They escape the deepContains comparison because of private fields. + if !deepContains(got.Spec.Template, want.Spec.Template) || + got.Annotations[hashAnnotationKey] != want.Annotations[hashAnnotationKey] || + !resourceRequirementsEqual(got.Spec.Template.Spec.Containers, want.Spec.Template.Spec.Containers) { got.Spec.Template = want.Spec.Template needed = true } @@ -509,3 +512,17 @@ func hashObject(object k8sruntime.Object) (string, error) { return hex.EncodeToString(hash.Sum(nil)), nil } + +func resourceRequirementsEqual(got, want []corev1.Container) bool { + if len(got) < len(want) { + return false + } + + for i := range want { + if !reflect.DeepEqual(got[i].Resources, want[i].Resources) { + return false + } + } + + return true +} diff --git a/pkg/controller/redis/redis_controller.go b/pkg/controller/redis/redis_controller.go index 689f52c4..c3f8bb44 100644 --- a/pkg/controller/redis/redis_controller.go +++ b/pkg/controller/redis/redis_controller.go @@ -191,7 +191,7 @@ func (reconciler *ReconcileRedis) Reconcile(request reconcile.Request) (reconcil if result, err := reconciler.createOrUpdate(ctx, object, redisObject, options); err != nil { return reconcile.Result{}, err } else if result.Requeue { - logger.Info(fmt.Sprintf("Applied %#v", object)) + logger.Info(fmt.Sprintf("Applied %T", object)) return result, nil } }