Fix TestServiceAlloc test

This commit is contained in:
Wojciech Tyczynski
2016-11-10 15:34:08 +01:00
parent d5014c3f21
commit 03b9be982f
3 changed files with 59 additions and 23 deletions

View File

@@ -45,6 +45,7 @@ import (
// loops, which manage creating the "kubernetes" service, the "default" and "kube-system"
// namespace, and provide the IP repair check on service IPs
type Controller struct {
ServiceClient coreclient.ServicesGetter
NamespaceRegistry namespace.Registry
ServiceRegistry service.Registry
@@ -75,8 +76,9 @@ type Controller struct {
}
// NewBootstrapController returns a controller for watching the core capabilities of the master
func (c *Config) NewBootstrapController(legacyRESTStorage corerest.LegacyRESTStorage) *Controller {
func (c *Config) NewBootstrapController(legacyRESTStorage corerest.LegacyRESTStorage, serviceClient coreclient.ServicesGetter) *Controller {
return &Controller{
ServiceClient: serviceClient,
NamespaceRegistry: legacyRESTStorage.NamespaceRegistry,
ServiceRegistry: legacyRESTStorage.ServiceRegistry,
@@ -240,12 +242,12 @@ func createEndpointPortSpec(endpointPort int, endpointPortName string, extraEndp
// doesn't already exist.
func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, serviceIP net.IP, servicePorts []api.ServicePort, serviceType api.ServiceType, reconcile bool) error {
ctx := api.NewDefaultContext()
if s, err := c.ServiceRegistry.GetService(ctx, serviceName); err == nil {
if s, err := c.ServiceClient.Services(api.NamespaceDefault).Get(serviceName); err == nil {
// The service already exists.
if reconcile {
if svc, updated := getMasterServiceUpdateIfNeeded(s, servicePorts, serviceType); updated {
glog.Warningf("Resetting master service %q to %#v", serviceName, svc)
_, err := c.ServiceRegistry.UpdateService(ctx, svc)
_, err := c.ServiceClient.Services(api.NamespaceDefault).Update(svc)
return err
}
}
@@ -270,7 +272,7 @@ func (c *Controller) CreateOrUpdateMasterServiceIfNeeded(serviceName string, ser
return err
}
_, err := c.ServiceRegistry.CreateService(ctx, svc)
_, err := c.ServiceClient.Services(api.NamespaceDefault).Create(svc)
if err != nil && errors.IsAlreadyExists(err) {
err = nil
}