From 72ba863e10e69bc5891948376b115dd7cee49d66 Mon Sep 17 00:00:00 2001 From: jiangpengcheng Date: Sat, 14 Sep 2024 09:53:17 +0800 Subject: [PATCH] Update diff --- .../cases/java-download-function/manifests.yaml | 2 ++ .../cases/java-function-vpa/manifests.yaml | 2 ++ .../integration/cases/java-function/manifests.yaml | 2 ++ .../integration/cases/java-log-config/manifests.yaml | 2 ++ .../cases/java-log-format-json/manifests.yaml | 2 ++ controllers/spec/common.go | 11 ++++++----- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.ci/tests/integration/cases/java-download-function/manifests.yaml b/.ci/tests/integration/cases/java-download-function/manifests.yaml index e6eb76dc..4763bae5 100644 --- a/.ci/tests/integration/cases/java-download-function/manifests.yaml +++ b/.ci/tests/integration/cases/java-download-function/manifests.yaml @@ -1,6 +1,8 @@ apiVersion: compute.functionmesh.io/v1alpha1 kind: Function metadata: + annotations: + compute.functionmesh.io/pause-rollout: "false" name: function-download-sample namespace: default spec: diff --git a/.ci/tests/integration/cases/java-function-vpa/manifests.yaml b/.ci/tests/integration/cases/java-function-vpa/manifests.yaml index 219ae545..a5e4a79e 100644 --- a/.ci/tests/integration/cases/java-function-vpa/manifests.yaml +++ b/.ci/tests/integration/cases/java-function-vpa/manifests.yaml @@ -1,6 +1,8 @@ apiVersion: compute.functionmesh.io/v1alpha1 kind: Function metadata: + annotations: + compute.functionmesh.io/pause-rollout: "true" name: function-sample-vpa namespace: default spec: diff --git a/.ci/tests/integration/cases/java-function/manifests.yaml b/.ci/tests/integration/cases/java-function/manifests.yaml index d2b7391d..e7effe14 100644 --- a/.ci/tests/integration/cases/java-function/manifests.yaml +++ b/.ci/tests/integration/cases/java-function/manifests.yaml @@ -1,6 +1,8 @@ apiVersion: compute.functionmesh.io/v1alpha1 kind: Function metadata: + annotations: + compute.functionmesh.io/pause-rollout: "true" name: function-sample namespace: default spec: diff --git a/.ci/tests/integration/cases/java-log-config/manifests.yaml b/.ci/tests/integration/cases/java-log-config/manifests.yaml index 1e0c2fb9..5df73fbc 100644 --- a/.ci/tests/integration/cases/java-log-config/manifests.yaml +++ b/.ci/tests/integration/cases/java-log-config/manifests.yaml @@ -1,6 +1,8 @@ apiVersion: compute.functionmesh.io/v1alpha1 kind: Function metadata: + annotations: + compute.functionmesh.io/pause-rollout: "true" name: java-log-config namespace: default spec: diff --git a/.ci/tests/integration/cases/java-log-format-json/manifests.yaml b/.ci/tests/integration/cases/java-log-format-json/manifests.yaml index 6b9cbab1..989fb977 100644 --- a/.ci/tests/integration/cases/java-log-format-json/manifests.yaml +++ b/.ci/tests/integration/cases/java-log-format-json/manifests.yaml @@ -1,6 +1,8 @@ apiVersion: compute.functionmesh.io/v1alpha1 kind: Function metadata: + annotations: + compute.functionmesh.io/pause-rollout: "false" name: java-log-format-json namespace: default spec: diff --git a/controllers/spec/common.go b/controllers/spec/common.go index af3cef77..6af3dca5 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,9 +2376,11 @@ func makeFilebeatContainer(volumeMounts []corev1.VolumeMount, envVar []corev1.En } } -func CreateDiff(orj, modified runtime.Object) (string, error) { - orjCopy := orj.DeepCopyObject() - modifiedCopy := modified.DeepCopyObject() +func CreateDiff(orj, modified *appsv1.StatefulSet) (string, error) { + orjCopy := orj.DeepCopyObject().(*appsv1.StatefulSet) + modifiedCopy := modified.DeepCopyObject().(*appsv1.StatefulSet) + modifiedCopy.Status = orjCopy.Status + modifiedCopy.ObjectMeta = orjCopy.ObjectMeta orjData, err := json.Marshal(orjCopy) if err != nil { @@ -2389,7 +2390,7 @@ func CreateDiff(orj, modified runtime.Object) (string, error) { if err != nil { return "", fmt.Errorf("marshal modified %w", err) } - patch, err := strategicpatch.CreateTwoWayMergePatch(orjData, modifiedData, orj) + patch, err := strategicpatch.CreateTwoWayMergePatch(orjData, modifiedData, orjCopy) if err != nil { return "", fmt.Errorf("create diff %w", err) }