Fix TestServiceAlloc test
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user