Skip to content

Commit 7228e85

Browse files
Jonathan S. Katzjkatz
authored andcommitted
Remove superfluous label on managed PVCs
The label in question (pgremove) was used to indicate that the PVC was managed by PGO, but there are other labels that handle that,
1 parent d407593 commit 7228e85

File tree

6 files changed

+10
-17
lines changed

6 files changed

+10
-17
lines changed

installers/ansible/roles/pgo-operator/files/pgo-configs/pvc-storageclass.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"name": "{{.Name}}",
66
"labels": {
77
"vendor": "crunchydata",
8-
"pgremove": "true",
98
"pg-cluster": "{{.ClusterName}}"
109
}
1110
},

installers/ansible/roles/pgo-operator/files/pgo-configs/pvc.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"name": "{{.Name}}",
66
"labels": {
77
"vendor": "crunchydata",
8-
"pgremove": "true",
98
"pg-cluster": "{{.ClusterName}}"
109
}
1110
},

internal/apiserver/pvcservice/pvcimpl.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ import (
3030
func ShowPVC(allflag bool, clusterName, ns string) ([]msgs.ShowPVCResponseResult, error) {
3131
ctx := context.TODO()
3232
pvcList := []msgs.ShowPVCResponseResult{}
33-
// note to a future editor...all of our managed PVCs have a label called
34-
// called "pgremove"
35-
selector := fmt.Sprintf("%s=%s", config.LABEL_PGREMOVE, "true")
33+
selector := fmt.Sprintf("%s=%s", config.LABEL_VENDOR, config.LABEL_CRUNCHY)
3634

3735
// if allflag is not set to true, then update the selector to target the
3836
// specific PVCs for a specific cluster

internal/apiserver/statusservice/statusimpl.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ func Status(ns string) msgs.StatusResponse {
4646

4747
func getNumClaims(ns string) int {
4848
ctx := context.TODO()
49-
// count number of PVCs with pgremove=true
49+
5050
pvcs, err := apiserver.Clientset.
5151
CoreV1().PersistentVolumeClaims(ns).
52-
List(ctx, metav1.ListOptions{LabelSelector: config.LABEL_PGREMOVE})
52+
List(ctx, metav1.ListOptions{LabelSelector: config.LABEL_VENDOR + "=" + config.LABEL_CRUNCHY})
5353
if err != nil {
5454
log.Error(err)
5555
return 0
@@ -75,7 +75,7 @@ func getVolumeCap(ns string) string {
7575
// sum all PVCs storage capacity
7676
pvcs, err := apiserver.Clientset.
7777
CoreV1().PersistentVolumeClaims(ns).
78-
List(ctx, metav1.ListOptions{LabelSelector: config.LABEL_PGREMOVE})
78+
List(ctx, metav1.ListOptions{LabelSelector: config.LABEL_VENDOR + "=" + config.LABEL_CRUNCHY})
7979
if err != nil {
8080
log.Error(err)
8181
return "error"

internal/config/labels.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const (
3434

3535
const (
3636
LABEL_PGPOLICY = "pgpolicy"
37-
LABEL_PGREMOVE = "pgremove"
3837
LABEL_PVCNAME = "pvcname"
3938
LABEL_EXPORTER = "crunchy-postgres-exporter"
4039
LABEL_ARCHIVE = "archive"

internal/operator/pvc/pvc.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,13 @@ func DeleteIfExists(clientset kubernetes.Interface, name string, namespace strin
198198
}
199199

200200
log.Debugf("PVC %s is found", pvc.Name)
201+
log.Debugf("delete PVC %s in namespace %s", name, namespace)
201202

202-
if pvc.ObjectMeta.Labels[config.LABEL_PGREMOVE] == "true" {
203-
log.Debugf("delete PVC %s in namespace %s", name, namespace)
204-
deletePropagation := metav1.DeletePropagationForeground
205-
err = clientset.
206-
CoreV1().PersistentVolumeClaims(namespace).
207-
Delete(ctx, name, metav1.DeleteOptions{PropagationPolicy: &deletePropagation})
208-
}
209-
return err
203+
deletePropagation := metav1.DeletePropagationForeground
204+
205+
return clientset.
206+
CoreV1().PersistentVolumeClaims(namespace).
207+
Delete(ctx, name, metav1.DeleteOptions{PropagationPolicy: &deletePropagation})
210208
}
211209

212210
// Exists test to see if pvc exists

0 commit comments

Comments
 (0)