GNU bug report logs - #33968
errors in shepherd service constructors are not logged and lead to misleading status

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix; Reported by: Florian Dold <florian.dold@HIDDEN>; dated Thu, 3 Jan 2019 21:37:02 UTC; Maintainer for guix is bug-guix@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 3 Jan 2019 21:36:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 03 16:36:40 2019
Received: from localhost ([127.0.0.1]:46025 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1gfAfP-0000xs-4F
	for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 16:36:40 -0500
Received: from eggs.gnu.org ([208.118.235.92]:38768)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <florian.dold@HIDDEN>) id 1gfAfN-0000xh-40
 for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 16:36:37 -0500
Received: from lists.gnu.org ([208.118.235.17]:54226)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <florian.dold@HIDDEN>)
 id 1gfAfM-0005NX-Oe
 for submit <at> debbugs.gnu.org; Thu, 03 Jan 2019 16:36:36 -0500
Received: from eggs.gnu.org ([208.118.235.92]:57511)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <florian.dold@HIDDEN>) id 1gfAfL-000717-Jo
 for bug-guix@HIDDEN; Thu, 03 Jan 2019 16:36:36 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <florian.dold@HIDDEN>) id 1gfAfG-0005F1-Lt
 for bug-guix@HIDDEN; Thu, 03 Jan 2019 16:36:35 -0500
Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:36879)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <florian.dold@HIDDEN>)
 id 1gfAfE-0005BB-Lt
 for bug-guix@HIDDEN; Thu, 03 Jan 2019 16:36:30 -0500
Received: by mail-wm1-x32b.google.com with SMTP id g67so31537360wmd.2
 for <bug-guix@HIDDEN>; Thu, 03 Jan 2019 13:36:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=to:from:subject:openpgp:autocrypt:message-id:date:user-agent
 :mime-version:content-language;
 bh=bf0CWNbSVHsbUlOu6MgY6QeW7LGKC7EprDUCSfAoG1k=;
 b=k/9G9h/Jk/l9LJE/0pQdX+/4aEB9ng/2XIATe9BXUQADxwqTcyOimeCr52MqkPrq1W
 yFy7tQp9h4kX8mnPdFvMplK0xsdQXB2Ks8a5JY/srkV4qOhr59w0MaQ8YVYYPM9ueSZj
 TlTaKNHstG0YcrKZz7IN6mZgx1fj58HVyi5oKfee210DKPNKOsVTrhJoeZEmU6/7xGQS
 ykSaJUgNM1K6oskiklP/+lATJn44ddjEjQUtiV6TH99+DOD5HcVZ+9t6rfPhlDi7Q4lq
 MzJIpWqRRoAfSfiDx5nZcpZDhomSGDelSKzVz1KiSn33RXBb449joOE7jXMJjLx3BOpB
 aRCA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:to:from:subject:openpgp:autocrypt:message-id
 :date:user-agent:mime-version:content-language;
 bh=bf0CWNbSVHsbUlOu6MgY6QeW7LGKC7EprDUCSfAoG1k=;
 b=n+Jzol9OMfPD8G+EV8lUzI2jSNCPlLT0//BzaCy2ThH9y/qGQSmAwUWFUv9xF8gd7w
 7CnarTtomxHSQp7Ps7n7lkv4Z+g+2ZLYJ+V1pSE8vzNkY/5U1cqCTGIbb1Q/DF2i2ZIf
 CKBI5PLDWRmP9SZjQnKx8XNwDQcLyhNXy9cpAg5z25DPfl/BdN/v0R3ulUXV0KIp8RB2
 trnhQF6YHkiOMwJK9rzs1I0YXmQK6ql29sGb7T4ljqmFBlb2p5WByrivRigW0wQH4kRW
 NYlpk8u6GXUIonA5D4M0gCSPz4K7ZJfcep3blLK6nCTo5l17dW4/HepKpmQ+QsNpgT+g
 4qhw==
X-Gm-Message-State: AJcUukfN+MiOYCfczxq+gel2pHVpAr2/lfKZsDwuRPeGFrvVm6qja5K6
 UL32iGtpKf3WkWYqw8ILQ+4YM/oh
X-Google-Smtp-Source: ALg8bN4MxsQ7/Xxz2VOku+PkTXNg/NvM4d6+1GlSFFYZDFjAD7WtLkS7V64t8nGsS8jxcktF2t/MDA==
X-Received: by 2002:a1c:8d12:: with SMTP id p18mr42708866wmd.31.1546551382709; 
 Thu, 03 Jan 2019 13:36:22 -0800 (PST)
Received: from [192.168.178.64] (p508876EC.dip0.t-ipconnect.de.
 [80.136.118.236])
 by smtp.gmail.com with ESMTPSA id c129sm35173081wma.48.2019.01.03.13.36.21
 for <bug-guix@HIDDEN>
 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 03 Jan 2019 13:36:21 -0800 (PST)
To: bug-guix@HIDDEN
From: Florian Dold <florian.dold@HIDDEN>
Subject: errors in shepherd service constructors are not logged and lead to
 misleading status
