Skip to content

Commit

Permalink
Added new watcher logic
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelawyu committed Jan 27, 2025
1 parent 20de7b7 commit 2d30c7f
Show file tree
Hide file tree
Showing 5 changed files with 980 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apis/placement/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions pkg/controllers/clusterresourcebindingwatcher/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,23 @@ func isBindingStatusUpdated(oldBinding, newBinding *fleetv1beta1.ClusterResource
oldCond := oldBinding.GetCondition(string(i.ResourceBindingConditionType()))
newCond := newBinding.GetCondition(string(i.ResourceBindingConditionType()))
if !condition.EqualCondition(oldCond, newCond) {
klog.V(2).InfoS("The binding condition has changed, need to update the corresponding CRP", "oldBinding", klog.KObj(oldBinding), "newBinding", klog.KObj(newBinding), "type", i.ResourceBindingConditionType())
klog.V(2).InfoS("The binding status conditions have changed, need to refresh the CRP status", "binding", klog.KObj(oldBinding), "type", i.ResourceBindingConditionType())
return true
}
}
if !utils.IsFailedResourcePlacementsEqual(oldBinding.Status.FailedPlacements, newBinding.Status.FailedPlacements) {
klog.V(2).InfoS("The binding failed placement has changed, need to update the corresponding CRP", "oldBinding", klog.KObj(oldBinding), "newBinding", klog.KObj(newBinding))
klog.V(2).InfoS("Failed placements reported on the binding status has changed, need to refresh the CRP status", "binding", klog.KObj(oldBinding))
return true
}
klog.V(5).InfoS("The binding status has not changed, no need to update the corresponding CRP", "oldBinding", klog.KObj(oldBinding), "newBinding", klog.KObj(newBinding))
if !utils.IsDriftedResourcePlacementsEqual(oldBinding.Status.DriftedPlacements, newBinding.Status.DriftedPlacements) {
klog.V(2).InfoS("Drifted placements reported on the binding status has changed, need to refresh the CRP status", "binding", klog.KObj(oldBinding))
return true
}
if !utils.IsDiffedResourcePlacementsEqual(oldBinding.Status.DiffedPlacements, newBinding.Status.DiffedPlacements) {
klog.V(2).InfoS("Diffed placements reported on the binding status has changed, need to refresh the CRP status", "binding", klog.KObj(oldBinding))
return true
}

klog.V(5).InfoS("The binding status has not changed, no need to refresh the CRP status", "binding", klog.KObj(oldBinding))
return false
}
Loading

0 comments on commit 2d30c7f

Please sign in to comment.