diff --git a/api/v1alpha1/dnspolicy_types.go b/api/v1alpha1/dnspolicy_types.go index 6515b51ca..019ce824f 100644 --- a/api/v1alpha1/dnspolicy_types.go +++ b/api/v1alpha1/dnspolicy_types.go @@ -133,7 +133,7 @@ type DNSPolicyStatus struct { HealthCheck *HealthCheckStatus `json:"healthCheck,omitempty"` // +optional - ProbeConditions map[string][]metav1.Condition `json:"probeConditions,omitempty"` + RecordConditions map[string][]metav1.Condition `json:"recordConditions,omitempty"` } func (s *DNSPolicyStatus) GetConditions() []metav1.Condition { diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 214059290..9be351254 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -187,8 +187,8 @@ func (in *DNSPolicyStatus) DeepCopyInto(out *DNSPolicyStatus) { *out = new(HealthCheckStatus) (*in).DeepCopyInto(*out) } - if in.ProbeConditions != nil { - in, out := &in.ProbeConditions, &out.ProbeConditions + if in.RecordConditions != nil { + in, out := &in.RecordConditions, &out.RecordConditions *out = make(map[string][]v1.Condition, len(*in)) for key, val := range *in { var outVal []v1.Condition diff --git a/bundle/manifests/kuadrant-operator.clusterserviceversion.yaml b/bundle/manifests/kuadrant-operator.clusterserviceversion.yaml index 1fdf74bf8..3a6f2aff5 100644 --- a/bundle/manifests/kuadrant-operator.clusterserviceversion.yaml +++ b/bundle/manifests/kuadrant-operator.clusterserviceversion.yaml @@ -106,7 +106,7 @@ metadata: capabilities: Basic Install categories: Integration & Delivery containerImage: quay.io/kuadrant/kuadrant-operator:latest - createdAt: "2024-04-25T14:21:46Z" + createdAt: "2024-05-01T08:22:16Z" operators.operatorframework.io/builder: operator-sdk-v1.32.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: https://github.com/Kuadrant/kuadrant-operator diff --git a/bundle/manifests/kuadrant.io_dnspolicies.yaml b/bundle/manifests/kuadrant.io_dnspolicies.yaml index 37049204d..d73224d90 100644 --- a/bundle/manifests/kuadrant.io_dnspolicies.yaml +++ b/bundle/manifests/kuadrant.io_dnspolicies.yaml @@ -401,7 +401,7 @@ spec: recorded in the status condition format: int64 type: integer - probeConditions: + recordConditions: additionalProperties: items: description: "Condition contains details for one aspect of the diff --git a/config/crd/bases/kuadrant.io_dnspolicies.yaml b/config/crd/bases/kuadrant.io_dnspolicies.yaml index d00229c30..41f4160a6 100644 --- a/config/crd/bases/kuadrant.io_dnspolicies.yaml +++ b/config/crd/bases/kuadrant.io_dnspolicies.yaml @@ -400,7 +400,7 @@ spec: recorded in the status condition format: int64 type: integer - probeConditions: + recordConditions: additionalProperties: items: description: "Condition contains details for one aspect of the diff --git a/controllers/dnspolicy_status.go b/controllers/dnspolicy_status.go index 27d53fdeb..1765c9ba2 100644 --- a/controllers/dnspolicy_status.go +++ b/controllers/dnspolicy_status.go @@ -81,6 +81,8 @@ func (r *DNSPolicyReconciler) calculateStatus(ctx context.Context, dnsPolicy *v1 } recordsList := &kuadrantdnsv1alpha1.DNSRecordList{} + controlledRecords := &kuadrantdnsv1alpha1.DNSRecordList{} + var enforcedCondition *metav1.Condition if err := r.Client().List(ctx, recordsList); err != nil { enforcedCondition = kuadrant.EnforcedCondition(dnsPolicy, kuadrant.NewErrUnknown(dnsPolicy.Kind(), err), false) @@ -90,7 +92,15 @@ func (r *DNSPolicyReconciler) calculateStatus(ctx context.Context, dnsPolicy *v1 meta.SetStatusCondition(&newStatus.Conditions, *enforcedCondition) - propagateRecordConditions(recordsList, newStatus) + for _, record := range recordsList.Items { + for _, reference := range record.GetOwnerReferences() { + if reference.Controller != nil && *reference.Controller && reference.Name == dnsPolicy.Name && reference.UID == dnsPolicy.UID { + controlledRecords.Items = append(controlledRecords.Items, record) + } + } + } + + propagateRecordConditions(controlledRecords, newStatus) return newStatus } @@ -124,7 +134,7 @@ func (r *DNSPolicyReconciler) enforcedCondition(recordsList *kuadrantdnsv1alpha1 func propagateRecordConditions(records *kuadrantdnsv1alpha1.DNSRecordList, policyStatus *v1alpha1.DNSPolicyStatus) { //reset conditions - policyStatus.ProbeConditions = map[string][]metav1.Condition{} + policyStatus.RecordConditions = map[string][]metav1.Condition{} for _, record := range records.Items { var allConditions []metav1.Condition @@ -151,8 +161,8 @@ func propagateRecordConditions(records *kuadrantdnsv1alpha1.DNSRecordList, polic continue } - policyStatus.ProbeConditions[*record.Spec.RootHost] = append( - policyStatus.ProbeConditions[*record.Spec.RootHost], + policyStatus.RecordConditions[*record.Spec.RootHost] = append( + policyStatus.RecordConditions[*record.Spec.RootHost], condition) } } diff --git a/controllers/dnspolicy_status_test.go b/controllers/dnspolicy_status_test.go index 2a166d087..7b3360622 100644 --- a/controllers/dnspolicy_status_test.go +++ b/controllers/dnspolicy_status_test.go @@ -94,7 +94,7 @@ func TestPropagateRecordConditions(t *testing.T) { }, PolicyStatus: &v1alpha1.DNSPolicyStatus{}, Validate: func(t *testing.T, policyStatus *v1alpha1.DNSPolicyStatus) { - if conditions, ok := policyStatus.ProbeConditions[rootHost]; ok { + if conditions, ok := policyStatus.RecordConditions[rootHost]; ok { t.Fatalf("expected no probe conditions for root host, found %v", len(conditions)) } }, @@ -127,7 +127,7 @@ func TestPropagateRecordConditions(t *testing.T) { }, PolicyStatus: &v1alpha1.DNSPolicyStatus{}, Validate: func(t *testing.T, policyStatus *v1alpha1.DNSPolicyStatus) { - if conditions, ok := policyStatus.ProbeConditions[rootHost]; !ok { + if conditions, ok := policyStatus.RecordConditions[rootHost]; !ok { t.Fatalf("expected probe conditions for root host, found none") } else { if len(conditions) != 2 {