From 9676b4f8c180fc3ac415db7e648ec4c2e467cd0e Mon Sep 17 00:00:00 2001 From: Jian Zhu Date: Mon, 11 Sep 2023 22:08:13 +0800 Subject: [PATCH] skip comparing the spec hash for addon deployment config (#207) Signed-off-by: zhujian --- pkg/utils/addon_config.go | 9 +++++ pkg/utils/addon_config_test.go | 70 +++++++++++++++++----------------- 2 files changed, 44 insertions(+), 35 deletions(-) diff --git a/pkg/utils/addon_config.go b/pkg/utils/addon_config.go index e1de216f0..ecdb98ad0 100644 --- a/pkg/utils/addon_config.go +++ b/pkg/utils/addon_config.go @@ -81,6 +81,14 @@ func GetDesiredAddOnDeploymentConfig( return nil, err } + /* If the addonDeploymentConfig.spec.proxy field is not set, the spec hash in managedclusteraddon status will be + // different from the spec hash calculated here. This is because the spec hash in managedclusteraddon status is + // calculated by getting the addon deployment config object using a dynamic client, which will not contain + // addonDeploymentConfig.spec.proxy field if it is not set. However, the spec hash of the addonDeploymentConfig here + // is calculated by getting the addon deployment config object using a typed client, which will contain + // addonDeploymentConfig.spec.proxy field even if it is not set. + // TODO: uncomment the comparison after the above issue is fixed + specHash, err := GetAddOnDeploymentConfigSpecHash(adc) if err != nil { return nil, err @@ -89,6 +97,7 @@ func GetDesiredAddOnDeploymentConfig( return nil, fmt.Errorf("addon %s deployment config spec hash %s is not equal to desired spec hash %s", addon.Name, specHash, desiredConfig.SpecHash) } + */ return adc.DeepCopy(), nil } diff --git a/pkg/utils/addon_config_test.go b/pkg/utils/addon_config_test.go index 1fb2420d1..160cf061a 100644 --- a/pkg/utils/addon_config_test.go +++ b/pkg/utils/addon_config_test.go @@ -93,41 +93,41 @@ func TestAgentInstallNamespaceFromDeploymentConfigFunc(t *testing.T) { }, expected: "", }, - { - name: "addon deployment config reference spec hash not match", - getter: newTestAddOnDeploymentConfigGetter( - &addonapiv1alpha1.AddOnDeploymentConfig{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test1", - }, - Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{ - AgentInstallNamespace: "testns", - }, - }), - mca: &addonapiv1alpha1.ManagedClusterAddOn{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test1", - Namespace: "cluster1", - }, - Status: addonapiv1alpha1.ManagedClusterAddOnStatus{ - ConfigReferences: []addonapiv1alpha1.ConfigReference{ - { - ConfigGroupResource: addonapiv1alpha1.ConfigGroupResource{ - Group: "addon.open-cluster-management.io", - Resource: "addondeploymentconfigs", - }, - ConfigReferent: addonapiv1alpha1.ConfigReferent{ - Name: "test1", - }, - DesiredConfig: &addonapiv1alpha1.ConfigSpecHash{ - SpecHash: "wronghash", - }, - }, - }, - }, - }, - expected: "", - }, + // { + // name: "addon deployment config reference spec hash not match", + // getter: newTestAddOnDeploymentConfigGetter( + // &addonapiv1alpha1.AddOnDeploymentConfig{ + // ObjectMeta: metav1.ObjectMeta{ + // Name: "test1", + // }, + // Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{ + // AgentInstallNamespace: "testns", + // }, + // }), + // mca: &addonapiv1alpha1.ManagedClusterAddOn{ + // ObjectMeta: metav1.ObjectMeta{ + // Name: "test1", + // Namespace: "cluster1", + // }, + // Status: addonapiv1alpha1.ManagedClusterAddOnStatus{ + // ConfigReferences: []addonapiv1alpha1.ConfigReference{ + // { + // ConfigGroupResource: addonapiv1alpha1.ConfigGroupResource{ + // Group: "addon.open-cluster-management.io", + // Resource: "addondeploymentconfigs", + // }, + // ConfigReferent: addonapiv1alpha1.ConfigReferent{ + // Name: "test1", + // }, + // DesiredConfig: &addonapiv1alpha1.ConfigSpecHash{ + // SpecHash: "wronghash", + // }, + // }, + // }, + // }, + // }, + // expected: "", + // }, { name: "addon deployment config reference spec hash match", getter: newTestAddOnDeploymentConfigGetter(