Openpgp: preference=signencrypt
Autocrypt: addr=florian.dold@HIDDEN; keydata=
 mQENBFr0DFABCADIf6L8MOVfrvjN8vTPngMjxGk4gpaRAYydTYMt8I7A746E8fI4vIp66b7x
 ZmT+RwnR+nydTLdAMEpwsqxOUtBLBG+63v/pOFEqHaWWjoWB9tC2GKa23o5accKdeVwZAUSC
 d8PMCTY0An25yjspAPFeSuS8OVhNcJgqwMRLr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
 gOSHABEBAAGJATwEGAEIACYWIQTSicR018Yz2C9+q1hf73L/w6CZwgUCWvQMUAIbDAUJAeEz
 gAAKCRBf73L/w6CZwjXsB/0QCZvO+chvdd719yAFLEAkhGxPeolvJaGudg1AY37dx0NaeBhG
 DzE6kWXCSD0Sp/1+36hTv680+I+L9gQW9p3mZRyT/syI63aEMIPAWCCVy7OokujVs0F8oozI
 CJexqdMP7jho5zDU9ecIMNo7zOo7+U4mfNPnS70wJmdBO2s9edVmXkfkEzuL6fGuDFdjC3le
 AfLLDlYsZ/7jUWX9UF+U05mjSI+1w3vmUigufKdf3h65s4xcgRr+BR0uuAG81oJ+/eiEyv+i
 yo2U+n+RaH9yqO4rrMgQFnMrfr0JQ6CDSklup4LRPjpjvdqX900QkVWErvMxDnC66pyur0o/ 3rSx
Message-ID: <7c7f7030-a0f2-5fd0-7d02-f203277d7bba@HIDDEN>
Date: Thu, 3 Jan 2019 22:36:20 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.3.3
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------127386F850B9CE8C8EAF01A8"
Content-Language: en-US-large
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2a00:1450:4864:20::32b
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: -4.0 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

This is a multi-part message in MIME format.
--------------127386F850B9CE8C8EAF01A8
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Hi Guix,

when defining a service type that extends shepherd-root-service-type and
the 'start' function of the shepherd-service definition contains an
error, the error is silently ignored.  No log output is generated at all.

For example (full system definition is attached):

(define (errtest-shepherd-service c)
  (list
    (shepherd-service
      (provision '(errtest))
      (documentation "Errtest")
      (requirement '(file-systems))
      (modules `((shepherd support) (ice-9 match) ,@%default-modules))
      (start #~(lambda args
                 (local-output "errtest start")
                 this-is-an-unbound-variable
                 (local-output "errtest end")
                 #t)))))


The log message "errtest start" appears in /var/log/messages, as
expected.  The next line contains an error, and aborts execution of the
start function.

The error only becomes apparent when manually doing a "herd restart
errtest", which shows an error message (but without any error location
or stack trace).  But the error (regarding the unbound variable) is not
logged, and there is no indication in the log that the service couldn't
be started in any log.

Furthermore the "herd status" of a service that encountered an error in
the start function is very misleading:

root@errtest ~# herd status errtest
Status of errtest:
  It is stopped.
  It is enabled.
  Provides (errtest).
  Requires (file-systems).
  Conflicts with ().
  Will be respawned.


It shows "Will be respawned", which is wrong.

I'd be happy to work on a patch, but it seems like there is some design
discussion necessary, in particular how the "Will be respawned" should
be handled.  Services have a "respawn?" flag, but of course respawning
can only work if the start function executed successfully (and only the
service process itself failed) in the first place.

I generally feel like the state machine for services needs some work.
In particular, it would be useful to distinguish between "failed" and
"completed" services instead of conflating both states into "stopped".
Or maybe have some more general mechanism for storing state about the
service, instead of just the slot that usually contains the PID?

- Florian

--------------127386F850B9CE8C8EAF01A8
Content-Type: text/x-scheme;
 name="config-error-reporting.scm"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
 filename="config-error-reporting.scm"

(use-modules (gnu))
(use-service-modules networking ssh shepherd)

(define (errtest-shepherd-service c)
  (list
    (shepherd-service
      (provision '(errtest))
      (documentation "Errtest")
      (requirement '(file-systems))
      (modules `((shepherd support) (ice-9 match) ,@%default-modules))
      (start #~(lambda args
		 (local-output "errtest start")
		 this-is-an-unbound-variable
		 (local-output "errtest end")
		 #t)))))

(define errtest-service-type
  (service-type
   (name 'errtest)
   (extensions
    (list (service-extension shepherd-root-service-type errtest-shepherd-=
service)))
   (default-value #t)))

(operating-system
  (host-name "errtest")
  (timezone "Europe/Berlin")
  (locale "en_US.utf8")
  (kernel-arguments (list "console=3DttyS0" "console=3Dtty0"))
  (bootloader (bootloader-configuration
                (bootloader grub-bootloader)
                (target "/dev/sdX")))
  (file-systems (cons (file-system
                        (device (file-system-label "my-root"))
                        (mount-point "/")
                        (type "ext4"))
                      %base-file-systems))

  (services (cons* (service errtest-service-type)
                   %base-services)))

--------------127386F850B9CE8C8EAF01A8--




Acknowledgement sent to Florian Dold <florian.dold@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-guix@HIDDEN. Full text available.
Report forwarded to bug-guix@HIDDEN:
bug#33968; Package guix. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.