mirror of https://github.com/portainer/portainer
update logic to purge the cache, update the message when the environment can't be reached (#10298)
parent
4c16594a25
commit
291625959b
|
@ -89,6 +89,8 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) *
|
||||||
return httperror.InternalServerError("Unable to find an environment with the specified identifier inside the database", err)
|
return httperror.InternalServerError("Unable to find an environment with the specified identifier inside the database", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateEndpointProxy := shouldReloadTLSConfiguration(endpoint, &payload)
|
||||||
|
|
||||||
if payload.Name != nil {
|
if payload.Name != nil {
|
||||||
name := *payload.Name
|
name := *payload.Name
|
||||||
isUnique, err := handler.isNameUnique(name, endpoint.ID)
|
isUnique, err := handler.isNameUnique(name, endpoint.ID)
|
||||||
|
@ -104,8 +106,9 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) *
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if payload.URL != nil {
|
if payload.URL != nil && *payload.URL != endpoint.URL {
|
||||||
endpoint.URL = *payload.URL
|
endpoint.URL = *payload.URL
|
||||||
|
updateEndpointProxy = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if payload.PublicURL != nil {
|
if payload.PublicURL != nil {
|
||||||
|
@ -179,6 +182,8 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) *
|
||||||
}
|
}
|
||||||
|
|
||||||
if endpoint.Type == portainer.AzureEnvironment {
|
if endpoint.Type == portainer.AzureEnvironment {
|
||||||
|
updateEndpointProxy = true
|
||||||
|
|
||||||
credentials := endpoint.AzureCredentials
|
credentials := endpoint.AzureCredentials
|
||||||
if payload.AzureApplicationID != nil {
|
if payload.AzureApplicationID != nil {
|
||||||
credentials.ApplicationID = *payload.AzureApplicationID
|
credentials.ApplicationID = *payload.AzureApplicationID
|
||||||
|
@ -247,10 +252,7 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (payload.URL != nil && *payload.URL != endpoint.URL) ||
|
if updateEndpointProxy {
|
||||||
(payload.TLS != nil && endpoint.TLSConfig.TLS != *payload.TLS) ||
|
|
||||||
endpoint.Type == portainer.AzureEnvironment ||
|
|
||||||
shouldReloadTLSConfiguration(endpoint, &payload) {
|
|
||||||
handler.ProxyManager.DeleteEndpointProxy(endpoint.ID)
|
handler.ProxyManager.DeleteEndpointProxy(endpoint.ID)
|
||||||
_, err = handler.ProxyManager.CreateAndRegisterEndpointProxy(endpoint)
|
_, err = handler.ProxyManager.CreateAndRegisterEndpointProxy(endpoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -291,6 +293,12 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) *
|
||||||
}
|
}
|
||||||
|
|
||||||
func shouldReloadTLSConfiguration(endpoint *portainer.Endpoint, payload *endpointUpdatePayload) bool {
|
func shouldReloadTLSConfiguration(endpoint *portainer.Endpoint, payload *endpointUpdatePayload) bool {
|
||||||
|
|
||||||
|
// If we change anything in the tls config then we need to reload the proxy
|
||||||
|
if payload.TLS != nil && endpoint.TLSConfig.TLS != *payload.TLS {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// When updating Docker API environment, as long as TLS is true and TLSSkipVerify is false,
|
// When updating Docker API environment, as long as TLS is true and TLSSkipVerify is false,
|
||||||
// we assume that new TLS files have been uploaded and we need to reload the TLS configuration.
|
// we assume that new TLS files have been uploaded and we need to reload the TLS configuration.
|
||||||
if endpoint.Type != portainer.DockerEnvironment ||
|
if endpoint.Type != portainer.DockerEnvironment ||
|
||||||
|
|
|
@ -34,7 +34,7 @@ angular.module('portainer.docker', ['portainer.app', reactModule]).config([
|
||||||
endpoint.Status = status;
|
endpoint.Status = status;
|
||||||
|
|
||||||
if (status === EnvironmentStatus.Down) {
|
if (status === EnvironmentStatus.Down) {
|
||||||
throw new Error('Environment is unreachable.');
|
throw new Error(`The environment named ${endpoint.Name} is unreachable.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await StateManager.updateEndpointState(endpoint);
|
await StateManager.updateEndpointState(endpoint);
|
||||||
|
|
|
@ -53,7 +53,7 @@ angular.module('portainer.kubernetes', ['portainer.app', registriesModule, custo
|
||||||
try {
|
try {
|
||||||
await getSelfSubjectAccessReview(endpoint.Id, 'default');
|
await getSelfSubjectAccessReview(endpoint.Id, 'default');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('Environment is unreachable.');
|
throw new Error(`The environment named ${endpoint.Name} is unreachable.`);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
let params = {};
|
let params = {};
|
||||||
|
|
Loading…
Reference in New Issue