@@ -55,6 +55,8 @@ func (c *PodController) watchPods(ctx context.Context) (cache.Controller, error)
55
55
c .Namespace ,
56
56
fields .Everything ())
57
57
58
+ //labelSelector := labels.Set(map[string]string{"pg-cluster": "ourdaomain1"}).AsSelector()
59
+
58
60
_ , controller := cache .NewInformer (
59
61
source ,
60
62
@@ -83,10 +85,36 @@ func (c *PodController) onAdd(obj interface{}) {
83
85
84
86
// onUpdate is called when a pgcluster is updated
85
87
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)
86
92
}
87
93
88
94
// onDelete is called when a pgcluster is deleted
89
95
func (c * PodController ) onDelete (obj interface {}) {
90
96
pod := obj .(* apiv1.Pod )
91
97
log .Infof ("[PodCONTROLLER] OnDelete %s\n " , pod .ObjectMeta .SelfLink )
92
98
}
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
+ }
0 commit comments