Unverified Commit c9a11a3c authored by Hussein Galal's avatar Hussein Galal Committed by GitHub

[release-1.20] Fix condition for adding kubernetes endpoints (#3947)

* Fix condition for adding kubernetes endpoints (#3941) * Fix condition for adding kubernetes endpoints Signed-off-by: 's avatargalal-hussein <hussein.galal.ahmed.11@gmail.com> * Fix condition for adding kubernetes endpoints Signed-off-by: 's avatargalal-hussein <hussein.galal.ahmed.11@gmail.com> * fix get addresses Signed-off-by: 's avatargalal-hussein <hussein.galal.ahmed.11@gmail.com>
parent 5ff22d0e
...@@ -45,22 +45,17 @@ type handler struct { ...@@ -45,22 +45,17 @@ type handler struct {
// This controller will update the version.program/apiaddresses etcd key with a list of // 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 // api addresses endpoints found in the kubernetes service in the default namespace
func (h *handler) sync(key string, endpoint *v1.Endpoints) (*v1.Endpoints, error) { func (h *handler) sync(key string, endpoint *v1.Endpoints) (*v1.Endpoints, error) {
if endpoint == nil { if endpoint != nil &&
return nil, nil endpoint.Namespace == "default" &&
} endpoint.Name == "kubernetes" {
w := &bytes.Buffer{}
if endpoint.Namespace != "default" && endpoint.Name != "kubernetes" { if err := json.NewEncoder(w).Encode(getAddresses(endpoint)); err != nil {
return nil, nil return nil, err
} }
_, err := h.etcdClient.Put(h.ctx, etcd.AddressKey, w.String())
w := &bytes.Buffer{} if err != nil {
if err := json.NewEncoder(w).Encode(getAddresses(endpoint)); err != nil { return nil, err
return nil, err }
}
_, err := h.etcdClient.Put(h.ctx, etcd.AddressKey, w.String())
if err != nil {
return nil, err
} }
return endpoint, nil return endpoint, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment