remove etcd requests from the operator
This commit is contained in:
		
							parent
							
								
									d34273543e
								
							
						
					
					
						commit
						56964fd99c
					
				|  | @ -11,8 +11,6 @@ import ( | ||||||
| 	"sync" | 	"sync" | ||||||
| 
 | 
 | ||||||
| 	"github.com/Sirupsen/logrus" | 	"github.com/Sirupsen/logrus" | ||||||
| 	etcdclient "github.com/coreos/etcd/client" |  | ||||||
| 	"golang.org/x/net/context" |  | ||||||
| 	"k8s.io/client-go/kubernetes" | 	"k8s.io/client-go/kubernetes" | ||||||
| 	"k8s.io/client-go/pkg/api" | 	"k8s.io/client-go/pkg/api" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
|  | @ -38,7 +36,6 @@ var ( | ||||||
| type Config struct { | type Config struct { | ||||||
| 	KubeClient          *kubernetes.Clientset //TODO: move clients to the better place?
 | 	KubeClient          *kubernetes.Clientset //TODO: move clients to the better place?
 | ||||||
| 	RestClient          *rest.RESTClient | 	RestClient          *rest.RESTClient | ||||||
| 	EtcdClient          etcdclient.KeysAPI |  | ||||||
| 	TeamsAPIClient      *teams.API | 	TeamsAPIClient      *teams.API | ||||||
| 	OpConfig            config.Config | 	OpConfig            config.Config | ||||||
| 	InfrastructureRoles map[string]spec.PgUser // inherited from the controller
 | 	InfrastructureRoles map[string]spec.PgUser // inherited from the controller
 | ||||||
|  | @ -146,22 +143,6 @@ func (c *Cluster) initUsers() error { | ||||||
| 	return nil | 	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 { | func (c *Cluster) Create(stopCh <-chan struct{}) error { | ||||||
| 	c.mu.Lock() | 	c.mu.Lock() | ||||||
| 	defer c.mu.Unlock() | 	defer c.mu.Unlock() | ||||||
|  | @ -182,13 +163,6 @@ func (c *Cluster) Create(stopCh <-chan struct{}) error { | ||||||
| 
 | 
 | ||||||
| 	c.setStatus(spec.ClusterStatusCreating) | 	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
 | 	//TODO: service will create endpoint implicitly
 | ||||||
| 	ep, err := c.createEndpoint() | 	ep, err := c.createEndpoint() | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  |  | ||||||
|  | @ -1,11 +1,11 @@ | ||||||
| package cluster | package cluster | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
|  | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" | 	"time" | ||||||
| 
 | 
 | ||||||
| 	"k8s.io/apimachinery/pkg/util/json" |  | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | ||||||
| 	"k8s.io/client-go/pkg/labels" | 	"k8s.io/client-go/pkg/labels" | ||||||
|  |  | ||||||
|  | @ -5,7 +5,6 @@ import ( | ||||||
| 	"sync" | 	"sync" | ||||||
| 
 | 
 | ||||||
| 	"github.com/Sirupsen/logrus" | 	"github.com/Sirupsen/logrus" | ||||||
| 	etcdclient "github.com/coreos/etcd/client" |  | ||||||
| 	"k8s.io/client-go/kubernetes" | 	"k8s.io/client-go/kubernetes" | ||||||
| 	"k8s.io/client-go/pkg/api/v1" | 	"k8s.io/client-go/pkg/api/v1" | ||||||
| 	"k8s.io/client-go/rest" | 	"k8s.io/client-go/rest" | ||||||
|  | @ -21,7 +20,6 @@ type Config struct { | ||||||
| 	RestConfig          *rest.Config | 	RestConfig          *rest.Config | ||||||
| 	KubeClient          *kubernetes.Clientset | 	KubeClient          *kubernetes.Clientset | ||||||
| 	RestClient          *rest.RESTClient | 	RestClient          *rest.RESTClient | ||||||
| 	EtcdClient          etcdclient.KeysAPI |  | ||||||
| 	TeamsAPIClient      *teams.API | 	TeamsAPIClient      *teams.API | ||||||
| 	InfrastructureRoles map[string]spec.PgUser | 	InfrastructureRoles map[string]spec.PgUser | ||||||
| } | } | ||||||
|  | @ -122,10 +120,6 @@ func (c *Controller) initController() { | ||||||
| 		DeleteFunc: c.podDelete, | 		DeleteFunc: c.podDelete, | ||||||
| 	}) | 	}) | ||||||
| 
 | 
 | ||||||
| 	if err := c.initEtcdClient(c.opConfig.EtcdHost); err != nil { |  | ||||||
| 		c.logger.Fatalf("Can't get etcd client: %s", err) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	c.clusterEventQueues = make([]*cache.FIFO, c.opConfig.Workers) | 	c.clusterEventQueues = make([]*cache.FIFO, c.opConfig.Workers) | ||||||
| 	for i := range c.clusterEventQueues { | 	for i := range c.clusterEventQueues { | ||||||
| 		c.clusterEventQueues[i] = cache.NewFIFO(func(obj interface{}) (string, error) { | 		c.clusterEventQueues[i] = cache.NewFIFO(func(obj interface{}) (string, error) { | ||||||
|  |  | ||||||
|  | @ -1,25 +0,0 @@ | ||||||
| package controller |  | ||||||
| 
 |  | ||||||
| import ( |  | ||||||
| 	"fmt" |  | ||||||
| 	"time" |  | ||||||
| 
 |  | ||||||
| 	etcdclient "github.com/coreos/etcd/client" |  | ||||||
| ) |  | ||||||
| 
 |  | ||||||
| func (c *Controller) initEtcdClient(etcdHost string) error { |  | ||||||
| 	etcdURL := fmt.Sprintf("http://%s", etcdHost) |  | ||||||
| 
 |  | ||||||
| 	cfg, err := etcdclient.New(etcdclient.Config{ |  | ||||||
| 		Endpoints:               []string{etcdURL}, |  | ||||||
| 		Transport:               etcdclient.DefaultTransport, |  | ||||||
| 		HeaderTimeoutPerRequest: time.Second, |  | ||||||
| 	}) |  | ||||||
| 	if err != nil { |  | ||||||
| 		return err |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	c.EtcdClient = etcdclient.NewKeysAPI(cfg) |  | ||||||
| 
 |  | ||||||
| 	return nil |  | ||||||
| } |  | ||||||
|  | @ -23,7 +23,6 @@ func (c *Controller) makeClusterConfig() cluster.Config { | ||||||
| 	return cluster.Config{ | 	return cluster.Config{ | ||||||
| 		KubeClient:          c.KubeClient, | 		KubeClient:          c.KubeClient, | ||||||
| 		RestClient:          c.RestClient, | 		RestClient:          c.RestClient, | ||||||
| 		EtcdClient:          c.EtcdClient, |  | ||||||
| 		TeamsAPIClient:      c.TeamsAPIClient, | 		TeamsAPIClient:      c.TeamsAPIClient, | ||||||
| 		OpConfig:            config.Copy(c.opConfig), | 		OpConfig:            config.Copy(c.opConfig), | ||||||
| 		InfrastructureRoles: infrastructureRoles, | 		InfrastructureRoles: infrastructureRoles, | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue