diff --git a/Makefile b/Makefile index dafe34f94..7c430f161 100644 --- a/Makefile +++ b/Makefile @@ -114,7 +114,7 @@ dev-extension: build-server build-client ## Run the extension in development mod ##@ Docs .PHONY: docs-build docs-validate docs-clean docs-validate-clean docs-build: init-dist ## Build docs - cd api && $(SWAG) init -o "../dist/docs" -ot "yaml" -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 -p pascalcase --markdownFiles ./ + cd api && $(SWAG) init -o "../dist/docs" -ot "yaml" -g ./http/handler/handler.go --parseDependency --parseInternal --parseDepth 2 --markdownFiles ./ docs-validate: docs-build ## Validate docs yarn swagger2openapi --warnOnly dist/docs/swagger.yaml -o dist/docs/openapi.yaml diff --git a/api/http/handler/customtemplates/customtemplate_create.go b/api/http/handler/customtemplates/customtemplate_create.go index 82254916b..6a584a914 100644 --- a/api/http/handler/customtemplates/customtemplate_create.go +++ b/api/http/handler/customtemplates/customtemplate_create.go @@ -149,7 +149,7 @@ func isValidNote(note string) bool { // @success 200 {object} portainer.CustomTemplate // @failure 400 "Invalid request" // @failure 500 "Server error" -// @router /custom_templates/create/string [post] +// @router /custom_templates/string [post] func (handler *Handler) createCustomTemplateFromFileContent(r *http.Request) (*portainer.CustomTemplate, error) { var payload customTemplateFromFileContentPayload err := request.DecodeAndValidateJSONPayload(r, &payload) @@ -263,7 +263,7 @@ func (payload *customTemplateFromGitRepositoryPayload) Validate(r *http.Request) // @success 200 {object} portainer.CustomTemplate // @failure 400 "Invalid request" // @failure 500 "Server error" -// @router /custom_templates/create/repository [post] +// @router /custom_templates/repository [post] func (handler *Handler) createCustomTemplateFromGitRepository(r *http.Request) (*portainer.CustomTemplate, error) { var payload customTemplateFromGitRepositoryPayload err := request.DecodeAndValidateJSONPayload(r, &payload) @@ -443,7 +443,7 @@ func (payload *customTemplateFromFileUploadPayload) Validate(r *http.Request) er // @success 200 {object} portainer.CustomTemplate // @failure 400 "Invalid request" // @failure 500 "Server error" -// @router /custom_templates/create/file [post] +// @router /custom_templates/file [post] func (handler *Handler) createCustomTemplateFromFileUpload(r *http.Request) (*portainer.CustomTemplate, error) { payload := &customTemplateFromFileUploadPayload{} err := payload.Validate(r) diff --git a/api/http/handler/edgejobs/edgejob_tasklogs_clear.go b/api/http/handler/edgejobs/edgejob_tasklogs_clear.go index 4781168ac..e54c59029 100644 --- a/api/http/handler/edgejobs/edgejob_tasklogs_clear.go +++ b/api/http/handler/edgejobs/edgejob_tasklogs_clear.go @@ -110,6 +110,11 @@ func (handler *Handler) clearEdgeJobTaskLogs(tx dataservices.DataStoreTx, edgeJo return httperror.InternalServerError("Unable to persist Edge job changes in the database", err) } + err = handler.FileService.ClearEdgeJobTaskLogs(strconv.Itoa(int(edgeJobID)), strconv.Itoa(int(endpointID))) + if err != nil { + return httperror.InternalServerError("Unable to clear log file from disk", err) + } + endpoint, err := tx.Endpoint().Endpoint(endpointID) if err != nil { return httperror.NotFound("Unable to retrieve environment from the database", err) diff --git a/api/http/handler/endpoints/endpoint_update.go b/api/http/handler/endpoints/endpoint_update.go index eb728bc9c..4d566968c 100644 --- a/api/http/handler/endpoints/endpoint_update.go +++ b/api/http/handler/endpoints/endpoint_update.go @@ -89,8 +89,6 @@ 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) } - updateEndpointProxy := shouldReloadTLSConfiguration(endpoint, &payload) - if payload.Name != nil { name := *payload.Name isUnique, err := handler.isNameUnique(name, endpoint.ID) @@ -106,9 +104,8 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) * } - if payload.URL != nil && *payload.URL != endpoint.URL { + if payload.URL != nil { endpoint.URL = *payload.URL - updateEndpointProxy = true } if payload.PublicURL != nil { @@ -182,8 +179,6 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) * } if endpoint.Type == portainer.AzureEnvironment { - updateEndpointProxy = true - credentials := endpoint.AzureCredentials if payload.AzureApplicationID != nil { credentials.ApplicationID = *payload.AzureApplicationID @@ -252,7 +247,10 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) * } } - if updateEndpointProxy { + if (payload.URL != nil && *payload.URL != endpoint.URL) || + (payload.TLS != nil && endpoint.TLSConfig.TLS != *payload.TLS) || + endpoint.Type == portainer.AzureEnvironment || + shouldReloadTLSConfiguration(endpoint, &payload) { handler.ProxyManager.DeleteEndpointProxy(endpoint.ID) _, err = handler.ProxyManager.CreateAndRegisterEndpointProxy(endpoint) if err != nil { @@ -293,12 +291,6 @@ func (handler *Handler) endpointUpdate(w http.ResponseWriter, r *http.Request) * } 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, // we assume that new TLS files have been uploaded and we need to reload the TLS configuration. if endpoint.Type != portainer.DockerEnvironment || diff --git a/app/docker/__module.js b/app/docker/__module.js index a5ef94fc9..de09c8719 100644 --- a/app/docker/__module.js +++ b/app/docker/__module.js @@ -34,7 +34,7 @@ angular.module('portainer.docker', ['portainer.app', reactModule]).config([ endpoint.Status = status; if (status === EnvironmentStatus.Down) { - throw new Error(`The environment named ${endpoint.Name} is unreachable.`); + throw new Error('Environment is unreachable.'); } await StateManager.updateEndpointState(endpoint); diff --git a/app/docker/views/dashboard/dashboard.html b/app/docker/views/dashboard/dashboard.html index 5104a06df..655828adb 100644 --- a/app/docker/views/dashboard/dashboard.html +++ b/app/docker/views/dashboard/dashboard.html @@ -18,7 +18,7 @@