Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable work generator to process apply strategy updates + DiffReported condition #1016

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

michaelawyu
Copy link
Contributor

Description of your changes

This PR:

a) fixes the issue where work generator will not refresh apply strategies; and
b) enables work generator to process DiffReported condition

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

  • Unit tests
  • Integration tests

Special notes for your reviewer

E2E tests can only be added when the new work applier is enabled.

@@ -700,15 +703,16 @@ func (r *Reconciler) upsertWork(ctx context.Context, newWork, existingWork *flee
} else {
// we already checked the label in fetchAllResourceSnapShots function so no need to check again
resourceIndex, _ := labels.ExtractResourceIndexFromClusterResourceSnapshot(resourceSnapshot)
if workResourceIndex == resourceIndex {
// no need to do anything if the work is generated from the same resource/override snapshots
if workResourceIndex == resourceIndex && equality.Semantic.DeepEqual(existingWork.Spec.ApplyStrategy, newWork.Spec.ApplyStrategy) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also check applyStrategy in the areAllWorkSynced() function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this is actually a tricky one; to avoid apply strategy inconsistencies the refresh has to be handled before the check. I will some edits

pkg/controllers/workgenerator/controller.go Show resolved Hide resolved
pkg/utils/common.go Outdated Show resolved Hide resolved
Comment on lines +1819 to +1829
It("can update work status", func() {
work := retrieveWork(memberClusterNamespaceName, fmt.Sprintf(placementv1beta1.FirstWorkNameFmt, testCRPName))

diffReportedCond := &metav1.Condition{
Type: string(placementv1beta1.WorkConditionTypeDiffReported),
Status: metav1.ConditionTrue,
Reason: string(workapplier.ManifestProcessingReportDiffResultTypeNoDiffFound),
ObservedGeneration: work.GetGeneration(),
}
refreshWorkStatus(work, nil, nil, diffReportedCond, nil)
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we won't need this (which simulated a behavior of another controller) if we explicitly set the applied to be false ourself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Ryan! Part of the code tests the status populator, which is why the condition is being set (summarizing all DiffReported conditions from work objects).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants