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: copy drift/diff details from work status to binding status #960

Merged
merged 12 commits into from
Dec 9, 2024

Conversation

britaniar
Copy link
Contributor

Description of your changes

Fixes #

I have:

  • copied work status drift/diff details to binding status

  • unit tests for new functions created

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

How has this code been tested

Special notes for your reviewer

// or the failed placements are changed.
if condition.EqualCondition(oldAppliedCondition, newAppliedCondition) && condition.EqualCondition(oldAvailableCondition, newAvailableCondition) {
// or the failed/diffed/drifted placements are changed.
if !comparePlacements(oldWork, newWork) && condition.EqualCondition(oldAppliedCondition, newAppliedCondition) && condition.EqualCondition(oldAvailableCondition, newAvailableCondition) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi Britania! Glad that you caught the error in this flow; but the current setup kind of defeats the purpose of this check, which was meant to reduce the overhead for doing comparisons.

@britaniar britaniar force-pushed the workstatus branch 2 times, most recently from 151221c to 7f1f20f Compare November 19, 2024 01:40
Copy link
Contributor

@michaelawyu michaelawyu left a comment

Choose a reason for hiding this comment

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

Added some comments, PTAL 🙏

pkg/controllers/workgenerator/controller.go Outdated Show resolved Hide resolved
@britaniar britaniar marked this pull request as ready for review December 2, 2024 17:20
pkg/controllers/workgenerator/controller.go Outdated Show resolved Hide resolved
pkg/utils/common.go Show resolved Hide resolved
Comment on lines +1155 to 1173
} else {
oldResourceSnapshot := oldWork.Labels[fleetv1beta1.ParentResourceSnapshotIndexLabel]
newResourceSnapshot := newWork.Labels[fleetv1beta1.ParentResourceSnapshotIndexLabel]
if oldResourceSnapshot == "" || newResourceSnapshot == "" {
klog.ErrorS(controller.NewUnexpectedBehaviorError(errors.New("found an invalid work without parent-resource-snapshot-index")),
"Could not find the parent resource snapshot index label", "oldWork", klog.KObj(oldWork), "oldResourceSnapshotLabelValue", oldResourceSnapshot,
"newWork", klog.KObj(newWork), "newResourceSnapshotLabelValue", newResourceSnapshot)
return
}
// There is an edge case that, the work spec is the same but from different resourceSnapshots.
// WorkGenerator will update the work because of the label changes, but the generation is the same.
// When the normal update happens, the controller will set the applied condition as false and wait
// until the work condition has been changed.
// In this edge case, we need to requeue the binding to update the binding status.
if oldResourceSnapshot == newResourceSnapshot {
klog.V(2).InfoS("The work applied or available condition stayed as true, no need to reconcile", "oldWork", klog.KObj(oldWork), "newWork", klog.KObj(newWork))
return
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we still need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I am only comparing the status, so it is still necessary to have these checks that we implemented recently.

@ryanzhang-oss ryanzhang-oss merged commit 80b6d47 into Azure:main Dec 9, 2024
12 checks passed
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.

3 participants