mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 06:01:50 +00:00
Services and Endpoints weren't properly sync'ing
They need incremental changes and a resync on start.
This commit is contained in:
@@ -65,12 +65,17 @@ type ReplicationControllerInterface interface {
|
||||
|
||||
// ServiceInterface has methods to work with Service resources.
|
||||
type ServiceInterface interface {
|
||||
ListServices(selector labels.Selector) (api.ServiceList, error)
|
||||
GetService(id string) (api.Service, error)
|
||||
CreateService(api.Service) (api.Service, error)
|
||||
UpdateService(api.Service) (api.Service, error)
|
||||
DeleteService(string) error
|
||||
WatchServices(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
|
||||
}
|
||||
|
||||
// EndpointsInterface has methods to work with Endpoints resources
|
||||
type EndpointsInterface interface {
|
||||
ListEndpoints(selector labels.Selector) (api.EndpointsList, error)
|
||||
WatchEndpoints(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error)
|
||||
}
|
||||
|
||||
@@ -318,8 +323,9 @@ func (c *Client) WatchReplicationControllers(label, field labels.Selector, resou
|
||||
Watch()
|
||||
}
|
||||
|
||||
func (c *Client) ListServices(selector labels.Selector) (list api.ServiceList, err error) {
|
||||
err = c.Get().Path("services").SelectorParam("labels", selector).Do().Into(&list)
|
||||
// ListServices takes a selector, and returns the list of services that match that selector
|
||||
func (c *Client) ListServices(selector labels.Selector) (result api.ServiceList, err error) {
|
||||
err = c.Get().Path("services").SelectorParam("labels", selector).Do().Into(&result)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -361,6 +367,12 @@ func (c *Client) WatchServices(label, field labels.Selector, resourceVersion uin
|
||||
Watch()
|
||||
}
|
||||
|
||||
// ListEndpoints takes a selector, and returns the list of endpoints that match that selector
|
||||
func (c *Client) ListEndpoints(selector labels.Selector) (result api.EndpointsList, err error) {
|
||||
err = c.Get().Path("endpoints").SelectorParam("labels", selector).Do().Into(&result)
|
||||
return
|
||||
}
|
||||
|
||||
// WatchEndpoints returns a watch.Interface that watches the requested endpoints for a service.
|
||||
func (c *Client) WatchEndpoints(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
|
||||
return c.Get().
|
||||
|
@@ -32,10 +32,13 @@ type FakeAction struct {
|
||||
// implementation. This makes faking out just the method you want to test easier.
|
||||
type Fake struct {
|
||||
// Fake by default keeps a simple list of the methods that have been called.
|
||||
Actions []FakeAction
|
||||
Pods api.PodList
|
||||
Ctrl api.ReplicationController
|
||||
Watch watch.Interface
|
||||
Actions []FakeAction
|
||||
Pods api.PodList
|
||||
Ctrl api.ReplicationController
|
||||
ServiceList api.ServiceList
|
||||
EndpointsList api.EndpointsList
|
||||
Err error
|
||||
Watch watch.Interface
|
||||
}
|
||||
|
||||
func (c *Fake) ListPods(selector labels.Selector) (api.PodList, error) {
|
||||
@@ -93,6 +96,11 @@ func (c *Fake) WatchReplicationControllers(label, field labels.Selector, resourc
|
||||
return c.Watch, nil
|
||||
}
|
||||
|
||||
func (c *Fake) ListServices(selector labels.Selector) (api.ServiceList, error) {
|
||||
c.Actions = append(c.Actions, FakeAction{Action: "list-services"})
|
||||
return c.ServiceList, c.Err
|
||||
}
|
||||
|
||||
func (c *Fake) GetService(name string) (api.Service, error) {
|
||||
c.Actions = append(c.Actions, FakeAction{Action: "get-service", Value: name})
|
||||
return api.Service{}, nil
|
||||
@@ -115,12 +123,17 @@ func (c *Fake) DeleteService(service string) error {
|
||||
|
||||
func (c *Fake) WatchServices(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
|
||||
c.Actions = append(c.Actions, FakeAction{Action: "watch-services", Value: resourceVersion})
|
||||
return c.Watch, nil
|
||||
return c.Watch, c.Err
|
||||
}
|
||||
|
||||
func (c *Fake) ListEndpoints(selector labels.Selector) (api.EndpointsList, error) {
|
||||
c.Actions = append(c.Actions, FakeAction{Action: "list-endpoints"})
|
||||
return c.EndpointsList, c.Err
|
||||
}
|
||||
|
||||
func (c *Fake) WatchEndpoints(label, field labels.Selector, resourceVersion uint64) (watch.Interface, error) {
|
||||
c.Actions = append(c.Actions, FakeAction{Action: "watch-endpoints", Value: resourceVersion})
|
||||
return c.Watch, nil
|
||||
return c.Watch, c.Err
|
||||
}
|
||||
|
||||
func (c *Fake) ServerVersion() (*version.Info, error) {
|
||||
|
Reference in New Issue
Block a user