@@ -19,10 +19,11 @@ package cluster
19
19
*/
20
20
21
21
import (
22
- "strings"
23
22
"bytes"
24
23
"encoding/json"
24
+ "fmt"
25
25
"os"
26
+ "strings"
26
27
"time"
27
28
28
29
crv1 "github.com/crunchydata/postgres-operator/apis/cr/v1"
@@ -154,20 +155,22 @@ func AddCluster(clientset *kubernetes.Clientset, client *rest.RESTClient, cl *cr
154
155
operator .AddDefaultPostgresHaConfigMap (clientset , cl , deploymentFields .IsInit , true , namespace )
155
156
} else {
156
157
configMap , found := kubeapi .GetConfigMap (clientset , strings .Trim (deploymentFields .ConfVolume , "\" " ), namespace )
157
- if found {
158
- if _ , exists := configMap .Data [config .PostgresHaTemplatePath ]; ! exists {
159
- log .Debugf ("Custom postgres-ha config file not found in custom configMap, " +
160
- "creating default configMap with default postgres-ha config file" )
161
- operator .AddDefaultPostgresHaConfigMap (clientset , cl , deploymentFields .IsInit , true , namespace )
162
- } else {
163
- log .Debugf ("Custom postgres-ha config file found in custom configMap, " +
164
- "creating default configMap without default postgres-ha config file" )
165
- operator .AddDefaultPostgresHaConfigMap (clientset , cl , deploymentFields .IsInit , false , namespace )
166
- }
167
- } else {
158
+ if ! found {
159
+ err = fmt .Errorf ("Unable to find custom configMap %s configured for deplyment %s when " +
160
+ "creating the default postgres-ha config file" , deploymentFields .ConfVolume ,
161
+ deploymentFields .Name )
168
162
log .Error (err .Error ())
169
163
return err
170
164
}
165
+ if _ , exists := configMap .Data [config .PostgresHaTemplatePath ]; ! exists {
166
+ log .Debugf ("Custom postgres-ha config file not found in custom configMap, " +
167
+ "creating default configMap with default postgres-ha config file" )
168
+ operator .AddDefaultPostgresHaConfigMap (clientset , cl , deploymentFields .IsInit , true , namespace )
169
+ } else {
170
+ log .Debugf ("Custom postgres-ha config file found in custom configMap, " +
171
+ "creating default configMap without default postgres-ha config file" )
172
+ operator .AddDefaultPostgresHaConfigMap (clientset , cl , deploymentFields .IsInit , false , namespace )
173
+ }
171
174
}
172
175
173
176
log .Debug ("collectaddon value is [" + deploymentFields .CollectAddon + "]" )
0 commit comments