Skip to content

Commit 10553c1

Browse files
author
Jeff McCormick
committed
fix pgo delete cluster command to not delete pods while deletion of deployment is inprogress
1 parent da543ba commit 10553c1

File tree

4 files changed

+127
-13
lines changed

4 files changed

+127
-13
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: storage.k8s.io/v1beta1
2+
kind: StorageClass
3+
metadata:
4+
name: gluster-heketi
5+
provisioner: kubernetes.io/glusterfs
6+
parameters:
7+
resturl: "http://gluster1:8080"
8+
restuser: "user"
9+
restuserkey: "My Secret"

examples/gluster/test-pvc.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"apiVersion": "v1",
3+
"kind": "PersistentVolumeClaim",
4+
"metadata": {
5+
"annotations": {
6+
"volume.beta.kubernetes.io/storage-class": "gluster-heketi"
7+
},
8+
"name": "test-pvc"
9+
},
10+
"spec": {
11+
"accessModes": [
12+
"ReadWriteOnce"
13+
],
14+
"resources": {
15+
"requests": {
16+
"storage": "400M"
17+
}
18+
}
19+
}
20+
}

golang-examples/config.go

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
log "github.com/Sirupsen/logrus"
6+
"io/ioutil"
7+
"os"
8+
)
9+
10+
type ContainerResource struct {
11+
Name string `json:"Name"`
12+
RequestsMemory string `json:"RequestsMemory"`
13+
RequestsCPU float64 `json:"RequestsCPU"`
14+
LimitsMemory string `json:"LimitsMemory"`
15+
LimitsCPU float64 `json:"LimitsCPU"`
16+
}
17+
18+
type Cluster struct {
19+
CCPImagePrefix string `json:"CCPImagePrefix"`
20+
CCPImageTag string `json:"CCPImageTag"`
21+
Port int `json:"Port"`
22+
User string `json:"User"`
23+
Database string `json:"Database"`
24+
PasswordAgeDays int `json:"PasswordAgeDays"`
25+
PasswordLength int `json:"PasswordLength"`
26+
Strategy int `json:"Strategy"`
27+
Replicas int `json:"Replicas"`
28+
}
29+
30+
type Storage struct {
31+
Name string `json:"Name"`
32+
AccessMode string `json:"AccessMode"`
33+
Size string `json:"Size"`
34+
StorageType string `json:"StorageType"`
35+
}
36+
type Pgo struct {
37+
Audit bool `json:"Audit"`
38+
Metrics bool `json:"Metrics"`
39+
LSPVCTemplate string `json:"LSPVCTemplate"`
40+
LoadTemplate string `json:"LoadTemplate"`
41+
COImagePrefix string `json:"COImagePrefix"`
42+
COImageTag string `json:"COImageTag"`
43+
}
44+
45+
type PgoConfig struct {
46+
ClusterDef Cluster
47+
PrimaryStorage string `json:"PrimaryStorage"`
48+
BackupStorage string `json:"BackupStorage"`
49+
ReplicaStorage string `json:"ReplicaStorage"`
50+
StorageDef []Storage `json:"Storage"`
51+
DefaultContainerResource string `json:"DefaultContainerResource"`
52+
ContainerResources []ContainerResource `json:"ContainerResources"`
53+
PgoDef Pgo `json:"Pgo"`
54+
}
55+
56+
func main() {
57+
log.Info("hi")
58+
path := "./conf/apiserver/pgo.json"
59+
_, err := ioutil.ReadFile(path)
60+
if err != nil {
61+
log.Error("error loading template path=" + path + err.Error())
62+
panic(err.Error())
63+
}
64+
65+
thisconfig := PgoConfig{}
66+
thisconfig.PrimaryStorage = "storage1"
67+
thisconfig.StorageDef = make([]Storage, 1)
68+
thisconfig.StorageDef[0].Name = "storage1"
69+
thisconfig.StorageDef[0].AccessMode = "ReadWriteMany"
70+
thisconfig.DefaultContainerResource = "res1"
71+
thisconfig.ContainerResources = make([]ContainerResource, 1)
72+
thisconfig.ContainerResources[0].Name = "res1"
73+
thisconfig.ClusterDef = Cluster{}
74+
thisconfig.ClusterDef.Port = 5432
75+
thisconfig.PgoDef.Audit = false
76+
thisconfig.PgoDef.Metrics = false
77+
thisconfig.PgoDef.LSPVCTemplate = "this lspvc template"
78+
thisconfig.PgoDef.LoadTemplate = "loadtempaltepath"
79+
thisconfig.PgoDef.COImagePrefix = "crunchydata"
80+
thisconfig.PgoDef.COImageTag = "centos7-2.6"
81+
82+
//json.Unmarshal(buf, &c)
83+
84+
//log.Info("Pgo.LSPVCTemplate is [" + c.PgoDef.LSPVCTemplate + "]")
85+
86+
//log.Infof("%v\n", c.ContainerResources)
87+
88+
b, err := json.MarshalIndent(thisconfig, "", " ")
89+
if err != nil {
90+
log.Error(err)
91+
} else {
92+
os.Stdout.Write(b)
93+
}
94+
95+
}

operator/cluster/cluster_strategy_1.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,7 @@ func (r Strategy1) DeleteCluster(clientset *kubernetes.Clientset, restclient *re
151151
log.Error("error deleting primary Deployment " + err.Error())
152152
}
153153

154-
//delete any remaining pods that may be left lingering
155-
pods, err := kubeapi.GetPods(clientset, "pg-cluster="+cl.Spec.Name,
156-
namespace)
157-
for _, pod := range pods.Items {
158-
err = kubeapi.DeletePod(clientset, pod.Name, namespace)
159-
}
160-
pods, err = kubeapi.GetPods(clientset,
161-
"name="+cl.Spec.Name+ReplicaSuffix, namespace)
162-
for _, pod := range pods.Items {
163-
err = kubeapi.DeletePod(clientset, pod.Name, namespace)
164-
}
165-
166154
//delete the primary service
167-
168155
kubeapi.DeleteService(clientset, cl.Spec.Name, namespace)
169156

170157
//delete the replica service
@@ -178,6 +165,9 @@ func (r Strategy1) DeleteCluster(clientset *kubernetes.Clientset, restclient *re
178165
//delete the pgreplicas if necessary
179166
DeletePgreplicas(restclient, cl.Spec.Name, namespace)
180167

168+
//delete the pgbackups if necessary
169+
kubeapi.Deletepgbackup(restclient, cl.Spec.Name, namespace)
170+
181171
return err
182172

183173
}

0 commit comments

Comments
 (0)