Subject: Re: bug#69401: /etc/guix/machines.scm symlink can be garbage collected

From: Ludovic Courtès <[email-masked]>
Date: Thu, 04 Apr 2024 23:55:07 +0200

Hi,

Efraim Flashner <[email-masked]> skribis:

> Some of the build nodes behind the Berlin build farm have a childhurd
> which can build packages.  Unfortunately, the symlink from
> /etc/guix/machines.scm to the generated file in the store to setup
> offloading has been garbage collected on several of the machines.

Indeed.  Here’s an example:

--8<---------------cut here---------------start------------->8---
root@hydra-guix-108 ~# guix gc -R $(readlink -f /run/current-system) |grep machines.scm
/gnu/store/xg26iis3ydik6zxqk24cyk7h9zli1d25-machines.scm
root@hydra-guix-108 ~# ls -l /etc/guix/machines.scm
lrwxrwxrwx 1 root root 56 Mar  7 11:53 /etc/guix/machines.scm -> /gnu/store/1171q4xhph07ll3mlzlg7igcwg3c98i1-machines.scm
root@hydra-guix-108 ~# stat -L /etc/guix/machines.scm
stat: cannot statx '/etc/guix/machines.scm': No such file or directory
--8<---------------cut here---------------end--------------->8---

Here /etc/guix/machines.scm points to a different ‘machines.scm’ than
the one that is current.  The old one was removed last week:

--8<---------------cut here---------------start------------->8---
root@hydra-guix-108 ~# zgrep 1171q4xhph07ll3mlzlg7igcwg3c98i1 /var/log/mcron.log.1.gz 
2024-03-27 03:00:05 23100 guix gc -F 150G: [46%] deleting '/gnu/store/1171q4xhph07ll3mlzlg7igcwg3c98i1-machines.scm'
--8<---------------cut here---------------end--------------->8---

The /etc/guix/machines.scm link was created on the last deployment
though:

--8<---------------cut here---------------start------------->8---
root@hydra-guix-108 ~# ls -l /etc/guix/machines.scm
lrwxrwxrwx 1 root root 56 Mar  7 11:53 /etc/guix/machines.scm -> /gnu/store/1171q4xhph07ll3mlzlg7igcwg3c98i1-machines.scm
root@hydra-guix-108 ~# guix system describe
Generation 109  Mar 07 2024 11:53:30    (current)
  file name: /var/guix/profiles/system-109-link
  canonical file name: /gnu/store/5m0sjf3x0pslipcbdxm9ml99h0lbh7c8-system
  label: GNU with Linux-Libre 6.6.18
  bootloader: grub-efi
  root device: label: "my-root"
  kernel: /gnu/store/jcr3d8yy531q4i6kgkfmb0r3ghw418mc-linux-libre-6.6.18/bzImage
  channels:
    guix:
      repository URL: https://git.savannah.gnu.org/git/guix.git
      commit: 64d269b983b76553466ac93945d58c7865cf190e
  configuration file: /gnu/store/d4z76lw515padizhl62hydxwygh57p6k-configuration.scm
--8<---------------cut here---------------end--------------->8---

Could it be that the “wrong” activation snippet was run by ‘guix
deploy’?  Here we see the right one:

--8<---------------cut here---------------start------------->8---
root@hydra-guix-108 ~# grep machines.scm $(guix gc -R $(readlink -f /run/current-system) |grep activate-service)
/gnu/store/pgmb9swcx0pljhbw88mgd3zjagz5axvn-activate-service.scm:(eval-when (expand load eval) (let ((extensions (quote ())) (prepend (lambda (items lst) (let loop ((items items) (lst lst)) (if (null? items) lst (loop (cdr items) (cons (car items) (delete (car items) lst)))))))) (set! %load-path (prepend (cons "/gnu/store/pj751v3199vmv6i6sf0szp185ryzcfdg-module-import" (map (lambda (extension) (string-append extension "/share/guile/site/" (effective-version))) extensions)) %load-path)) (set! %load-compiled-path (prepend (cons "/gnu/store/iqbchmbmhmi34bwgv4sm14li9m24dpnl-module-import-compiled" (map (lambda (extension) (string-append extension "/lib/guile/" (effective-version) "/site-ccache")) extensions)) %load-compiled-path))))(begin (unless (or #f (file-exists? "/etc/guix/signing-key.pub")) (system* "/gnu/store/59y43hrlffs8hg1584vg5074jsbfhwjy-guix-1.4.0-16.aeb4943/bin/guix" "archive" "--generate-key")) (begin (use-modules (guix build utils)) (define acl-file "/etc/guix/acl") (if (file-exists? acl-file) (if (and (symbolic-link? acl-file) (store-file-name? (readlink acl-file))) (delete-file acl-file) (rename-file acl-file (string-append acl-file ".bak"))) (mkdir-p (dirname acl-file))) (symlink "/gnu/store/np3babd2h4xh4x4dvm51k6rp3xbsrzyl-acl" acl-file)) (begin (use-modules (guix build utils)) (define machines-file "/etc/guix/machines.scm") (if (file-exists? machines-file) (if (and (symbolic-link? machines-file) (store-file-name? (readlink machines-file))) (delete-file machines-file) (rename-file machines-file (string-append machines-file ".bak"))) (mkdir-p (dirname machines-file))) (symlink "/gnu/store/xg26iis3ydik6zxqk24cyk7h9zli1d25-machines.scm" machines-file)))
--8<---------------cut here---------------end--------------->8---

To be continued…

Ludo’.