Skip to content

Commit cee735f

Browse files
committed
fix log and condition
1 parent e83604f commit cee735f

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

internal/controller/state/conditions/conditions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,12 +979,12 @@ func NewPolicyTargetNotFound(msg string) Condition {
979979

980980
// NewPolicyAncestorLimitReached returns a Condition that indicates that the Policy is not accepted because
981981
// the ancestor status list has reached the maximum size of 16.
982-
func NewPolicyAncestorLimitReached() Condition {
982+
func NewPolicyAncestorLimitReached(policyType string, policyName string) Condition {
983983
return Condition{
984984
Type: string(v1alpha2.PolicyConditionAccepted),
985985
Status: metav1.ConditionFalse,
986986
Reason: string(PolicyReasonAncestorLimitReached),
987-
Message: PolicyMessageAncestorLimitReached,
987+
Message: fmt.Sprintf("%s %s %s", PolicyMessageAncestorLimitReached, policyType, policyName),
988988
}
989989
}
990990

internal/controller/state/graph/backend_tls_policy.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ func addPolicyAncestorLimitCondition(
204204
}
205205
}
206206

207-
newCondition := conditions.NewPolicyAncestorLimitReached()
208-
newCondition.Message = fmt.Sprintf("%s %s %s", newCondition.Message, policyType, policyName)
207+
newCondition := conditions.NewPolicyAncestorLimitReached(policyType, policyName)
209208
return append(conds, newCondition)
210209
}
211210

internal/controller/state/graph/backend_tls_policy_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -803,8 +803,8 @@ func TestAddGatewaysForBackendTLSPoliciesAncestorLimit(t *testing.T) {
803803
logAncestorLimitReached(testLogger, "test/btp-full-ancestors", "BackendTLSPolicy", "test/gateway1")
804804
logOutput := logBuf.String()
805805

806-
g.Expect(logOutput).To(ContainSubstring("Policy ancestor limit reached"))
807-
g.Expect(logOutput).To(ContainSubstring("policy=test/btp-full-ancestors"))
806+
g.Expect(logOutput).To(ContainSubstring("Policy ancestor limit reached for test/btp-full-ancestors"))
807+
g.Expect(logOutput).To(ContainSubstring("test/btp-full-ancestors"))
808808
g.Expect(logOutput).To(ContainSubstring("policyKind=BackendTLSPolicy"))
809809
g.Expect(logOutput).To(ContainSubstring("ancestor=test/gateway1"))
810810
}

internal/controller/state/graph/policies_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,8 +2304,8 @@ func TestNGFPolicyAncestorLimitHandling(t *testing.T) {
23042304

23052305
// Verify logging occurred
23062306
logOutput := logBuf.String()
2307-
g.Expect(logOutput).To(ContainSubstring("Policy ancestor limit reached"))
2308-
g.Expect(logOutput).To(ContainSubstring("policy=test/policy-full-ancestors"))
2307+
g.Expect(logOutput).To(ContainSubstring("Policy ancestor limit reached for test/policy-full-ancestors"))
2308+
g.Expect(logOutput).To(ContainSubstring("test/policy-full-ancestors"))
23092309
g.Expect(logOutput).To(ContainSubstring("policyKind=TestPolicy"))
23102310
g.Expect(logOutput).To(ContainSubstring("ancestor=test/gateway1"))
23112311
}

internal/controller/state/graph/policy_ancestor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const maxAncestors = 16
1515

1616
// logAncestorLimitReached logs when a policy ancestor limit is reached.
1717
func logAncestorLimitReached(logger logr.Logger, policyName, policyKind, ancestorName string) {
18-
logger.Info("Policy ancestor limit reached", "policy", policyName, "policyKind", policyKind, "ancestor", ancestorName)
18+
logger.Info("Policy ancestor limit reached for "+policyName, "policyKind", policyKind, "ancestor", ancestorName)
1919
}
2020

2121
// ngfPolicyAncestorsFull returns whether or not an ancestor list is full. A list is full when

0 commit comments

Comments
 (0)