mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
scripts: publish: Add a custom baking header.
Log the not-found responses and their reason (baking or not) to stdout. Also send the X-Baking custom header so that the client can be informed of the cause of the failure. * guix/scripts/publish.scm (not-found): Add a baking? argument to add the X-Baking HTTP header to the response if baking is in progress. Also, log the 404 responses to stdout, indicating if it is due to baking or not. (render-narinfo/cached): Pass the baking? argument.
This commit is contained in:
parent
7c01abeb6e
commit
62f9f34525
1 changed files with 20 additions and 5 deletions
|
@ -4,7 +4,7 @@
|
|||
;;; Copyright © 2015-2022 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
|
||||
;;; Copyright © 2021 Mathieu Othacehe <othacehe@gnu.org>
|
||||
;;; Copyright © 2021, 2022 Mathieu Othacehe <othacehe@gnu.org>
|
||||
;;;
|
||||
;;; This file is part of GNU Guix.
|
||||
;;;
|
||||
|
@ -375,14 +375,28 @@ (define* (narinfo-string store store-path
|
|||
compression)))
|
||||
compressions))))
|
||||
|
||||
;; Custom header to indicate that baking is in progress.
|
||||
(declare-opaque-header! "X-Baking")
|
||||
|
||||
(define* (not-found request
|
||||
#:key (phrase "Resource not found")
|
||||
#:key
|
||||
baking?
|
||||
(phrase "Resource not found")
|
||||
ttl)
|
||||
"Render 404 response for REQUEST."
|
||||
(format #t "-> ~a ~a: 404~a~%"
|
||||
(request-method request)
|
||||
(uri-path (request-uri request))
|
||||
(if baking? " (baking)" ""))
|
||||
(values (build-response #:code 404
|
||||
#:headers (if ttl
|
||||
`((cache-control (max-age . ,ttl)))
|
||||
'()))
|
||||
#:headers
|
||||
(append
|
||||
(if ttl
|
||||
`((cache-control (max-age . ,ttl)))
|
||||
'())
|
||||
(if baking?
|
||||
'((x-baking . "1"))
|
||||
'())))
|
||||
(string-append phrase ": "
|
||||
(uri-path (request-uri request)))))
|
||||
|
||||
|
@ -587,6 +601,7 @@ (define (delete-entry narinfo)
|
|||
#:nar-path nar-path
|
||||
#:compressions compressions)
|
||||
(not-found request
|
||||
#:baking? #t
|
||||
#:phrase "We're baking it"
|
||||
#:ttl 300))) ;should be available within 5m
|
||||
(else
|
||||
|
|
Loading…
Reference in a new issue