Skip to content
Open
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
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func main() {
os.Exit(1)
}
if err := (&controller.DNSZoneDiscoveryReplicator{}).SetupWithManager(mcmgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "DNSZoneDiscoveryReplicator")
setupLog.Error(err, "unable to create controller", "controller", "DNSZoneDiscovery")
os.Exit(1)
}

Expand Down
9 changes: 6 additions & 3 deletions internal/controller/dnszonediscovery_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
mcbuilder "sigs.k8s.io/multicluster-runtime/pkg/builder"
mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager"
mcreconcile "sigs.k8s.io/multicluster-runtime/pkg/reconcile"
Expand Down Expand Up @@ -84,7 +85,9 @@ func (r *DNSZoneDiscoveryReplicator) Reconcile(ctx context.Context, req mcreconc
return ctrl.Result{}, err
}
logger.Info("set controller OwnerReference to DNSZone", "dnsZone", zone.Name)
return ctrl.Result{}, nil
// Requeue explicitly; GenerationChangedPredicate filters metadata-only
// updates so the watch will not re-enqueue for us.
return ctrl.Result{Requeue: true}, nil
}

// Mark Accepted true if not already
Expand Down Expand Up @@ -134,7 +137,7 @@ func (r *DNSZoneDiscoveryReplicator) Reconcile(ctx context.Context, req mcreconc
func (r *DNSZoneDiscoveryReplicator) SetupWithManager(mgr mcmanager.Manager) error {
r.mgr = mgr
return mcbuilder.ControllerManagedBy(mgr).
For(&dnsv1alpha1.DNSZoneDiscovery{}).
Named("dnszonediscovery-replicator").
For(&dnsv1alpha1.DNSZoneDiscovery{}, mcbuilder.WithPredicates(predicate.GenerationChangedPredicate{})).
Named("dnszonediscovery").
Complete(r)
}
9 changes: 5 additions & 4 deletions internal/controller/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
const (
testZoneName = "my-zone"
testNamespace = "default"
kindDNSZone = "DNSZone"
)

// --------------------------------------------------------------------------
Expand Down Expand Up @@ -446,8 +447,8 @@ func TestEmitZoneEvent_RegardingIsZone(t *testing.T) {
t.Fatalf("expected 1 event, got %d", len(fc.events))
}
ref := fc.events[0].Regarding
if ref.Kind != "DNSZone" {
t.Errorf("Regarding.Kind = %q, want %q", ref.Kind, "DNSZone")
if ref.Kind != kindDNSZone {
t.Errorf("Regarding.Kind = %q, want %q", ref.Kind, kindDNSZone)
}
if ref.Name != testZoneName {
t.Errorf("Regarding.Name = %q, want %q", ref.Name, testZoneName)
Expand Down Expand Up @@ -983,8 +984,8 @@ func TestEmitRecordSetEvent_RelatedIsZone(t *testing.T) {
if related == nil {
t.Fatal("Related = nil, want non-nil DNSZone reference")
}
if related.Kind != "DNSZone" {
t.Errorf("Related.Kind = %q, want %q", related.Kind, "DNSZone")
if related.Kind != kindDNSZone {
t.Errorf("Related.Kind = %q, want %q", related.Kind, kindDNSZone)
}
if related.Name != testZoneName {
t.Errorf("Related.Name = %q, want %q", related.Name, testZoneName)
Expand Down
Loading
Loading