Skip to content

Commit

Permalink
fix: extend http download timeout (#369)
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
  • Loading branch information
migmartri committed Sep 28, 2023
1 parent f5ede4c commit 42c24bf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
8 changes: 5 additions & 3 deletions app/artifact-cas/configs/config.devel.yaml
Expand Up @@ -5,11 +5,13 @@
server:
http:
addr: 0.0.0.0:8001
timeout: 5s
# Timeouts for http downloads
# grpc downloads/uploads don't require this because they don't have timeouts
timeout: 300s
grpc:
addr: 0.0.0.0:9001
# Some cas backends are slow, so we need to increase the timeout
# for example, Azure Blob Storage describe takes more than 1 second to respond sometimes
# Some unary RPCs are slow, so we need to increase the timeout
# For example, Azure Blob Storage describe takes more than 1 second to respond sometimes
timeout: 5s
http_metrics:
addr: 0.0.0.0:5001
Expand Down
9 changes: 4 additions & 5 deletions app/artifact-cas/internal/service/download.go
Expand Up @@ -91,6 +91,10 @@ func (s *DownloadService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

// if the buffer contains the actual data we expect we proceed with sending it to the browser
// Set headers
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", info.FileName))
w.Header().Set("Content-Length", strconv.FormatInt(info.Size, 10))
s.log.Infow("msg", "download initialized", "digest", wantChecksum, "size", bytefmt.ByteSize(uint64(info.Size)))

gotChecksum := sha256.New()
Expand Down Expand Up @@ -120,11 +124,6 @@ func (s *DownloadService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

// if the buffer contains the actual data we expect we proceed with sending it to the browser
// Set headers
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", info.FileName))
w.Header().Set("Content-Length", strconv.FormatInt(info.Size, 10))

if _, err := io.Copy(w, buf); err != nil {
http.Error(w, sl.LogAndMaskErr(err, s.log).Error(), http.StatusInternalServerError)
return
Expand Down
2 changes: 1 addition & 1 deletion deployment/chainloop/Chart.yaml
Expand Up @@ -4,7 +4,7 @@ description: Chainloop is an open source software supply chain control plane, a

type: application
# Bump the patch (not minor, not major) version on each change in the Chart Source code
version: 1.17.1
version: 1.17.2
# Do not update appVersion, this is handled automatically by the release process
appVersion: v0.19.0

Expand Down
5 changes: 4 additions & 1 deletion deployment/chainloop/templates/cas/config.configmap.yaml
Expand Up @@ -9,14 +9,17 @@ data:
server:
http:
addr: 0.0.0.0:8000
timeout: 1s
# Timeouts for http downloads
# grpc downloads/uploads don't require this because they don't have timeouts
timeout: 300s
grpc:
{{- if .Values.cas.tlsConfig.secret.name }}
tls_config:
certificate: /data/server-certs/tls.crt
private_key: /data/server-certs/tls.key
{{- end }}
addr: 0.0.0.0:9000
# Some unary RPCs are slow, so we need to increase the timeout
timeout: 5s
http_metrics:
addr: 0.0.0.0:5000

0 comments on commit 42c24bf

Please sign in to comment.