mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-09 17:56:40 +02:00
committed by
Oleksii Kliukin
parent
d34273543e
commit
4acaf27a5d
@@ -11,8 +11,6 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
etcdclient "github.com/coreos/etcd/client"
|
||||
"golang.org/x/net/context"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/pkg/api"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
@@ -38,7 +36,6 @@ var (
|
||||
type Config struct {
|
||||
KubeClient *kubernetes.Clientset //TODO: move clients to the better place?
|
||||
RestClient *rest.RESTClient
|
||||
EtcdClient etcdclient.KeysAPI
|
||||
TeamsAPIClient *teams.API
|
||||
OpConfig config.Config
|
||||
InfrastructureRoles map[string]spec.PgUser // inherited from the controller
|
||||
@@ -146,22 +143,6 @@ func (c *Cluster) initUsers() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) etcdKeyExists(keyName string) (bool, error) {
|
||||
options := etcdclient.GetOptions{}
|
||||
resp, err := c.EtcdClient.Get(context.Background(), keyName, &options)
|
||||
if err != nil {
|
||||
etcdErr, ok := err.(etcdclient.Error)
|
||||
if !ok {
|
||||
return false, err
|
||||
}
|
||||
if etcdErr.Code == etcdclient.ErrorCodeKeyNotFound {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
return resp != nil, err
|
||||
}
|
||||
|
||||
func (c *Cluster) Create(stopCh <-chan struct{}) error {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
@@ -182,13 +163,6 @@ func (c *Cluster) Create(stopCh <-chan struct{}) error {
|
||||
|
||||
c.setStatus(spec.ClusterStatusCreating)
|
||||
|
||||
keyExist, err := c.etcdKeyExists(fmt.Sprintf("/%s/%s", c.OpConfig.EtcdScope, c.Metadata.Name))
|
||||
if err != nil {
|
||||
c.logger.Warnf("Can't check etcd key: %s", err)
|
||||
}
|
||||
if keyExist {
|
||||
c.logger.Warnf("Etcd key for the cluster already exists")
|
||||
}
|
||||
//TODO: service will create endpoint implicitly
|
||||
ep, err := c.createEndpoint()
|
||||
if err != nil {
|
||||
|
||||
+1
-1
@@ -1,11 +1,11 @@
|
||||
package cluster
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
"k8s.io/client-go/pkg/api/v1"
|
||||
"k8s.io/client-go/pkg/apis/apps/v1beta1"
|
||||
"k8s.io/client-go/pkg/labels"
|
||||
|
||||
Reference in New Issue
Block a user