Skip to content

Commit 065133b

Browse files
committed
f2
1 parent 3152257 commit 065133b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

internal/controller/policies.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,16 @@ func ProcessBackendTrafficPolicy(c client.Client,
6060
condition := NewPolicyCondition(policy.Generation, true, "Policy has been accepted")
6161
if sectionName != nil && !portNameExist[string(*sectionName)] {
6262
condition = NewPolicyCondition(policy.Generation, false, fmt.Sprintf("SectionName %s not found in Service %s/%s", *sectionName, service.Namespace, service.Name))
63-
if ok := SetAncestors(&policy.Status, tctx.ParentRefs, condition); ok {
64-
updated = true
65-
}
63+
processPolicyStatus(&policy, tctx, condition, &updated)
64+
continue
6665
}
6766
if p, ok := conflicts[key.String()]; ok && (p.Name == policy.Name && p.Namespace == policy.Namespace) {
6867
condition = NewPolicyConflictCondition(policy.Generation, fmt.Sprintf("Unable to target Service %s/%s, because it conflicts with another BackendTrafficPolicy", service.Namespace, service.Name))
69-
if ok := SetAncestors(&policy.Status, tctx.ParentRefs, condition); ok {
70-
updated = true
71-
}
68+
processPolicyStatus(&policy, tctx, condition, &updated)
69+
continue
7270
}
7371
conflicts[key.String()] = policy
72+
processPolicyStatus(&policy, tctx, condition, &updated)
7473
}
7574
if _, ok := tctx.BackendTrafficPolicies[types.NamespacedName{
7675
Name: policy.Name,
@@ -90,6 +89,16 @@ func ProcessBackendTrafficPolicy(c client.Client,
9089
}
9190
}
9291
}
92+
93+
func processPolicyStatus(policy *v1alpha1.BackendTrafficPolicy,
94+
tctx *provider.TranslateContext,
95+
condition metav1.Condition,
96+
updated *bool) {
97+
if ok := SetAncestors(&policy.Status, tctx.ParentRefs, condition); ok {
98+
*updated = true
99+
}
100+
}
101+
93102
func SetAncestors(status *v1alpha1.PolicyStatus, parentRefs []gatewayv1.ParentReference, condition metav1.Condition) bool {
94103
updated := false
95104
for _, parent := range parentRefs {

0 commit comments

Comments
 (0)