Skip to content

Commit 216a24a

Browse files
author
jmccormick2001
committed
fix backup command to return proper error message if the user tries to perform a pgbackrest backup on a cluster that does not have pgbackrest enabled
1 parent 6b66462 commit 216a24a

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

apiserver/backrestservice/backrestimpl.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ func CreateBackup(request *msgs.CreateBackrestBackupRequest) msgs.CreateBackrest
8484
return resp
8585
}
8686

87+
if cluster.Spec.UserLabels[util.LABEL_BACKREST] != "true" {
88+
resp.Status.Code = msgs.Error
89+
resp.Status.Msg = clusterName + " does not have pgbackrest enabled"
90+
return resp
91+
}
92+
8793
result := crv1.Pgtask{}
8894

8995
// error if it already exists

apiserver/clusterservice/clusterimpl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ func getClusterParams(request *msgs.CreateClusterRequest, name string, userLabel
795795
spec.RootPassword = request.Password
796796
spec.Replicas = "0"
797797
str := apiserver.Pgo.Cluster.Replicas
798-
log.Debugf("%s is the pgo.yaml replicas setting", apiserver.Pgo.Cluster.Replicas)
798+
log.Debugf("[%s] is Pgo.Cluster.Replicas", str)
799799
if str != "" {
800800
spec.Replicas = str
801801
}

pgo/cmd/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func createCluster(args []string) {
169169

170170
r := new(msgs.CreateClusterRequest)
171171
r.Name = args[0]
172-
r.ReplicaCount = ReplicaCount
172+
r.ReplicaCount = ClusterReplicaCount
173173
r.NodeLabel = NodeLabel
174174
r.Password = Password
175175
r.SecretFrom = SecretFrom

pgo/cmd/create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/spf13/cobra"
2323
)
2424

25+
var ClusterReplicaCount int
2526
var ManagedUser bool
2627
var ContainerResources string
2728
var ReplicaStorageConfig, StorageConfig string
@@ -245,7 +246,7 @@ func init() {
245246
createClusterCmd.Flags().StringVarP(&PoliciesFlag, "policies", "z", "", "The policies to apply when creating a cluster, comma separated.")
246247
createClusterCmd.Flags().StringVarP(&CCPImageTag, "ccp-image-tag", "c", "", "The CCPImageTag to use for cluster creation. If specified, overrides the pgo.yaml setting.")
247248
createClusterCmd.Flags().IntVarP(&Series, "series", "e", 1, "The number of clusters to create in a series.")
248-
createClusterCmd.Flags().IntVarP(&ReplicaCount, "replica-count", "", 0, "The number of replicas to create as part of the cluster.")
249+
createClusterCmd.Flags().IntVarP(&ClusterReplicaCount, "replica-count", "", 0, "The number of replicas to create as part of the cluster.")
249250
createClusterCmd.Flags().StringVarP(&ContainerResources, "resources-config", "r", "", "The name of a container resource configuration in pgo.yaml that holds CPU and memory requests and limits.")
250251

251252
createIngestCmd.Flags().StringVarP(&IngestConfig, "ingest-config", "i", "", "Defines the path of an ingest configuration file.")

0 commit comments

Comments
 (0)