Skip to content

Commit

Permalink
update mca progressing condition when desired and last applied matches (
Browse files Browse the repository at this point in the history
#513)

Signed-off-by: haoqing0110 <[email protected]>
  • Loading branch information
haoqing0110 authored Jun 13, 2024
1 parent 287a6fb commit 462992f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
18 changes: 5 additions & 13 deletions pkg/addon/controllers/addonprogressing/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,20 +283,12 @@ func workIsReady(work *workapiv1.ManifestWork) bool {
return true
}

// set addon progressing condition and last applied
// Set addon progressing condition and last applied
// Once completed, the LastAppliedConfig will set to DesiredConfig. Even the condition status
// changes later, eg, spoke cluster becomes unhealthy, status becomes progressing or failed after completed,
// the LastAppliedConfig and DesiredConfig won't change. this is to avoid back and forth in rollout.
// The setRolloutStatus() func in graph.go only look at the LastAppliedConfig and DesiredConfig.
func setAddOnProgressingAndLastApplied(reason string, message string, addon *addonapiv1alpha1.ManagedClusterAddOn) {
// always update progressing condition when there is no config
// skip update progressing condition when last applied config already the same as desired
skip := len(addon.Status.ConfigReferences) > 0
for _, configReference := range addon.Status.ConfigReferences {
if !equality.Semantic.DeepEqual(configReference.LastAppliedConfig, configReference.DesiredConfig) {
skip = false
}
}
if skip {
return
}

condition := metav1.Condition{
Type: addonapiv1alpha1.ManagedClusterAddOnConditionProgressing,
Reason: reason,
Expand Down
10 changes: 8 additions & 2 deletions test/integration/addon/addon_manager_upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ var _ = ginkgo.Describe("Addon upgrade", func() {
})

ginkgo.By("update work status to avoid addon status update")
for i := 0; i < 4; i++ {
for i := 0; i < 2; i++ {
updateManifestWorkStatus(hubWorkClient, clusterNames[i], manifestWorkName, metav1.ConditionFalse)
}

Expand Down Expand Up @@ -503,6 +503,9 @@ var _ = ginkgo.Describe("Addon upgrade", func() {
for i := 0; i < 2; i++ {
updateManifestWorkStatus(hubWorkClient, clusterNames[i], manifestWorkName, metav1.ConditionTrue)
}
for i := 3; i < 4; i++ {
updateManifestWorkStatus(hubWorkClient, clusterNames[i], manifestWorkName, metav1.ConditionFalse)
}

ginkgo.By("check mca status")
for i := 0; i < 2; i++ {
Expand Down Expand Up @@ -627,7 +630,7 @@ var _ = ginkgo.Describe("Addon upgrade", func() {
})

ginkgo.By("update work status to avoid addon status update")
for i := 0; i < 4; i++ {
for i := 0; i < 2; i++ {
updateManifestWorkStatus(hubWorkClient, clusterNames[i], manifestWorkName, metav1.ConditionFalse)
}

Expand Down Expand Up @@ -762,6 +765,9 @@ var _ = ginkgo.Describe("Addon upgrade", func() {
for i := 0; i < 2; i++ {
updateManifestWorkStatus(hubWorkClient, clusterNames[i], manifestWorkName, metav1.ConditionTrue)
}
for i := 2; i < 4; i++ {
updateManifestWorkStatus(hubWorkClient, clusterNames[i], manifestWorkName, metav1.ConditionFalse)
}
assertClusterManagementAddOnNoConditions(testAddOnConfigsImpl.name, start, 3*time.Second, metav1.Condition{
Type: addonapiv1alpha1.ManagedClusterAddOnConditionProgressing,
Status: metav1.ConditionTrue,
Expand Down

0 comments on commit 462992f

Please sign in to comment.