diff --git a/api/http/handler/endpoints/endpoint_update.go b/api/http/handler/endpoints/endpoint_update.go index 2b896f7a0..0657fefc7 100644 --- a/api/http/handler/endpoints/endpoint_update.go +++ b/api/http/handler/endpoints/endpoint_update.go @@ -257,6 +257,7 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) * } if payload.URL != nil || payload.TLS != nil || endpoint.Type == portainer.AzureEnvironment { + handler.ProxyManager.DeleteEndpointProxy(endpoint.ID) _, err = handler.ProxyManager.CreateAndRegisterEndpointProxy(endpoint) if err != nil { return &httperror.HandlerError{http.StatusInternalServerError, "Unable to register HTTP proxy for the environment", err} diff --git a/api/http/proxy/manager.go b/api/http/proxy/manager.go index 953493be9..7ec36166b 100644 --- a/api/http/proxy/manager.go +++ b/api/http/proxy/manager.go @@ -63,7 +63,7 @@ func (manager *Manager) GetEndpointProxy(endpoint *portainer.Endpoint) http.Hand // DeleteEndpointProxy deletes the proxy associated to a key // and cleans the k8s environment(endpoint) client cache. DeleteEndpointProxy -// is currently only called for edge connection clean up. +// is currently only called for edge connection clean up and when endpoint is updated func (manager *Manager) DeleteEndpointProxy(endpointID portainer.EndpointID) { manager.endpointProxies.Remove(fmt.Sprint(endpointID)) manager.k8sClientFactory.RemoveKubeClient(endpointID)