GNU bug report logs - #48561
"Daemon not running" exception when avahi-daemon is not running

Previous Next

Package: guix;

Reported by: Maxime Devos <maximedevos <at> telenet.be>

Date: Fri, 21 May 2021 08:50:02 UTC

Severity: minor

Done: Mathieu Othacehe <othacehe <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 48561 in the body.
You can then email your comments to 48561 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#48561; Package guix. (Fri, 21 May 2021 08:50:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxime Devos <maximedevos <at> telenet.be>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Fri, 21 May 2021 08:50:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: bug-guix <at> gnu.org
Subject: "Daemon not running" exception when avahi-daemon is not running
Date: Fri, 21 May 2021 10:48:53 +0200
[Message part 1 (text/plain, inline)]
Severity: minor

My /var/log/guix-daemon.log.* are full of backtraces like these
(and boring messages like SIGPOLL, spurious SIGPOLL, accepted connections
from pid [..], user [...]).

Backtrace:
In ice-9/boot-9.scm:
  1752:10 10 (with-exception-handler _ _ #:unwind? _ # _)
In unknown file:
           9 (apply-smob/0 #<thunk 7f77d4149f60>)
In ice-9/boot-9.scm:
    724:2  8 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
    619:8  7 (_ #(#(#<directory (guile-user) 7f77d4143c80>)))
In guix/ui.scm:
  2166:12  6 (run-guix-command _ . _)
In ice-9/boot-9.scm:
  1752:10  5 (with-exception-handler _ _ #:unwind? _ # _)
  1747:15  4 (with-exception-handler #<procedure 7f77d0deeed0 at ic…> …)
In guix/scripts/discover.scm:
    141:8  3 (_)
In guix/avahi.scm:
   171:17  2 (avahi-browse-service-thread _ #:types _ #:ignore-local? …)
In unknown file:
           1 (make-client #<poll 7f77d0de41c0> () #<procedure client…>)
In ice-9/boot-9.scm:
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `avahi-error' with args `(#<avahi-error-enum Daemon not running> make-client)'.

Some kind of warning message when the daemon is not running makes sense,
but a full backtrace seems unneeded.

Maybe print a line like:

  warning: avahi daemon is not running, cannot auto-discover substitute servers!

instead.

Greetings,
Maxime.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#48561; Package guix. (Fri, 21 May 2021 13:24:02 GMT) Full text and rfc822 format available.

Message #8 received at 48561 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: Maxime Devos <maximedevos <at> telenet.be>
Cc: 48561 <at> debbugs.gnu.org
Subject: Re: bug#48561: "Daemon not running" exception when avahi-daemon is
 not running
Date: Fri, 21 May 2021 15:23:08 +0200
[Message part 1 (text/plain, inline)]
Hello Maxime,

>   warning: avahi daemon is not running, cannot auto-discover substitute servers!

This should be fixed with the attached patch.

Thanks,

Mathieu
[0001-scripts-discover-Warn-when-the-daemon-is-unreachable.patch (text/x-patch, inline)]
From a50bbf99f65d26bbdb0d16112a49335bf913b822 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe <at> gnu.org>
Date: Fri, 21 May 2021 15:21:15 +0200
Subject: [PATCH] scripts: discover: Warn when the daemon is unreachable.

* guix/scripts/discover (guix-discover): Print a warning message when the
daemon is unreachable.
---
 guix/scripts/discover.scm | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/guix/scripts/discover.scm b/guix/scripts/discover.scm
index be1eaa6e95..e42f7662d0 100644
--- a/guix/scripts/discover.scm
+++ b/guix/scripts/discover.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2020 Mathieu Othacehe <othacehe <at> gnu.org>
+;;; Copyright © 2020, 2021 Mathieu Othacehe <othacehe <at> gnu.org>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -26,6 +26,7 @@
   #:use-module (guix build syscalls)
   #:use-module (guix build utils)
   #:use-module (guix scripts publish)
+  #:use-module (avahi)
   #:use-module (ice-9 rdelim)
   #:use-module (srfi srfi-37)
   #:export (read-substitute-urls
@@ -138,5 +139,13 @@ to synchronize with the writer."
       (parameterize ((%publish-file publish-file))
         (mkdir-p (dirname publish-file))
         (false-if-exception (delete-file publish-file))
-        (avahi-browse-service-thread service-proc
-                                     #:types %services)))))
+        (catch 'avahi-error
+          (lambda ()
+            (avahi-browse-service-thread service-proc
+                                         #:types %services))
+          (lambda (key err function . _)
+            (cond
+             ((eq? err error/no-daemon)
+              (warning (G_ "Avahi daemon is not running, \
+cannot auto-discover substitutes servers.~%"))))
+            (exit 1)))))))
-- 
2.31.1


Information forwarded to bug-guix <at> gnu.org:
bug#48561; Package guix. (Fri, 21 May 2021 14:38:01 GMT) Full text and rfc822 format available.

Message #11 received at 48561 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Mathieu Othacehe <othacehe <at> gnu.org>
Cc: 48561 <at> debbugs.gnu.org
Subject: Re: bug#48561: "Daemon not running" exception when avahi-daemon is
 not running
Date: Fri, 21 May 2021 16:37:48 +0200
[Message part 1 (text/plain, inline)]
Hi Mathieu,

Mathieu Othacehe schreef op vr 21-05-2021 om 15:23 [+0200]:
> +        (catch 'avahi-error
> +          (lambda ()
> +            (avahi-browse-service-thread service-proc
> +                                         #:types %services))
> +          (lambda (key err function . _)
> +            (cond
> +             ((eq? err error/no-daemon)
> +              (warning (G_ "Avahi daemon is not running, \
> +cannot auto-discover substitutes servers.~%"))))
> +            (exit 1)))))))

Shouldn't this code print an an error message when err is something
other than error/no-daemon?  You can use error->string. Two examples
from (guile-avahi)Error handling:

2.4 Error Handling
==================

Avahi errors are implemented as Scheme exceptions (*note exceptions in
Guile: (guile)Exceptions.).  Each time a Avahi function returns an
error, an exception with key 'avahi-error' is raised.  The additional
arguments that are thrown include an error code and the name of the
Avahi procedure that raised the exception.  The error code is pretty
much like an enumerate value: it is one of the 'error/' variables
exported by the '(avahi)' module (*note Enumerates and Constants::).
Exceptions can be turned into error messages using the 'error->string'
procedure.

   The following examples illustrates how Avahi exceptions can be
handled:

     (let ((poll (make-simple-poll)))

       ;;
       ;; ...
       ;;

       (catch 'avahi-error
         (lambda ()
           (run-simple-poll (simple-poll poll)))
         (lambda (key err function . currently-unused)
           (format (current-error-port)
                   "an Avahi error was raised by `~a': ~a~%"
                   function (error->string err)))))

   Again, error values can be compared using 'eq?':

         ;; `avahi-error' handler.
         (lambda (key err function . currently-unused)
           (if (eq? err error/no-daemon)
               (format (current-error-port)
                       "~a: the Avahi daemon is not running~%"
                       function)))

Otherwise LGTM, but I haven't tested.

Greetings,
Maxime.
[signature.asc (application/pgp-signature, inline)]

Reply sent to Mathieu Othacehe <othacehe <at> gnu.org>:
You have taken responsibility. (Sat, 22 May 2021 12:07:02 GMT) Full text and rfc822 format available.

Notification sent to Maxime Devos <maximedevos <at> telenet.be>:
bug acknowledged by developer. (Sat, 22 May 2021 12:07:02 GMT) Full text and rfc822 format available.

Message #16 received at 48561-done <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <othacehe <at> gnu.org>
To: Maxime Devos <maximedevos <at> telenet.be>
Cc: 48561-done <at> debbugs.gnu.org
Subject: Re: bug#48561: "Daemon not running" exception when avahi-daemon is
 not running
Date: Sat, 22 May 2021 14:06:35 +0200
Hey,

> Otherwise LGTM, but I haven't tested.

Fixed with 7003b2db526fc367664f3a7c4bdbe38a7c717da6.

Thanks,

Mathieu




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 20 Jun 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 311 days ago.

Previous Next


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