Skip to content

Commit c75c9bc

Browse files
author
Jeff McCormick
committed
update code for dynamic storage
1 parent 2cf5d09 commit c75c9bc

File tree

4 files changed

+20
-19
lines changed

4 files changed

+20
-19
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pgo: check-go-vars
1717
cd client && go build -o $(GOBIN)/pgo pgo.go
1818
clean: check-go-vars
1919
rm -rf $(GOPATH)/pkg/* $(GOBIN)/*
20-
go get -u github.com/FiloSottile/gvt
21-
gvt restore
20+
go get github.com/tools/godep
21+
godep restore
2222
operatorimage: check-go-vars
2323
cd operator && go install postgres-operator.go
2424
cp $(GOBIN)/postgres-operator bin/postgres-operator

client/cmd/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,13 @@ func validateConfig() {
166166
os.Exit(2)
167167
}
168168

169+
/**
169170
if viper.GetString("MASTER_STORAGE.STORAGE_TYPE") == "dynamic" ||
170171
viper.GetString("REPLICA_STORAGE.STORAGE_TYPE") == "dynamic" {
171172
log.Error("STORAGE_TYPE dynamic is not supported yet")
172173
os.Exit(2)
173174
}
175+
*/
174176

175177
rep := viper.GetString("CLUSTER.REPLICAS")
176178
if rep != "" {

operator/cluster/cluster.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ func createPVC(clientset *kubernetes.Clientset, name string, storageSpec *tpr.Pg
372372
case "existing":
373373
log.Debug("StorageType is existing")
374374
pvcName = storageSpec.PvcName
375-
case "create":
375+
case "create", "dynamic":
376376
log.Debug("StorageType is create")
377377
pvcName = name + "-pvc"
378378
log.Debug("PVC_NAME=%s PVC_SIZE=%s PVC_ACCESS_MODE=%s\n",
@@ -383,8 +383,6 @@ func createPVC(clientset *kubernetes.Clientset, name string, storageSpec *tpr.Pg
383383
return pvcName, err
384384
}
385385
log.Info("created PVC =" + pvcName + " in namespace " + namespace)
386-
case "dynamic":
387-
log.Debug("StorageType is dynamic, not supported yet")
388386
}
389387

390388
return pvcName, err

operator/cluster/cluster_strategy_1.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,22 @@ func (r ClusterStrategy1) AddCluster(clientset *kubernetes.Clientset, client *re
125125
if err != nil {
126126
log.Error("could not convert REPLICAS config setting")
127127
} else {
128-
//create the replica service
129-
serviceName := cl.Spec.Name + "-replica"
130-
repserviceFields := ServiceTemplateFields{
131-
Name: serviceName,
132-
ClusterName: cl.Spec.Name,
133-
Port: cl.Spec.Port,
134-
}
128+
if newReplicas > 0 {
129+
//create the replica service
130+
serviceName := cl.Spec.Name + "-replica"
131+
repserviceFields := ServiceTemplateFields{
132+
Name: serviceName,
133+
ClusterName: cl.Spec.Name,
134+
Port: cl.Spec.Port,
135+
}
135136

136-
err = CreateService(clientset, &repserviceFields, namespace)
137-
if err != nil {
138-
log.Error("error in creating replica service " + err.Error())
139-
return err
137+
err = CreateService(clientset, &repserviceFields, namespace)
138+
if err != nil {
139+
log.Error("error in creating replica service " + err.Error())
140+
return err
141+
}
142+
ScaleReplicas(serviceName, clientset, cl, newReplicas, namespace)
140143
}
141-
ScaleReplicas(serviceName, clientset, cl, newReplicas, namespace)
142144
}
143145

144146
return err
@@ -429,9 +431,8 @@ func (r ClusterStrategy1) CreateReplica(serviceName string, clientset *kubernete
429431
switch cl.Spec.ReplicaStorage.StorageType {
430432
case "", "emptydir":
431433
log.Debug("MasterStorage.StorageType is emptydir")
432-
log.Debug("using the dynamic replica template ")
433434
err = ReplicaDeploymentTemplate1.Execute(&replicaDoc, replicaDeploymentFields)
434-
case "existing", "create":
435+
case "existing", "create", "dynamic":
435436
log.Debug("using the shared replica template ")
436437
err = ReplicaDeploymentTemplate1Shared.Execute(&replicaDoc, replicaDeploymentFields)
437438
}

0 commit comments

Comments
 (0)