Skip to content

Commit a87305c

Browse files
scotwellsclaude
andcommitted
fix: use non-controller ownerReference for DNSRecordSets
The dns-operator's dnsrecordset-replicator controller rejects DNSRecordSets that have controller=true on their ownerReference (unless owned by DNSZone). This was causing the error: "Object is already owned by another Gateway controller". Change from SetControllerReference to SetOwnerReference so the Gateway still owns the DNSRecordSet for garbage collection purposes, but the dns-operator can manage (replicate) the record. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent cb046bd commit a87305c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/controller/gateway_dns_controller.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,11 @@ func (r *GatewayReconciler) ensureDNSRecordSets(
245245
return fmt.Errorf("conflict: existing DNSRecordSet %q is managed by %q", desired.Name, existingManagedBy)
246246
}
247247

248-
// Ensure owner reference is always set.
249-
if err := controllerutil.SetControllerReference(upstreamGateway, desired, upstreamClient.Scheme()); err != nil {
248+
// Set owner reference for garbage collection, but NOT as controller.
249+
// The dns-operator's dnsrecordset-replicator expects to be the controller
250+
// of DNSRecordSets it manages. Using SetOwnerReference (not SetControllerReference)
251+
// allows the Gateway to own the record for GC while letting dns-operator manage it.
252+
if err := controllerutil.SetOwnerReference(upstreamGateway, desired, upstreamClient.Scheme()); err != nil {
250253
return fmt.Errorf("failed to set owner reference on DNSRecordSet: %w", err)
251254
}
252255

0 commit comments

Comments
 (0)