Skip to content

Commit

Permalink
skip comparing the spec hash for addon deployment config (#207)
Browse files Browse the repository at this point in the history
Signed-off-by: zhujian <jiazhu@redhat.com>
  • Loading branch information
zhujian7 authored Sep 11, 2023
1 parent 5497e73 commit 9676b4f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 35 deletions.
9 changes: 9 additions & 0 deletions pkg/utils/addon_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down
70 changes: 35 additions & 35 deletions pkg/utils/addon_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 9676b4f

Please sign in to comment.