proper name
This commit is contained in:
parent
82917313f5
commit
734489eb77
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (z *PgZooKeeper) DeleteEtcdKey(clusterName string) error {
|
func (z *SpiloZooKeeper) DeleteEtcdKey(clusterName string) error {
|
||||||
options := client.DeleteOptions{
|
options := client.DeleteOptions{
|
||||||
Recursive: true,
|
Recursive: true,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (z *PgZooKeeper) CreateStatefulSet(spilo *Spilo) {
|
func (z *SpiloZooKeeper) CreateStatefulSet(spilo *Spilo) {
|
||||||
ns := (*spilo).Metadata.Namespace
|
ns := (*spilo).Metadata.Namespace
|
||||||
|
|
||||||
statefulSet := z.createSetFromSpilo(spilo)
|
statefulSet := z.createSetFromSpilo(spilo)
|
||||||
|
|
@ -21,7 +21,7 @@ func (z *PgZooKeeper) CreateStatefulSet(spilo *Spilo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) createSetFromSpilo(spilo *Spilo) v1beta1.StatefulSet {
|
func (z *SpiloZooKeeper) createSetFromSpilo(spilo *Spilo) v1beta1.StatefulSet {
|
||||||
clusterName := (*spilo).Metadata.Name
|
clusterName := (*spilo).Metadata.Name
|
||||||
|
|
||||||
envVars := []v1.EnvVar{
|
envVars := []v1.EnvVar{
|
||||||
|
|
@ -166,7 +166,7 @@ func (z *PgZooKeeper) createSetFromSpilo(spilo *Spilo) v1beta1.StatefulSet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) CreateSecrets(ns, name string) {
|
func (z *SpiloZooKeeper) CreateSecrets(ns, name string) {
|
||||||
secret := v1.Secret{
|
secret := v1.Secret{
|
||||||
ObjectMeta: v1.ObjectMeta{
|
ObjectMeta: v1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|
@ -191,7 +191,7 @@ func (z *PgZooKeeper) CreateSecrets(ns, name string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) CreateService(ns, name string) {
|
func (z *SpiloZooKeeper) CreateService(ns, name string) {
|
||||||
service := v1.Service{
|
service := v1.Service{
|
||||||
ObjectMeta: v1.ObjectMeta{
|
ObjectMeta: v1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|
@ -214,7 +214,7 @@ func (z *PgZooKeeper) CreateService(ns, name string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) CreateEndPoint(ns, name string) {
|
func (z *SpiloZooKeeper) CreateEndPoint(ns, name string) {
|
||||||
endPoint := v1.Endpoints{
|
endPoint := v1.Endpoints{
|
||||||
ObjectMeta: v1.ObjectMeta{
|
ObjectMeta: v1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ type SpiloOperator struct {
|
||||||
ClientSet *kubernetes.Clientset
|
ClientSet *kubernetes.Clientset
|
||||||
SpiloClient *rest.RESTClient
|
SpiloClient *rest.RESTClient
|
||||||
|
|
||||||
SpiloZooKeeper *PgZooKeeper
|
SpiloZooKeeper *SpiloZooKeeper
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(options Options) *SpiloOperator {
|
func New(options Options) *SpiloOperator {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ type podWatcher struct {
|
||||||
subscribe bool
|
subscribe bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type PgZooKeeper struct {
|
type SpiloZooKeeper struct {
|
||||||
podEvents chan podEvent
|
podEvents chan podEvent
|
||||||
podWatchers chan podWatcher
|
podWatchers chan podWatcher
|
||||||
SpiloClient *rest.RESTClient
|
SpiloClient *rest.RESTClient
|
||||||
|
|
@ -49,8 +49,8 @@ func podsListWatch(client *kubernetes.Clientset) *cache.ListWatch {
|
||||||
return cache.NewListWatchFromClient(client.Core().RESTClient(), "pods", api.NamespaceAll, fields.Everything())
|
return cache.NewListWatchFromClient(client.Core().RESTClient(), "pods", api.NamespaceAll, fields.Everything())
|
||||||
}
|
}
|
||||||
|
|
||||||
func newZookeeper(spiloClient *rest.RESTClient, clientset *kubernetes.Clientset) *PgZooKeeper {
|
func newZookeeper(spiloClient *rest.RESTClient, clientset *kubernetes.Clientset) *SpiloZooKeeper {
|
||||||
pgZooKeeper := &PgZooKeeper{
|
spiloZooKeeper := &SpiloZooKeeper{
|
||||||
SpiloClient: spiloClient,
|
SpiloClient: spiloClient,
|
||||||
Clientset: clientset,
|
Clientset: clientset,
|
||||||
}
|
}
|
||||||
|
|
@ -63,9 +63,9 @@ func newZookeeper(spiloClient *rest.RESTClient, clientset *kubernetes.Clientset)
|
||||||
)
|
)
|
||||||
|
|
||||||
spiloInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
|
spiloInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||||
AddFunc: pgZooKeeper.spiloAdd,
|
AddFunc: spiloZooKeeper.spiloAdd,
|
||||||
UpdateFunc: pgZooKeeper.spiloUpdate,
|
UpdateFunc: spiloZooKeeper.spiloUpdate,
|
||||||
DeleteFunc: pgZooKeeper.spiloDelete,
|
DeleteFunc: spiloZooKeeper.spiloDelete,
|
||||||
})
|
})
|
||||||
|
|
||||||
podInformer := cache.NewSharedIndexInformer(
|
podInformer := cache.NewSharedIndexInformer(
|
||||||
|
|
@ -76,13 +76,13 @@ func newZookeeper(spiloClient *rest.RESTClient, clientset *kubernetes.Clientset)
|
||||||
)
|
)
|
||||||
|
|
||||||
podInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
|
podInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||||
AddFunc: pgZooKeeper.podAdd,
|
AddFunc: spiloZooKeeper.podAdd,
|
||||||
UpdateFunc: pgZooKeeper.podUpdate,
|
UpdateFunc: spiloZooKeeper.podUpdate,
|
||||||
DeleteFunc: pgZooKeeper.podDelete,
|
DeleteFunc: spiloZooKeeper.podDelete,
|
||||||
})
|
})
|
||||||
|
|
||||||
pgZooKeeper.spiloInformer = spiloInformer
|
spiloZooKeeper.spiloInformer = spiloInformer
|
||||||
pgZooKeeper.podInformer = podInformer
|
spiloZooKeeper.podInformer = podInformer
|
||||||
|
|
||||||
cfg := etcdclient.Config{
|
cfg := etcdclient.Config{
|
||||||
Endpoints: []string{etcdHostOutside},
|
Endpoints: []string{etcdHostOutside},
|
||||||
|
|
@ -95,13 +95,13 @@ func newZookeeper(spiloClient *rest.RESTClient, clientset *kubernetes.Clientset)
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
pgZooKeeper.etcdApiClient = etcdclient.NewKeysAPI(c)
|
spiloZooKeeper.etcdApiClient = etcdclient.NewKeysAPI(c)
|
||||||
pgZooKeeper.podEvents = make(chan podEvent)
|
spiloZooKeeper.podEvents = make(chan podEvent)
|
||||||
|
|
||||||
return pgZooKeeper
|
return spiloZooKeeper
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *PgZooKeeper) podAdd(obj interface{}) {
|
func (d *SpiloZooKeeper) podAdd(obj interface{}) {
|
||||||
pod := obj.(*v1.Pod)
|
pod := obj.(*v1.Pod)
|
||||||
d.podEvents <- podEvent{
|
d.podEvents <- podEvent{
|
||||||
namespace: pod.Namespace,
|
namespace: pod.Namespace,
|
||||||
|
|
@ -110,7 +110,7 @@ func (d *PgZooKeeper) podAdd(obj interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *PgZooKeeper) podDelete(obj interface{}) {
|
func (d *SpiloZooKeeper) podDelete(obj interface{}) {
|
||||||
pod := obj.(*v1.Pod)
|
pod := obj.(*v1.Pod)
|
||||||
d.podEvents <- podEvent{
|
d.podEvents <- podEvent{
|
||||||
namespace: pod.Namespace,
|
namespace: pod.Namespace,
|
||||||
|
|
@ -119,7 +119,7 @@ func (d *PgZooKeeper) podDelete(obj interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *PgZooKeeper) podUpdate(old, cur interface{}) {
|
func (d *SpiloZooKeeper) podUpdate(old, cur interface{}) {
|
||||||
oldPod := old.(*v1.Pod)
|
oldPod := old.(*v1.Pod)
|
||||||
d.podEvents <- podEvent{
|
d.podEvents <- podEvent{
|
||||||
namespace: oldPod.Namespace,
|
namespace: oldPod.Namespace,
|
||||||
|
|
@ -128,7 +128,7 @@ func (d *PgZooKeeper) podUpdate(old, cur interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
func (z *SpiloZooKeeper) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
|
|
||||||
|
|
@ -143,7 +143,7 @@ func (z *PgZooKeeper) Run(stopCh <-chan struct{}, wg *sync.WaitGroup) {
|
||||||
<-stopCh
|
<-stopCh
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) spiloAdd(obj interface{}) {
|
func (z *SpiloZooKeeper) spiloAdd(obj interface{}) {
|
||||||
spilo := obj.(*Spilo)
|
spilo := obj.(*Spilo)
|
||||||
|
|
||||||
clusterName := (*spilo).Metadata.Name
|
clusterName := (*spilo).Metadata.Name
|
||||||
|
|
@ -155,7 +155,7 @@ func (z *PgZooKeeper) spiloAdd(obj interface{}) {
|
||||||
z.CreateStatefulSet(spilo)
|
z.CreateStatefulSet(spilo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) spiloUpdate(old, cur interface{}) {
|
func (z *SpiloZooKeeper) spiloUpdate(old, cur interface{}) {
|
||||||
oldSpilo := old.(*Spilo)
|
oldSpilo := old.(*Spilo)
|
||||||
curSpilo := cur.(*Spilo)
|
curSpilo := cur.(*Spilo)
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ func (z *PgZooKeeper) spiloUpdate(old, cur interface{}) {
|
||||||
log.Printf("Update spilo old: %+v cur: %+v", *oldSpilo, *curSpilo)
|
log.Printf("Update spilo old: %+v cur: %+v", *oldSpilo, *curSpilo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) spiloDelete(obj interface{}) {
|
func (z *SpiloZooKeeper) spiloDelete(obj interface{}) {
|
||||||
spilo := obj.(*Spilo)
|
spilo := obj.(*Spilo)
|
||||||
|
|
||||||
err := z.DeleteStatefulSet(spilo.Metadata.Namespace, spilo.Metadata.Name)
|
err := z.DeleteStatefulSet(spilo.Metadata.Namespace, spilo.Metadata.Name)
|
||||||
|
|
@ -179,7 +179,7 @@ func (z *PgZooKeeper) spiloDelete(obj interface{}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) DeleteStatefulSet(ns, clusterName string) error {
|
func (z *SpiloZooKeeper) DeleteStatefulSet(ns, clusterName string) error {
|
||||||
orphanDependents := false
|
orphanDependents := false
|
||||||
deleteOptions := v1.DeleteOptions{
|
deleteOptions := v1.DeleteOptions{
|
||||||
OrphanDependents: &orphanDependents,
|
OrphanDependents: &orphanDependents,
|
||||||
|
|
@ -231,7 +231,7 @@ func (z *PgZooKeeper) DeleteStatefulSet(ns, clusterName string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) UpdateStatefulSet(spilo *Spilo) {
|
func (z *SpiloZooKeeper) UpdateStatefulSet(spilo *Spilo) {
|
||||||
ns := (*spilo).Metadata.Namespace
|
ns := (*spilo).Metadata.Namespace
|
||||||
|
|
||||||
statefulSet := z.createSetFromSpilo(spilo)
|
statefulSet := z.createSetFromSpilo(spilo)
|
||||||
|
|
@ -242,7 +242,7 @@ func (z *PgZooKeeper) UpdateStatefulSet(spilo *Spilo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) UpdateStatefulSetImage(spilo *Spilo) {
|
func (z *SpiloZooKeeper) UpdateStatefulSetImage(spilo *Spilo) {
|
||||||
ns := (*spilo).Metadata.Namespace
|
ns := (*spilo).Metadata.Namespace
|
||||||
|
|
||||||
z.UpdateStatefulSet(spilo)
|
z.UpdateStatefulSet(spilo)
|
||||||
|
|
@ -295,7 +295,7 @@ func (z *PgZooKeeper) UpdateStatefulSetImage(spilo *Spilo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (z *PgZooKeeper) podWatcher(stopCh <-chan struct{}) {
|
func (z *SpiloZooKeeper) podWatcher(stopCh <-chan struct{}) {
|
||||||
watchers := make(map[string]chan podEvent)
|
watchers := make(map[string]chan podEvent)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue