Skip to content

Commit 674aea8

Browse files
author
Jeff McCormick
committed
add client check for valid storage type when doing a restore
1 parent 15f7b53 commit 674aea8

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

client/cmd/backup.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,14 @@
1717
package cmd
1818

1919
import (
20-
//"bufio"
21-
"bytes"
22-
"encoding/json"
2320
"fmt"
2421
log "github.com/Sirupsen/logrus"
2522
"github.com/crunchydata/postgres-operator/tpr"
2623
"github.com/spf13/cobra"
2724
"github.com/spf13/viper"
28-
"io"
29-
"io/ioutil"
3025
"k8s.io/client-go/pkg/api"
3126
"k8s.io/client-go/pkg/api/errors"
3227
"k8s.io/client-go/pkg/api/v1"
33-
"strings"
34-
"text/template"
3528
"time"
3629
)
3730

@@ -177,7 +170,7 @@ func createBackup(args []string) {
177170
deleteBackup(dels)
178171
time.Sleep(2000 * time.Millisecond)
179172
} else if errors.IsNotFound(err) {
180-
fmt.Println("pgbackup " + arg + " not found so we will create it")
173+
log.Debug("pgbackup " + arg + " not found so we will create it")
181174
} else {
182175
log.Error("error getting pgbackup " + arg)
183176
log.Error(err.Error())

client/cmd/cluster.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ func listServices(name string) {
159159
func createCluster(args []string) {
160160
var err error
161161

162+
//validate configuration
163+
if viper.GetString("MASTER_STORAGE.STORAGE_TYPE") == "existing" {
164+
if BackupPVC != "" {
165+
log.Error("storage type of existing not allowed when doing a restore")
166+
return
167+
}
168+
}
169+
162170
for _, arg := range args {
163171
log.Debug("create cluster called for " + arg)
164172
result := tpr.PgCluster{}
@@ -369,8 +377,8 @@ func validateSecretFrom(secretname string) error {
369377
pguserFound := false
370378

371379
for _, s := range secrets.Items {
372-
fmt.Println("")
373-
fmt.Println("secret : " + s.ObjectMeta.Name)
380+
//fmt.Println("")
381+
//fmt.Println("secret : " + s.ObjectMeta.Name)
374382
if s.ObjectMeta.Name == secretname+tpr.PGMASTER_SECRET_SUFFIX {
375383
pgmasterFound = true
376384
} else if s.ObjectMeta.Name == secretname+tpr.PGROOT_SECRET_SUFFIX {

conf/postgres-operator/cluster/1/cluster-deployment-1.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
},
1010
"spec": {
1111
"replicas": 1,
12-
"selector": {
13-
"matchLabels": {
14-
"name": "{{.Name}}"
15-
}
16-
},
1712
"template": {
1813
"metadata": {
1914
"labels": {

0 commit comments

Comments
 (0)