@@ -62,6 +62,12 @@ type UnboundReconciler struct {
6262 Scheme * runtime.Scheme
6363}
6464
65+ type StubZoneTmplRec struct {
66+ Name string
67+ Options map [string ]string
68+ Servers []string
69+ }
70+
6571func min (i int , j int ) int {
6672 if i < j {
6773 return i
@@ -271,11 +277,6 @@ func (r *UnboundReconciler) reconcileUpgrade(instance *designatev1.DesignateUnbo
271277func (r * UnboundReconciler ) reconcileNormal (ctx context.Context , instance * designatev1.DesignateUnbound , helper * helper.Helper ) (ctrl.Result , error ) {
272278 util .LogForObject (helper , "Reconciling Service" , instance )
273279
274- if controllerutil .AddFinalizer (instance , helper .GetFinalizer ()) {
275- // Return to persist the finalizer immediately
276- return ctrl.Result {}, nil
277- }
278-
279280 serviceLabels := map [string ]string {
280281 common .AppSelector : instance .ObjectMeta .Name ,
281282 common .ComponentSelector : designateunbound .Component ,
@@ -515,6 +516,20 @@ func (r *UnboundReconciler) onIPChange() (ctrl.Result, error) {
515516 return ctrl.Result {}, nil
516517}
517518
519+ func stubZoneDefaults (values map [string ]string ) map [string ]string {
520+
521+ if values == nil {
522+ values = make (map [string ]string )
523+ }
524+ if _ , ok := values ["stub-prime" ]; ! ok {
525+ values ["stub-prime" ] = "true"
526+ }
527+ if _ , ok := values ["stub-first" ]; ! ok {
528+ values ["stub-first" ] = "true"
529+ }
530+ return values
531+ }
532+
518533func (r * UnboundReconciler ) generateServiceConfigMaps (
519534 ctx context.Context ,
520535 instance * designatev1.DesignateUnbound ,
@@ -530,6 +545,32 @@ func (r *UnboundReconciler) generateServiceConfigMaps(
530545
531546 templateParameters := make (map [string ]interface {})
532547
548+ stubZoneData := make ([]StubZoneTmplRec , len (instance .Spec .StubZones ))
549+ if len (instance .Spec .StubZones ) > 0 {
550+ bindIPMap := & corev1.ConfigMap {}
551+ err := h .GetClient ().Get (ctx , types.NamespacedName {Name : designate .BindPredIPConfigMap , Namespace : instance .GetNamespace ()}, bindIPMap )
552+ if err != nil {
553+ if k8s_errors .IsNotFound (err ) {
554+ r .Log .Info ("nameserver IPs not available, unable to complete unbound configuration at this time" )
555+ }
556+ return err
557+ }
558+ bindIPs := make ([]string , len (bindIPMap .Data ))
559+ keyTmpl := "bind_address_%d"
560+ for i := 0 ; i < len (bindIPMap .Data ); i ++ {
561+ bindIPs [i ] = bindIPMap .Data [fmt .Sprintf (keyTmpl , i )]
562+ }
563+
564+ for i := 0 ; i < len (instance .Spec .StubZones ); i ++ {
565+ stubZoneData [i ] = StubZoneTmplRec {
566+ Name : instance .Spec .StubZones [i ].Name ,
567+ Options : stubZoneDefaults (instance .Spec .StubZones [i ].Options ),
568+ Servers : bindIPs ,
569+ }
570+ }
571+ }
572+ templateParameters ["StubZones" ] = stubZoneData
573+
533574 cms := []util.Template {
534575 // ScriptsConfigMap
535576 {
0 commit comments