diff options
author | Christopher Baines <mail@cbaines.net> | 2024-06-05 16:28:48 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2024-06-05 16:28:48 +0100 |
commit | c1af6c5212d8a560d2ddd7a5c2b3013e6bad1f43 (patch) | |
tree | 2d09f1bae40f94f7a2ab0e94bfd7cb7932e0fdc8 | |
parent | 8609e3cb4894679200c940a30dc8b3688bc34213 (diff) | |
download | nar-herder-c1af6c5212d8a560d2ddd7a5c2b3013e6bad1f43.tar nar-herder-c1af6c5212d8a560d2ddd7a5c2b3013e6bad1f43.tar.gz |
Always create the nar removal channel
As this manages the metrics.
-rw-r--r-- | nar-herder/server.scm | 38 | ||||
-rw-r--r-- | nar-herder/storage.scm | 26 |
2 files changed, 33 insertions, 31 deletions
diff --git a/nar-herder/server.scm b/nar-herder/server.scm index 7046784..2d28a5f 100644 --- a/nar-herder/server.scm +++ b/nar-herder/server.scm @@ -740,7 +740,16 @@ compression) 'directory))) (utime (string-append directory "/" filename)))) - maintenance-scheduler))))) + maintenance-scheduler)))) + + (nar-removal-criteria + (filter-map + (match-lambda + ((key . val) + (if (eq? key 'storage-nar-removal-criteria) + val + #f))) + opts))) (if (string=? (assq-ref opts 'database-dump) "disabled") @@ -793,23 +802,12 @@ metrics-registry) #f)))) (removal-channel - (let ((nar-removal-criteria - (filter-map - (match-lambda - ((key . val) - (if (eq? key 'storage-nar-removal-criteria) - val - #f))) - opts))) - (if (and (assq-ref opts 'storage) - (number? (assq-ref opts 'storage-limit)) - (not (null? nar-removal-criteria))) - (start-nar-removal-fiber database - canonical-storage - (assq-ref opts 'storage-limit) - metrics-registry - nar-removal-criteria) - #f))) + (start-nar-removal-fiber + database + canonical-storage + (assq-ref opts 'storage-limit) + metrics-registry + nar-removal-criteria)) (addition-channel (make-channel))) (spawn-fiber @@ -837,7 +835,9 @@ (lambda () (put-message mirror-channel `(fetch ,file))))) - (when removal-channel + (when (and (assq-ref opts 'storage) + (number? (assq-ref opts 'storage-limit)) + (not (null? nar-removal-criteria))) (spawn-fiber (lambda () (sleep 60) diff --git a/nar-herder/storage.scm b/nar-herder/storage.scm index e85d745..dc6b365 100644 --- a/nar-herder/storage.scm +++ b/nar-herder/storage.scm @@ -536,23 +536,25 @@ When VERIFY-CERTIFICATE? is true, verify HTTPS server certificates." (log-msg 'ERROR "failed to remove " file ": " exn)) (lambda () ;; TODO: Do more checking at this point - (remove-nar-from-storage - storage-root - (uri-decode file)) + (when storage-root + (remove-nar-from-storage + storage-root + (uri-decode file))) (update-nar-files-metric metrics-registry '() #:removed-count 1)) #:unwind? #t)))))) - (spawn-fiber - (lambda () - (while #t - (with-exception-handler - (lambda (exn) - (log-msg 'ERROR "nar removal pass failed " exn)) - run-removal-pass - #:unwind? #t) - (sleep (* 60 60 24))))) + (when storage-root + (spawn-fiber + (lambda () + (while #t + (with-exception-handler + (lambda (exn) + (log-msg 'ERROR "nar removal pass failed " exn)) + run-removal-pass + #:unwind? #t) + (sleep (* 60 60 24)))))) removal-channel) |