Skip to content

Commit

Permalink
Fix condition error of ManifestApplied.
Browse files Browse the repository at this point in the history
Signed-off-by: xuezhaojun <[email protected]>
  • Loading branch information
xuezhaojun committed Jun 3, 2024
1 parent e24923d commit 9516078
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 8 additions & 9 deletions pkg/addonmanager/controllers/agentdeploy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,6 @@ func (c *addonDeployController) buildDeployManifestWorksFunc(addonWorkBuilder *a
})
return nil, nil, err
}
if len(objects) == 0 {
meta.SetStatusCondition(&addon.Status.Conditions, metav1.Condition{
Type: appliedType,
Status: metav1.ConditionTrue,
Reason: addonapiv1alpha1.AddonManifestAppliedReasonManifestsApplied,
Message: "no manifest need to apply",
})
return nil, nil, nil
}

// this is to retrieve the intended mode of the addon.
var mode string
Expand All @@ -425,6 +416,14 @@ func (c *addonDeployController) buildDeployManifestWorksFunc(addonWorkBuilder *a
})
return nil, nil, err
}
if len(appliedWorks) == 0 {
meta.SetStatusCondition(&addon.Status.Conditions, metav1.Condition{
Type: appliedType,
Status: metav1.ConditionTrue,
Reason: addonapiv1alpha1.AddonManifestAppliedReasonManifestsApplied,
Message: "no manifest need to apply",
})
}
return appliedWorks, deleteWorks, nil
}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/addonmanager/controllers/agentdeploy/hosted_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ func TestHostingReconcile(t *testing.T) {
if meta.IsStatusConditionFalse(addOn.Status.Conditions, addonapiv1alpha1.ManagedClusterAddOnHostingManifestApplied) {
t.Errorf("Condition Reason is not correct: %v", addOn.Status.Conditions)
}
if meta.IsStatusConditionFalse(addOn.Status.Conditions, addonapiv1alpha1.ManagedClusterAddOnManifestApplied) {
t.Errorf("Condition Reason is not correct: %v", addOn.Status.Conditions)
}
},
},
{
Expand Down

0 comments on commit 9516078

Please sign in to comment.