UploadJobArtifact(): return 400 if not accepting artifacts
The worker server API handler `UploadJobArtifact()` was previously silently discarding artifacts uploaded by the worker, if the server was configured to not accept artifacts. Change the behavior to return HTTP error "Bad Request" (`400`) to the worker, in case it tries to upload artifact to the server, but the server is configured to not accept any artifacts. Add a new unit test testing the new behavior and adjust existing unit tests, which were relying on the artifact being previously silently discarded.
This commit is contained in:
parent
fd82174469
commit
bdf009f800
2 changed files with 62 additions and 24 deletions
|
|
@ -6,7 +6,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
|
@ -794,11 +793,8 @@ func (h *apiHandlers) UploadJobArtifact(ctx echo.Context, tokenstr string, name
|
|||
request := ctx.Request()
|
||||
|
||||
if h.server.config.ArtifactsDir == "" {
|
||||
_, err := io.Copy(ioutil.Discard, request.Body)
|
||||
if err != nil {
|
||||
return api.HTTPErrorWithInternal(api.ErrorDiscardingArtifact, err)
|
||||
}
|
||||
return ctx.NoContent(http.StatusOK)
|
||||
// indicate to the worker that the server is not accepting any artifacts
|
||||
return ctx.NoContent(http.StatusBadRequest)
|
||||
}
|
||||
|
||||
f, err := os.Create(path.Join(h.server.config.ArtifactsDir, "tmp", token.String(), name))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue