Skip to content

Commit 67e681f

Browse files
committed
2 parents a63063c + 9c2a722 commit 67e681f

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

controller/podcontroller.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ func (c *PodController) watchPods(ctx context.Context) (cache.Controller, error)
5555
c.Namespace,
5656
fields.Everything())
5757

58+
//labelSelector := labels.Set(map[string]string{"pg-cluster": "ourdaomain1"}).AsSelector()
59+
5860
_, controller := cache.NewInformer(
5961
source,
6062

@@ -83,10 +85,36 @@ func (c *PodController) onAdd(obj interface{}) {
8385

8486
// onUpdate is called when a pgcluster is updated
8587
func (c *PodController) onUpdate(oldObj, newObj interface{}) {
88+
//oldpod := oldObj.(*apiv1.Pod)
89+
////newpod := newObj.(*apiv1.Pod)
90+
//checkReadyStatus(oldpod, newpod)
91+
//log.Infof("[PodCONTROLLER] OnUpdate %s\n", newpod.ObjectMeta.SelfLink)
8692
}
8793

8894
// onDelete is called when a pgcluster is deleted
8995
func (c *PodController) onDelete(obj interface{}) {
9096
pod := obj.(*apiv1.Pod)
9197
log.Infof("[PodCONTROLLER] OnDelete %s\n", pod.ObjectMeta.SelfLink)
9298
}
99+
100+
func checkReadyStatus(oldpod, newpod *apiv1.Pod) {
101+
//if the pod has a metadata label of pg-cluster and
102+
//eventually pg-failover == true then...
103+
//loop thru status.containerStatuses, find the container with name='database'
104+
//print out the 'ready' bool
105+
log.Infof("%v is the ObjectMeta Labels\n", newpod.ObjectMeta.Labels)
106+
if newpod.ObjectMeta.Labels["pg-cluster"] != "" {
107+
log.Infoln("we have a pg-cluster!")
108+
for _, v := range newpod.Status.ContainerStatuses {
109+
if v.Name == "database" {
110+
log.Infof("%s is the containerstatus Name\n", v.Name)
111+
if v.Ready {
112+
log.Infof("%v is the Ready status for cluster %s container %s container\n", v.Ready, newpod.ObjectMeta.Name, v.Name)
113+
} else {
114+
log.Infof("%v is the Ready status for cluster %s container %s container\n", v.Ready, newpod.ObjectMeta.Name, v.Name)
115+
}
116+
}
117+
}
118+
}
119+
120+
}

operator/cluster/cluster_strategy_1.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ func getPrimaryLabels(Name string, ClusterName string, replicaFlag bool, userLab
345345
primaryLabels["pg-cluster"] = ClusterName
346346

347347
for key, value := range userLabels {
348-
primaryLabels[key] = value
348+
if key == "NodeLabelKey" || key == "NodeLabelValue" {
349+
//dont add these types
350+
} else {
351+
primaryLabels[key] = value
352+
}
349353
}
350354
return primaryLabels
351355
}

0 commit comments

Comments
 (0)