Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- **Operator, ACL conflicts:** the `ACLConflict` condition and the `KafkaAccessPolicy` webhook
rejection now say that the Deny is applied and the Allow is dropped, and the condition names
which side this resource holds. Since 1.1.0 they still said the whole ACL tuple was dropped.

## [1.1.0] - 2026-11-11

### Added
Expand Down
18 changes: 10 additions & 8 deletions internal/operator/reconcile/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ type ClusterACLView struct {
// the AND-merge sees every owner's consent. clusterDefaults may be nil.
//
// Cross-resource Allow/Deny conflicts (which no single-resource validation can
// see) are resolved first-seen-wins, exactly as BuildDesiredSet documents: the
// conflicting tuple is dropped from the union. That is deliberate — the view
// see) are resolved first-seen-wins, exactly as BuildDesiredSet documents, and
// the Deny-first sort makes the Deny that first-seen survivor: the Allow is
// dropped from the union and the Deny is applied. That is deliberate — the view
// must stay buildable so reconciles keep running; the conflict surfaces as
// drift on the losing resource.
func BuildClusterACLView(topics []*v1alpha1.KafkaTopic, policies []*v1alpha1.KafkaAccessPolicy,
Expand Down Expand Up @@ -1435,7 +1436,8 @@ func setTerminalValidationFailedReasons(kind string, conds *[]metav1.Condition,
// True (reason CrossResourceConflict) when this resource (kind/namespace/name)
// is a party to any conflict in the view, naming the other party + subject;
// else False (reason NoConflict). NON-terminal — informational only; the
// conflicting tuple is already dropped from the applied union (no flapping).
// view already resolved the conflict to the Deny (the Allow is dropped from
// the applied union, no flapping).
// When view is nil (single-resource fallback), the condition is cleared.
func setACLConflictCondition(conds *[]metav1.Condition, view *ClusterACLView, kind, namespace, name string, gen int64) {
if view == nil {
Expand All @@ -1446,17 +1448,17 @@ func setACLConflictCondition(conds *[]metav1.Condition, view *ClusterACLView, ki
return c.SourceKind == kind && c.SourceNamespace == namespace && c.SourceName == name
}
for _, cf := range view.Conflicts {
var other access.ACL
var mine, other access.ACL
switch {
case isParty(cf.A):
other = cf.B
mine, other = cf.A, cf.B
case isParty(cf.B):
other = cf.A
mine, other = cf.B, cf.A
default:
continue
}
msg := fmt.Sprintf("ACL %s conflicts Allow/Deny with %s/%s/%s on the same tuple; the tuple is dropped from the applied set",
cf.Subject, other.SourceKind, other.SourceNamespace, other.SourceName)
msg := fmt.Sprintf("ACL %s: this resource's %s conflicts with the %s from %s/%s/%s on the same tuple; the Deny is applied and the Allow is not",
cf.Subject, mine.Permission, other.Permission, other.SourceKind, other.SourceNamespace, other.SourceName)
setCond(conds, v1alpha1.CondACLConflict, metav1.ConditionTrue, reasonCrossResourceConflict, msg, gen)
return
}
Expand Down
10 changes: 10 additions & 0 deletions internal/operator/reconcile/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2018,6 +2018,12 @@ func TestSetACLConflictConditionIsPartyAsA(t *testing.T) {
if !strings.Contains(c.Message, "the-subject") {
t.Fatalf("ACLConflict message = %q, want to contain subject %q", c.Message, "the-subject")
}
// Party A holds the Allow: the message must say its Allow loses to the Deny.
for _, want := range []string{"this resource's Allow", "the Deny from KafkaAccessPolicy/ns1/policy-p1", "the Deny is applied and the Allow is not"} {
if !strings.Contains(c.Message, want) {
t.Fatalf("ACLConflict message = %q, want to contain %q", c.Message, want)
}
}
}

// TestSetACLConflictConditionIsPartyAsB verifies that when the resource is party
Expand Down Expand Up @@ -2045,6 +2051,10 @@ func TestSetACLConflictConditionIsPartyAsB(t *testing.T) {
if !strings.Contains(c.Message, "ns1/topic-t1") {
t.Fatalf("ACLConflict message = %q, want to contain other party namespace/name %q", c.Message, "ns1/topic-t1")
}
// Party B holds the Deny, which is the side that is applied.
if !strings.Contains(c.Message, "this resource's Deny conflicts with the Allow") {
t.Fatalf("ACLConflict message = %q, want it to name this resource's Deny against the Allow", c.Message)
}
}

// TestReconcileTopicACLConflictConditionTrue verifies that ReconcileTopic sets
Expand Down
2 changes: 1 addition & 1 deletion internal/operator/webhook/kafkaaccesspolicy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (v *KafkaAccessPolicyValidator) checkConflict(ctx context.Context, pol *v1a
return fmt.Errorf(
"KafkaAccessPolicy %s/%s introduces an ACL conflict with %s %s/%s on subject %q: "+
"Allow/Deny disagreement on the same ACL tuple (spec §21); "+
"the tuple will be dropped from the applied set — resolve the disagreement before admission",
"the operator would apply the Deny and drop the Allow — resolve the disagreement before admission",
pol.Namespace, pol.Name, otherKind, otherNS, otherName, cf.Subject)
}
return nil
Expand Down
Loading