"Daemon not running" exception when avahi-daemon is not running

  • Done
  • quality assurance status badge
Details
2 participants
  • Maxime Devos
  • Mathieu Othacehe
Owner
unassigned
Submitted by
Maxime Devos
Severity
minor
M
M
Maxime Devos wrote on 21 May 2021 10:48
(address . bug-guix@gnu.org)
2d3636af080e6bcddc6ba94dc162260c0e73ed54.camel@telenet.be
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.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYKdz9RccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7kaUAQDgmZpI6l3LnTECZfpOlA0T2wqH
8CXMyrFwEdcuNfDp9gD/bNdp9hHLMNFxANS0vaVAuF0i3bjhVTb3SjgH2VpKXgQ=
=CwcT
-----END PGP SIGNATURE-----


M
M
Mathieu Othacehe wrote on 21 May 2021 15:23
(name . Maxime Devos)(address . maximedevos@telenet.be)(address . 48561@debbugs.gnu.org)
87im3cqkzn.fsf@gnu.org
Hello Maxime,

Toggle quote (2 lines)
> warning: avahi daemon is not running, cannot auto-discover substitute servers!

This should be fixed with the attached patch.

Thanks,

Mathieu
From a50bbf99f65d26bbdb0d16112a49335bf913b822 Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <othacehe@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(-)

Toggle diff (37 lines)
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@gnu.org>
+;;; Copyright © 2020, 2021 Mathieu Othacehe <othacehe@gnu.org>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@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
M
M
Maxime Devos wrote on 21 May 2021 16:37
(name . Mathieu Othacehe)(address . othacehe@gnu.org)(address . 48561@debbugs.gnu.org)
a0c712f64a1008c7d62a41a00e1081016066fc85.camel@telenet.be
Hi Mathieu,

Mathieu Othacehe schreef op vr 21-05-2021 om 15:23 [+0200]:
Toggle quote (11 lines)
> + (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.
-----BEGIN PGP SIGNATURE-----

iI0EABYKADUWIQTB8z7iDFKP233XAR9J4+4iGRcl7gUCYKfFvBccbWF4aW1lZGV2
b3NAdGVsZW5ldC5iZQAKCRBJ4+4iGRcl7iObAQCoPrIebwJ6Om7X7JkhRUmyGgjG
o8fwjpdo5o0iRUR29AEA7Kqfv3dCjFEM7H54h/9R5ckO1Shy6dwOq1nJh/4cMww=
=ignq
-----END PGP SIGNATURE-----


M
M
Mathieu Othacehe wrote on 22 May 2021 14:06
(name . Maxime Devos)(address . maximedevos@telenet.be)(address . 48561-done@debbugs.gnu.org)
87r1hznfas.fsf@gnu.org
Hey,

Toggle quote (2 lines)
> Otherwise LGTM, but I haven't tested.

Fixed with 7003b2db526fc367664f3a7c4bdbe38a7c717da6.

Thanks,

Mathieu
Closed
?