Skip to content

Commit 0a99a0b

Browse files
committed
fix status
1 parent 7716bfc commit 0a99a0b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

internal/controller/policies.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func ProcessBackendTrafficPolicy(c client.Client, tctx *provider.TranslateContex
4949
}
5050
for _, policy := range backendTrafficPolicyList.Items {
5151
targetRefs := policy.Spec.TargetRefs
52+
updated := false
5253
for _, targetRef := range targetRefs {
5354
sectionName := targetRef.SectionName
5455
key := PolicyTargetKey{
@@ -60,16 +61,26 @@ func ProcessBackendTrafficPolicy(c client.Client, tctx *provider.TranslateContex
6061
condition = NewPolicyCondition(policy.Generation, false, fmt.Sprintf("SectionName %s not found in Service %s/%s", *sectionName, service.Namespace, service.Name))
6162
goto record_status
6263
}
63-
if p, ok := conflicts[key.String()]; ok && (p.Name == policy.Name && p.Namespace != policy.Namespace) {
64-
condition = NewPolicyConflictCondition(policy.Generation, fmt.Sprintf("Unable to target Service %s/%s with BackendTrafficPolicy %s/%s", service.Namespace, service.Name, policy.Namespace, policy.Name))
64+
if p, ok := conflicts[key.String()]; ok && (p.Name == policy.Name && p.Namespace == policy.Namespace) {
65+
condition = NewPolicyConflictCondition(policy.Generation, fmt.Sprintf("Unable to target Service %s/%s, because it conflicts with another BackendTrafficPolicy", service.Namespace, service.Name))
6566
goto record_status
6667
}
6768
conflicts[key.String()] = policy
6869
record_status:
6970
if ok := SetAncestors(&policy.Status, tctx.ParentRefs, condition); ok {
70-
tctx.StatusUpdaters = append(tctx.StatusUpdaters, policy.DeepCopy())
71+
updated = true
7172
}
7273
}
74+
if _, ok := tctx.BackendTrafficPolicies[types.NamespacedName{
75+
Name: policy.Name,
76+
Namespace: policy.Namespace,
77+
}]; ok {
78+
continue
79+
}
80+
81+
if updated {
82+
tctx.StatusUpdaters = append(tctx.StatusUpdaters, policy.DeepCopy())
83+
}
7384

7485
tctx.BackendTrafficPolicies[types.NamespacedName{
7586
Name: policy.Name,

0 commit comments

Comments
 (0)