diff --git a/internal/controller/dnsrecord_controller.go b/internal/controller/dnsrecord_controller.go index 5c8e90a7..f802ecb8 100644 --- a/internal/controller/dnsrecord_controller.go +++ b/internal/controller/dnsrecord_controller.go @@ -79,7 +79,6 @@ func (r *DNSRecordReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( } } dnsRecord := previous.DeepCopy() - dnsRecord.Status.QueuedAt = reconcileStart if dnsRecord.DeletionTimestamp != nil && !dnsRecord.DeletionTimestamp.IsZero() { if err = r.deleteRecord(ctx, dnsRecord); err != nil { @@ -326,6 +325,7 @@ func (r *DNSRecordReconciler) applyChanges(ctx context.Context, dnsRecord *v1alp plan = plan.Calculate() dnsRecord.Status.ValidFor = defaultRequeueTime.String() + dnsRecord.Status.QueuedAt = reconcileStart if plan.Changes.HasChanges() { // generation has not changed but there are changes. // implies that they were overridden - bump write counter @@ -333,7 +333,7 @@ func (r *DNSRecordReconciler) applyChanges(ctx context.Context, dnsRecord *v1alp dnsRecord.Status.WriteCounter++ } dnsRecord.Status.ValidFor = validationRequeueTime.String() - setDNSRecordCondition(dnsRecord, string(v1alpha1.ConditionTypeReady), metav1.ConditionFalse, "Awaiting validation", "Awaiting validation") + setDNSRecordCondition(dnsRecord, string(v1alpha1.ConditionTypeReady), metav1.ConditionFalse, "AwaitingValidation", "Awaiting validation") logger.Info("Applying changes") err = registry.ApplyChanges(ctx, plan.Changes) if err != nil { diff --git a/internal/controller/dnsrecord_controller_test.go b/internal/controller/dnsrecord_controller_test.go index 2505db25..a2acf80c 100644 --- a/internal/controller/dnsrecord_controller_test.go +++ b/internal/controller/dnsrecord_controller_test.go @@ -28,7 +28,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" - externaldnsendpoint "sigs.k8s.io/external-dns/endpoint" "github.com/kuadrant/dns-operator/api/v1alpha1" ) @@ -53,19 +52,7 @@ var _ = Describe("DNSRecordReconciler", func() { ManagedZoneRef: &v1alpha1.ManagedZoneReference{ Name: managedZone.Name, }, - Endpoints: []*externaldnsendpoint.Endpoint{ - { - DNSName: "foo.example.com", - Targets: []string{ - "127.0.0.1", - }, - RecordType: "A", - SetIdentifier: "", - RecordTTL: 60, - Labels: nil, - ProviderSpecific: nil, - }, - }, + Endpoints: getTestEndpoints(), }, } }) diff --git a/internal/controller/helper_test.go b/internal/controller/helper_test.go index 4a7188c8..91bfc797 100644 --- a/internal/controller/helper_test.go +++ b/internal/controller/helper_test.go @@ -6,14 +6,17 @@ import ( "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + externaldnsendpoint "sigs.k8s.io/external-dns/endpoint" kuadrantdnsv1alpha1 "github.com/kuadrant/dns-operator/api/v1alpha1" ) const ( - TestTimeoutMedium = time.Second * 10 - TestTimeoutLong = time.Second * 30 + TestTimeoutMedium = time.Second * 20 + TestTimeoutLong = time.Second * 60 TestRetryIntervalMedium = time.Millisecond * 250 + RequeueDuration = time.Second * 10 + ValidityDuration = time.Second * 5 defaultNS = "default" providerCredential = "secretname" ) @@ -34,3 +37,19 @@ func testBuildManagedZone(name, ns, domainName string) *kuadrantdnsv1alpha1.Mana }, } } + +func getTestEndpoints() []*externaldnsendpoint.Endpoint { + return []*externaldnsendpoint.Endpoint{ + { + DNSName: "foo.example.com", + Targets: []string{ + "127.0.0.1", + }, + RecordType: "A", + SetIdentifier: "", + RecordTTL: 60, + Labels: nil, + ProviderSpecific: nil, + }, + } +} diff --git a/internal/controller/suite_test.go b/internal/controller/suite_test.go index c2814359..61e4cbd3 100644 --- a/internal/controller/suite_test.go +++ b/internal/controller/suite_test.go @@ -53,11 +53,6 @@ import ( // These tests use Ginkgo (BDD-style Go testing framework). Refer to // http://onsi.github.io/ginkgo/ to learn more about Ginkgo. -const ( - RequeueDuration = time.Minute * 1 - ValidityDuration = time.Second * 30 -) - var cfg *rest.Config var k8sClient client.Client var testEnv *envtest.Environment @@ -67,7 +62,7 @@ var dnsProviderFactory = &providerFake.Factory{ ProviderForFunc: func(ctx context.Context, pa v1alpha1.ProviderAccessor, c provider.Config) (provider.Provider, error) { return &providerFake.Provider{ RecordsFunc: func(context.Context) ([]*externaldnsendpoint.Endpoint, error) { - return []*externaldnsendpoint.Endpoint{}, nil + return getTestEndpoints(), nil }, ApplyChangesFunc: func(context.Context, *externaldnsplan.Changes) error { return nil