diff --git a/pkg/apiaddresses/controller.go b/pkg/apiaddresses/controller.go index b1671761ad..ed4d3705dd 100644 --- a/pkg/apiaddresses/controller.go +++ b/pkg/apiaddresses/controller.go @@ -44,23 +44,17 @@ type handler struct { // This controller will update the version.program/apiaddresses etcd key with a list of // api addresses endpoints found in the kubernetes service in the default namespace func (h *handler) sync(key string, endpoint *v1.Endpoints) (*v1.Endpoints, error) { - if endpoint == nil { - return nil, nil + if endpoint != nil && + endpoint.Namespace == "default" && + endpoint.Name == "kubernetes" { + w := &bytes.Buffer{} + if err := json.NewEncoder(w).Encode(util.GetAddresses(endpoint)); err != nil { + return nil, err + } + _, err := h.etcdClient.Put(h.ctx, etcd.AddressKey, w.String()) + if err != nil { + return nil, err + } } - - if endpoint.Namespace != "default" && endpoint.Name != "kubernetes" { - return nil, nil - } - - w := &bytes.Buffer{} - if err := json.NewEncoder(w).Encode(util.GetAddresses(endpoint)); err != nil { - return nil, err - } - - _, err := h.etcdClient.Put(h.ctx, etcd.AddressKey, w.String()) - if err != nil { - return nil, err - } - return endpoint, nil }