Skip to content

Commit ba099b1

Browse files
author
Jeff McCormick
authored
add backrest command label to all backrest-jobs to assist in backup job cleanup (CrunchyData#796)
1 parent ae8e141 commit ba099b1

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

apiserver/backrestservice/backrestimpl.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ func CreateBackup(request *msgs.CreateBackrestBackupRequest, ns string) msgs.Cre
134134

135135
//remove any previous backup job
136136

137-
selector := config.LABEL_PG_CLUSTER + "=" + clusterName + "," + config.LABEL_BACKREST + "=true"
137+
//selector := config.LABEL_PG_CLUSTER + "=" + clusterName + "," + config.LABEL_BACKREST + "=true"
138+
selector := config.LABEL_BACKREST_COMMAND + "=" + crv1.PgtaskBackrestBackup + "," + config.LABEL_PG_CLUSTER + "=" + clusterName + "," + config.LABEL_BACKREST + "=true"
138139
err = kubeapi.DeleteJobs(apiserver.Clientset, selector, ns)
139140
if err != nil {
140141
log.Error(err)
@@ -366,17 +367,17 @@ func getInfo(clusterName, storageType, podname, ns string) (string, error) {
366367
cmd = append(cmd, backrestInfoCommand)
367368

368369
log.Debugf("command is %v ", cmd)
369-
370+
370371
var output string
371-
if storageType != "s3" {
372+
if storageType != "s3" {
372373
outputLocal, stderr, err := kubeapi.ExecToPodThroughAPI(apiserver.RESTConfig, apiserver.Clientset, cmd, containername, podname, ns, nil)
373374
if err != nil {
374375
log.Error(err, stderr)
375376
return "", err
376377
}
377378
output = "\nStorage Type: local\n" + outputLocal
378379
}
379-
380+
380381
if strings.Contains(storageType, "s3") {
381382
cmd = append(cmd, repoTypeFlagS3)
382383
outputS3, stderr, err := kubeapi.ExecToPodThroughAPI(apiserver.RESTConfig, apiserver.Clientset, cmd, containername, podname, ns, nil)
@@ -385,7 +386,7 @@ func getInfo(clusterName, storageType, podname, ns string) (string, error) {
385386
return "", err
386387
}
387388
output = output + "\nStorage Type: s3\n" + outputS3
388-
}
389+
}
389390

390391
log.Debug("output=[" + output + "]")
391392

conf/postgres-operator/backrest-job.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"vendor": "crunchydata",
88
"pgo-backrest": "true",
99
"pgo-backrest-job": "true",
10+
"backrest-command": "{{.Command}}",
1011
"pg-cluster": "{{.ClusterName}}"
1112
}
1213
},
@@ -19,6 +20,7 @@
1920
"vendor": "crunchydata",
2021
"pgo-backrest": "true",
2122
"pgo-backrest-job": "true",
23+
"backrest-command": "{{.Command}}",
2224
"pg-cluster": "{{.ClusterName}}"
2325
}
2426
},

conf/postgres-operator/pgo.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Cluster:
44
CCPImagePrefix: crunchydata
55
Metrics: false
66
Badger: false
7-
CCPImageTag: rhel7-11.3-2.4.0-rc10
7+
CCPImageTag: centos7-11.3-2.4.0-rc10
88
Port: 5432
99
User: testuser
1010
Database: userdb
@@ -24,10 +24,10 @@ Cluster:
2424
AutofailReplaceReplica: false
2525
LogStatement: none
2626
LogMinDurationStatement: 60000
27-
PrimaryStorage: hostpathstorage
28-
BackupStorage: hostpathstorage
29-
ReplicaStorage: hostpathstorage
30-
BackrestStorage: hostpathstorage
27+
PrimaryStorage: storageos
28+
BackupStorage: storageos
29+
ReplicaStorage: storageos
30+
BackrestStorage: storageos
3131
Storage:
3232
hostpathstorage:
3333
AccessMode: ReadWriteMany
@@ -101,5 +101,5 @@ Pgo:
101101
PreferredFailoverNode:
102102
Audit: false
103103
PGOImagePrefix: crunchydata
104-
PGOImageTag: rhel7-4.0.0-rc13
104+
PGOImageTag: centos7-4.0.0-rc13
105105

0 commit comments

Comments
 (0)