Skip to content

Commit

Permalink
feat: support placement field in the override (#988)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiying-lin authored Dec 13, 2024
1 parent 9a3cd78 commit 81e428d
Show file tree
Hide file tree
Showing 2 changed files with 405 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/utils/overrider/overrider.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
)

// FetchAllMatchingOverridesForResourceSnapshot fetches all the matching overrides which are attached to the selected resources.
// TODO: to improve the performance, we can add the index on the placement field of the override snapshots.
func FetchAllMatchingOverridesForResourceSnapshot(
ctx context.Context,
c client.Client,
Expand Down Expand Up @@ -104,6 +105,12 @@ func FetchAllMatchingOverridesForResourceSnapshot(
filteredCRO := make([]*placementv1alpha1.ClusterResourceOverrideSnapshot, 0, len(croList.Items))
filteredRO := make([]*placementv1alpha1.ResourceOverrideSnapshot, 0, len(roList.Items))
for i := range croList.Items {
placementInOverride := croList.Items[i].Spec.OverrideSpec.Placement
if placementInOverride != nil && placementInOverride.Name != crp {
klog.V(2).InfoS("Skipping this override which was created for another placement", "clusterResourceOverride", klog.KObj(&croList.Items[i]), "placementInOverride", placementInOverride.Name, "clusterResourcePlacement", crp)
continue
}

for _, selector := range croList.Items[i].Spec.OverrideSpec.ClusterResourceSelectors {
croKey := placementv1beta1.ResourceIdentifier{
Group: selector.Group,
Expand All @@ -118,6 +125,12 @@ func FetchAllMatchingOverridesForResourceSnapshot(
}
}
for i := range roList.Items {
placementInOverride := roList.Items[i].Spec.OverrideSpec.Placement
if placementInOverride != nil && placementInOverride.Name != crp {
klog.V(2).InfoS("Skipping this override which was created for another placement", "resourceOverride", klog.KObj(&roList.Items[i]), "placementInOverride", placementInOverride.Name, "clusterResourcePlacement", crp)
continue
}

for _, selector := range roList.Items[i].Spec.OverrideSpec.ResourceSelectors {
roKey := placementv1beta1.ResourceIdentifier{
Group: selector.Group,
Expand Down
Loading

0 comments on commit 81e428d

Please sign in to comment.