unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: raingloom <raingloom@riseup.net>
To: 52654@debbugs.gnu.org
Subject: bug#52654: shepherd lacks error reporting
Date: Sun, 19 Dec 2021 06:13:20 +0100	[thread overview]
Message-ID: <20211219061320.7ef3bb8c@riseup.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 1114 bytes --]

I'm writing a single-shot shepherd-service that expands the (ext4) root
file system on first boot, using the hostname service as a template,
just passing the script as a G-expression, instead of using the
forkexec constructor.
Of course there is a bug in it. Trouble is, I have no idea what it is,
because Shepherd won't tell me. :)
The VM boots and completes the ssh initialization phase and then
apparently just gets stuck. Doesn't even show a login prompt.
It's... not a great debugging experience.
I'm going to attempt to at the very least add some error reporting.
It would also be really nice if the failure modes for Shepherd services
were better documented, like what happens when the procedure passed in
the `start` field fails, or is not even a procedure, etc.
Since I never touched Shepherd internals, help would be greatly
appreciated.

ps.: I'm attaching the system definition for completeness's sake and so
that someone might point out where the error is, but honestly the exact
bug in my code does not matter for the feature. All that matters is
there is an error and it should be logged but isn't.

[-- Attachment #2: cloud-deploy-bootstrap.scm --]
[-- Type: text/x-scheme, Size: 2928 bytes --]

(define-module (raingloom machines cloud-deploy-bootstrap))
(use-modules
 (gnu)
 (gnu system nss)
 (guix channels)
 (guix modules))
 

(use-service-modules
 admin
 networking
 shepherd
 ssh)

(use-package-modules
 admin
 bootloaders
 certs
 gnome
 linux
 networking
 ssh
 tmux
 tls
 version-control)

(define disk "/dev/vda")
(define partition "2")

(define ext-autoexpand-service-type
  (let
      ((name 'ext-autoexpand)
       (desc
        "Automatically expand ext2 root")
       (modules
        '((ice-9 popen))))
    (shepherd-service-type
     name
     (lambda (config)
       (shepherd-service
        (documentation desc)
        (provision (list name))
        (requirement '(file-systems))
        (one-shot? #t)
        (start
         (with-imported-modules
             (source-module-closure modules)
           #~(begin
               (use-modules #$@modules)
               (let ((port
                      (open-pipe*
                       OPEN_WRITE
                       #$(file-append util-linux "/sbin/sfdisk")
                       ;; don't check if the block is in use
                       ;; it is, and we don't care.
                       "--no-reread"
                       disk
                       "-N" partition)))
                 (display ",+" port)
                 (close-port port))
               (system* $#(file-append util-linux "/sbin/partx") "--update" disk)
               (system*
                #$(file-append e2fsprogs "/sbin/resize2fs")
                (string-append disk partition)))))))
     (description desc))))

(define-public %system
  (operating-system
   (host-name "cloud-deploy-bootstrap")
   (timezone "Europe/Budapest")
   (locale "en_US.utf8")
   (keyboard-layout (keyboard-layout "us"))
   (bootloader (bootloader-configuration
                (bootloader grub-bootloader)
                (targets '("/dev/vda"))
                (keyboard-layout keyboard-layout)))
   (file-systems (append
                  (list (file-system
                         (device (file-system-label "cloudimg-rootfs"))
                         (mount-point "/")
                         (type "btrfs")))
                  %base-file-systems))

   ;; This is where we specify system-wide packages.
   (packages (append (list
                      nss-certs
                      tmux)
                     %base-packages))

   (services
    (append
     (list
      (service ext-autoexpand-service-type #f)
      (service dhcp-client-service-type)
      (service openssh-service-type
               (openssh-configuration
                (openssh openssh-sans-x)
                (permit-root-login #t)
                (authorized-keys
                 `(("root" ,(local-file (string-append (getenv "HOME") "/.ssh/id_ed25519.pub"))))))))
     %base-services))
   ;; Allow resolution of '.local' host names with mDNS.
   (name-service-switch %mdns-host-lookup-nss)))

%system

             reply	other threads:[~2021-12-19  5:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-19  5:13 raingloom [this message]
2021-12-19  6:02 ` bug#52654: shepherd lacks error reporting raingloom
2023-04-29 15:22   ` Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211219061320.7ef3bb8c@riseup.net \
    --to=raingloom@riseup.net \
    --cc=52654@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).