branch: main commit 311e861d0e7f5bd7e1abe683e7330a255bde0f40 Author: Ludovic Courtès <l...@gnu.org> AuthorDate: Wed Oct 2 16:47:57 2024 +0200
remote-server: Gracefully handle missing dependency derivation. * src/cuirass/scripts/remote-server.scm (insert-build-for-dependency): Catch 'system-error around ‘read-derivation-from-file’. --- src/cuirass/scripts/remote-server.scm | 67 ++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/src/cuirass/scripts/remote-server.scm b/src/cuirass/scripts/remote-server.scm index 08cf69a..34ef3f8 100644 --- a/src/cuirass/scripts/remote-server.scm +++ b/src/cuirass/scripts/remote-server.scm @@ -461,35 +461,44 @@ all network interfaces." "Insert DEPENDENCY, a derivation, in the database, where DEPENDENCY currently lacks a 'Builds' entry and is a dependency of PARENT, a derivation with a corresponding 'Builds' entry." - (let* ((drv (read-derivation-from-file dependency)) - (outputs (map (match-lambda - ((name . item) - (output (name name) - (item (derivation-output-path item)) - (derivation (derivation-file-name drv))))) - (derivation-outputs drv))) - (dependency (build - (derivation dependency) - (nix-name (strip-store-file-name - (derivation->output-path drv))) - (outputs outputs) - (system (derivation-system drv)) - (job-name (string-append (build-job-name parent) - "." nix-name)) - (evaluation-id (build-evaluation-id parent)) - (specification-name (build-specification-name parent)) - (status (build-status failed)) - (creation-time (current-time)) - (completion-time creation-time) - (log (log-path (%cache-directory) derivation)))) - (id (db-add-build dependency))) - (when id - (log-info "registered build ~a for ghost dependency '~a'" - id (build-derivation dependency))) - - ;; Add dependency edges unconditionally (it's idempotent). - (db-add-build-dependencies (build-derivation parent) - (list (build-derivation dependency))))) + (match (catch 'system-error + (lambda () + (read-derivation-from-file dependency)) + (lambda args + ;; No luck: DEPENDENCY was GC'd in the meantime? + (log-error "failed to read '~a': ~a" dependency + (strerror (system-error-errno args))) + #f)) + (#f #f) + (drv + (let* ((outputs (map (match-lambda + ((name . item) + (output (name name) + (item (derivation-output-path item)) + (derivation (derivation-file-name drv))))) + (derivation-outputs drv))) + (dependency (build + (derivation dependency) + (nix-name (strip-store-file-name + (derivation->output-path drv))) + (outputs outputs) + (system (derivation-system drv)) + (job-name (string-append (build-job-name parent) + "." nix-name)) + (evaluation-id (build-evaluation-id parent)) + (specification-name (build-specification-name parent)) + (status (build-status failed)) + (creation-time (current-time)) + (completion-time creation-time) + (log (log-path (%cache-directory) derivation)))) + (id (db-add-build dependency))) + (when id + (log-info "registered build ~a for ghost dependency '~a'" + id (build-derivation dependency))) + + ;; Add dependency edges unconditionally (it's idempotent). + (db-add-build-dependencies (build-derivation parent) + (list (build-derivation dependency))))))) (define (serve-build-requests backend-port fetch-worker worker-directory) "Open a zmq socket on BACKEND-PORT and listen for messages coming from