Skip to content

Conversation

@zachsmith1
Copy link
Collaborator

This pull request introduces several changes to the DNS operator to improve status reporting, error handling, and controller logic. The most significant updates are the addition of per-owner status tracking in the API, refactoring of controller logic to better handle various error scenarios, and improved deep copy support for new status types.

API and Status Improvements:

  • Added RecordSets to the DNSRecordSetStatus struct, enabling per-owner (per name) status and conditions tracking. This includes a new RecordSetStatus type and corresponding CRD schema updates for better granularity in reporting readiness and errors.
  • Implemented deep copy methods for the new RecordSetStatus type and updated the deep copy logic for DNSRecordSetStatus to support the new field, ensuring correct handling during reconciliation and status updates.

Controller Logic and Error Handling:

  • Refactored the downstream DNSRecordSet controller to improve finalizer handling, error reporting, and condition setting. Now, the controller sets explicit status conditions (such as Accepted=False) when resources like DNSZone or DNSZoneClass are missing, deleting, or not ready, and avoids unnecessary PowerDNS calls in those cases.
  • Added new error reason constants (ReasonNotOwner, ReasonPDNSError) for more precise condition reporting in status updates.
  • Removed the PowerDNS cleanup logic from the downstream controller, simplifying deletion handling and relying on finalizer removal when appropriate.

Controller Registration:

  • Registered a new DNSRecordSetPowerDNSReconciler controller in the main application entrypoint to support PowerDNS-specific reconciliation flows.

Upstream/Downstream Status Mirroring:

  • Updated the replicator controller to mirror the entire downstream status (including conditions and records) to the upstream resource, instead of just the Programmed condition, improving consistency and observability.

c, err := controller.NewTyped("dnsrecordset-powerdns", mgr, controller.TypedOptions[PowerDNSRecordSetReconcileRequest]{
Reconciler: r,
RateLimiter: rl,
MaxConcurrentReconciles: 4,
Copy link

@joshlreese joshlreese Dec 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a good opportunity to wire this value through the operator config settings.

return err
}

rsHandler := handler.TypedFuncs[*dnsv1alpha1.DNSRecordSet, PowerDNSRecordSetReconcileRequest]{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This handler and the zoneHandler below could be simplified by using handler.TypedEnqueueRequestsFromMapFunc. The example I gave had this - and should function:

func (r *DNSRecordSetPowerDNSReconciler) SetupWithManager(mgr ctrl.Manager) error {

	return builder.TypedControllerManagedBy[PowerDNSRecordSetReconcileRequest](mgr).
		WatchesRawSource(
			source.TypedKind(
				mgr.GetCache(), &dnsv1alpha1.DNSRecordSet{},
				handler.TypedEnqueueRequestsFromMapFunc(func(ctx context.Context, rs *dnsv1alpha1.DNSRecordSet) []PowerDNSRecordSetReconcileRequest {
					var requests []PowerDNSRecordSetReconcileRequest

					// Enqueue a request for each (zone, recordtype, name) tuple

					for _, record := range rs.Spec.Records {
						requests = append(requests, PowerDNSRecordSetReconcileRequest{
							Request: ctrl.Request{
								NamespacedName: client.ObjectKey{
									Namespace: rs.Namespace,
									Name:      rs.Spec.DNSZoneRef.Name,
								},
							},
							RecordSetType: string(rs.Spec.RecordType),
							RecordSetName: record.Name,
						})
					}
					return requests
				}),
			),
		).
		Complete(r)
}

Copy link

@joshlreese joshlreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - just left a couple notes. Nice updates to the accepted / programming condition handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants