diff --git a/controllers/function.go b/controllers/function.go index 5fbec9a3..bc1e15c7 100644 --- a/controllers/function.go +++ b/controllers/function.go @@ -429,7 +429,7 @@ func (r *FunctionReconciler) checkIfStatefulSetNeedUpdate(ctx context.Context, s if err != nil { return false, err } - diff, err := spec.CreateDiff(statefulSet, desiredStatefulSet) + diff, err := spec.CreateDiff(statefulSet.Spec, desiredStatefulSet.Spec) if err != nil { return false, err } diff --git a/controllers/sink.go b/controllers/sink.go index 625be8a9..c00118ea 100644 --- a/controllers/sink.go +++ b/controllers/sink.go @@ -425,7 +425,7 @@ func (r *SinkReconciler) checkIfStatefulSetNeedUpdate(ctx context.Context, state if err != nil { return false, err } - diff, err := spec.CreateDiff(statefulSet, desiredStatefulSet) + diff, err := spec.CreateDiff(statefulSet.Spec, desiredStatefulSet.Spec) if err != nil { return false, err } diff --git a/controllers/source.go b/controllers/source.go index 921c8666..3ee64510 100644 --- a/controllers/source.go +++ b/controllers/source.go @@ -427,7 +427,7 @@ func (r *SourceReconciler) checkIfStatefulSetNeedUpdate(ctx context.Context, sta if err != nil { return false, err } - diff, err := spec.CreateDiff(statefulSet, desiredStatefulSet) + diff, err := spec.CreateDiff(statefulSet.Spec, desiredStatefulSet.Spec) if err != nil { return false, err } diff --git a/controllers/spec/common.go b/controllers/spec/common.go index af3cef77..57438e4e 100644 --- a/controllers/spec/common.go +++ b/controllers/spec/common.go @@ -40,7 +40,6 @@ import ( corev1 "k8s.io/api/core/v1" k8serrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/strategicpatch" @@ -2377,15 +2376,18 @@ func makeFilebeatContainer(volumeMounts []corev1.VolumeMount, envVar []corev1.En } } -func CreateDiff(orj, modified runtime.Object) (string, error) { - orjCopy := orj.DeepCopyObject() - modifiedCopy := modified.DeepCopyObject() - - orjData, err := json.Marshal(orjCopy) +func CreateDiff(orj, modified appsv1.StatefulSetSpec) (string, error) { + // remove auto generated fields + for i, i2 := range orj.Template.Spec.Containers { + i2.TerminationMessagePolicy = "" + i2.TerminationMessagePath = "" + orj.Template.Spec.Containers[i] = i2 + } + orjData, err := json.Marshal(orj) if err != nil { return "", fmt.Errorf("marshal origin %w", err) } - modifiedData, err := json.Marshal(modifiedCopy) + modifiedData, err := json.Marshal(modified) if err != nil { return "", fmt.Errorf("marshal modified %w", err) }