@@ -378,7 +378,7 @@ func (r *DesignateReconciler) reconcileInit(
378378 // create hash over all the different input resources to identify if any those changed
379379 // and a restart/recreate is required.
380380 //
381- _ , hashChanged , err := r .createHashOfInputHashes (ctx , instance , configMapVars )
381+ _ , hashChanged , err := r .createHashOfInputHashes (ctx , instance , common . InputHashName , configMapVars , nil )
382382 if err != nil {
383383 return ctrl.Result {}, err
384384 } else if hashChanged {
@@ -742,6 +742,12 @@ func (r *DesignateReconciler) reconcileNormal(ctx context.Context, instance *des
742742 return ctrl.Result {}, err
743743 }
744744
745+ nsRecordsLabels := labels .GetLabels (instance , labels .GetGroupLabel (instance .ObjectMeta .Name ), map [string ]string {})
746+ nsRecordsConfigMap , err := r .handleConfigMap (ctx , helper , instance , designate .NsRecordsConfigMap , nsRecordsLabels )
747+ if err != nil {
748+ return ctrl.Result {}, err
749+ }
750+
745751 allocatedIPs := make (map [string ]bool )
746752 for _ , predIP := range bindConfigMap .Data {
747753 allocatedIPs [predIP ] = true
@@ -807,6 +813,49 @@ func (r *DesignateReconciler) reconcileNormal(ctx context.Context, instance *des
807813 return ctrl.Result {}, err
808814 }
809815
816+ if err != nil {
817+ return ctrl.Result {}, err
818+ }
819+ if len (nsRecordsConfigMap .Data ) > 0 {
820+ poolsYamlConfigMap := & corev1.ConfigMap {
821+ ObjectMeta : metav1.ObjectMeta {
822+ Name : designate .PoolsYamlsConfigMap ,
823+ Namespace : instance .GetNamespace (),
824+ Labels : bindLabels ,
825+ },
826+ Data : make (map [string ]string ),
827+ }
828+ poolsYaml , err := designate .GeneratePoolsYamlData (bindConfigMap .Data , mdnsConfigMap .Data , nsRecordsConfigMap .Data )
829+ if err != nil {
830+ return ctrl.Result {}, err
831+ }
832+ Log .Info (fmt .Sprintf ("pools.yaml content is\n %v" , poolsYaml ))
833+ updatedPoolsYaml := make (map [string ]string )
834+ updatedPoolsYaml [designate .PoolsYamlsConfigMap ] = poolsYaml
835+
836+ _ , err = controllerutil .CreateOrPatch (ctx , helper .GetClient (), poolsYamlConfigMap , func () error {
837+ poolsYamlConfigMap .Labels = util .MergeStringMaps (poolsYamlConfigMap .Labels , bindLabels )
838+ poolsYamlConfigMap .Data = updatedPoolsYaml
839+ return controllerutil .SetControllerReference (instance , poolsYamlConfigMap , helper .GetScheme ())
840+ })
841+ if err != nil {
842+ Log .Info ("Unable to create config map for pools.yaml file" )
843+ return ctrl.Result {}, err
844+ }
845+ configMaps := []interface {}{
846+ poolsYamlConfigMap .Data ,
847+ }
848+
849+ poolsYamlsEnvVars := make (map [string ]env.Setter )
850+ _ , changed , err := r .createHashOfInputHashes (ctx , instance , designate .PoolsYamlHash , poolsYamlsEnvVars , configMaps )
851+ if err != nil {
852+ return ctrl.Result {}, err
853+ } else if changed {
854+ // launch the pool update job
855+ Log .Info ("Creating a pool update job" )
856+ }
857+ }
858+
810859 // deploy designate-central
811860 designateCentral , op , err := r .centralDeploymentCreateOrUpdate (ctx , instance )
812861 if err != nil {
@@ -1087,7 +1136,7 @@ func (r *DesignateReconciler) handleConfigMap(ctx context.Context, helper *helpe
10871136 err := helper .GetClient ().Get (ctx , types.NamespacedName {Name : configMapName , Namespace : instance .GetNamespace ()}, foundMap )
10881137 if err != nil {
10891138 if k8s_errors .IsNotFound (err ) {
1090- Log .Info (fmt .Sprintf ("Ip map %s doesn't exist, creating." , configMapName ))
1139+ Log .Info (fmt .Sprintf ("configmap %s doesn't exist, creating." , configMapName ))
10911140 } else {
10921141 return nil , err
10931142 }
@@ -1346,23 +1395,45 @@ func (r *DesignateReconciler) generateServiceConfigMaps(
13461395func (r * DesignateReconciler ) createHashOfInputHashes (
13471396 ctx context.Context ,
13481397 instance * designatev1beta1.Designate ,
1398+ hashType string ,
13491399 envVars map [string ]env.Setter ,
1400+ additionalConfigmaps []interface {},
13501401) (string , bool , error ) {
13511402 Log := r .GetLogger (ctx )
13521403
13531404 var hashMap map [string ]string
13541405 changed := false
13551406 mergedMapVars := env .MergeEnvs ([]corev1.EnvVar {}, envVars )
1356- hash , err := util .ObjectHash (mergedMapVars )
1407+ combinedHashes := []string {}
1408+
1409+ envHash , err := util .ObjectHash (mergedMapVars )
13571410 if err != nil {
13581411 Log .Info ("XXX - Error creating hash" )
1359- return hash , changed , err
1412+ return "" , changed , err
1413+ }
1414+ combinedHashes = append (combinedHashes , envHash )
1415+
1416+ for _ , configMap := range additionalConfigmaps {
1417+ configMapHash , err := util .ObjectHash (configMap )
1418+ if err != nil {
1419+ Log .Info (fmt .Sprintf ("Error creating hash for %v" , configMap ))
1420+ return "" , changed , err
1421+ }
1422+ combinedHashes = append (combinedHashes , configMapHash )
1423+ }
1424+
1425+ finalHash , err := util .ObjectHash (combinedHashes )
1426+ if err != nil {
1427+ Log .Info ("Error creating final hash" )
1428+ return "" , changed , err
13601429 }
1361- if hashMap , changed = util .SetHash (instance .Status .Hash , common .InputHashName , hash ); changed {
1430+
1431+ if hashMap , changed = util .SetHash (instance .Status .Hash , hashType , finalHash ); changed {
13621432 instance .Status .Hash = hashMap
1363- Log .Info (fmt .Sprintf ("Input maps hash %s - %s" , common . InputHashName , hash ))
1433+ Log .Info (fmt .Sprintf ("Input maps hash %s - %s" , hashType , finalHash ))
13641434 }
1365- return hash , changed , nil
1435+
1436+ return finalHash , changed , nil
13661437}
13671438
13681439func (r * DesignateReconciler ) transportURLCreateOrUpdate (
0 commit comments