GNU bug report logs -
#76698
Activations interfere with each other modules
Previous Next
Reported by: Tomas Volf <~@wolfsden.cz>
Date: Mon, 3 Mar 2025 01:03:02 UTC
Severity: normal
Merged with 77365
Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To reply to this bug, email your comments to 76698 AT debbugs.gnu.org.
There is no need to reopen the bug first.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-guix <at> gnu.org
:
bug#76698
; Package
guix
.
(Mon, 03 Mar 2025 01:03:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Tomas Volf <~@wolfsden.cz>
:
New bug report received and forwarded. Copy sent to
bug-guix <at> gnu.org
.
(Mon, 03 Mar 2025 01:03:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hello,
when using `activation-service-type' combined with `with-extension', the
various modules seem to interfere with each other.
In my case the samba-service-type interferes with my custom service:
--8<---------------cut here---------------start------------->8---
(define (watcher-activation* config)
(match-record config <watcher-configuration>
(user group cache-dir state-dir)
(with-extension/guile-wolfsden
#~(begin
(use-modules (wolfsden fs)
(wolfsden sh))
(for-each (lambda (dir)
(mkdir-p dir)
(invoke* #$(file-append coreutils "/bin/chown")
"-Rv" (string-append #$user ":" #$group) dir)
(chmod dir #o700))
'(#$cache-dir
#$state-dir))))))
--8<---------------cut here---------------end--------------->8---
samba-service-type's activation starts with:
--8<---------------cut here---------------start------------->8---
(define (samba-activation config)
(let ((package (samba-configuration-package config))
(config-file (samba-configuration-config-file config)))
(with-imported-modules '((guix build utils))
--8<---------------cut here---------------end--------------->8---
Both (guix build utils) and (wolfsden sh) provide (invoke) procedure,
however with incompatible parameters, leading to somewhat annoying to
debug issues. In my case the error was:
--8<---------------cut here---------------start------------->8---
guix deploy: error: failed to deploy x: failed to switch systems while deploying '127.0.0.1':
keyword-argument-error #f "Invalid keyword" () ("/etc/samba/smb.conf")
--8<---------------cut here---------------end--------------->8---
Which makes sense now when I understand what the problem is, but it took
while to get to it.
I do not think this should be the case. Either each activation service
should be isolated into a fresh user module, or the services provided by
Guix should not introduce any additional modules into the scope.
Alternatively, each activation service could be wrapped into
program-file, that would ensure isolation as well.
Tomas
--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
Information forwarded
to
bug-guix <at> gnu.org
:
bug#76698
; Package
guix
.
(Thu, 06 Mar 2025 03:14:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 76698 <at> debbugs.gnu.org (full text, mbox):
Hi Tomas,
On Mon, 03 Mar 2025 09:02:22 +0800,
Tomas Volf wrote:
>
> Hello,
>
> when using `activation-service-type' combined with `with-extension', the
> various modules seem to interfere with each other.
>
> In my case the samba-service-type interferes with my custom service:
>
> --8<---------------cut here---------------start------------->8---
> (define (watcher-activation* config)
> (match-record config <watcher-configuration>
> (user group cache-dir state-dir)
> (with-extension/guile-wolfsden
> #~(begin
> (use-modules (wolfsden fs)
> (wolfsden sh))
> (for-each (lambda (dir)
> (mkdir-p dir)
> (invoke* #$(file-append coreutils "/bin/chown")
> "-Rv" (string-append #$user ":" #$group) dir)
> (chmod dir #o700))
> '(#$cache-dir
> #$state-dir))))))
> --8<---------------cut here---------------end--------------->8---
>
> samba-service-type's activation starts with:
>
> --8<---------------cut here---------------start------------->8---
> (define (samba-activation config)
> (let ((package (samba-configuration-package config))
> (config-file (samba-configuration-config-file config)))
> (with-imported-modules '((guix build utils))
> --8<---------------cut here---------------end--------------->8---
>
> Both (guix build utils) and (wolfsden sh) provide (invoke) procedure,
> however with incompatible parameters, leading to somewhat annoying to
> debug issues. In my case the error was:
>
> --8<---------------cut here---------------start------------->8---
> guix deploy: error: failed to deploy x: failed to switch systems while deploying '127.0.0.1':
> keyword-argument-error #f "Invalid keyword" () ("/etc/samba/smb.conf")
> --8<---------------cut here---------------end--------------->8---
>
> Which makes sense now when I understand what the problem is, but it took
> while to get to it.
>
> I do not think this should be the case. Either each activation service
> should be isolated into a fresh user module, or the services provided by
> Guix should not introduce any additional modules into the scope.
> Alternatively, each activation service could be wrapped into
> program-file, that would ensure isolation as well.
Activation scripts are already ‘program-file’s, but unfortunately
(gnu build activation) and (guix build utils) are implicit dependencies. This
is hard to change at the moment.
I have sent a patch which might partially address your issue:
[PATCH v2 3/3] services: activation: Continue on exceptions.
https://issues.guix.gnu.org/73494#26
It executes activation scripts by ‘invoke’, so they won't change the
environment.
What I'm trying to achieve is to avoid blocking the activation process when one
script fails.
With that patch, when one script fails, its backtrace is printed out by
‘invoke’, additionally a warning is emitted to indicate the failed script:
--8<---------------cut here---------------start------------->8---
activating system...
The following derivation will be built:
/gnu/store/78x8n7b58nqcllfqfpr4p73q6n2wazak-switch-to-system.scm.drv
building /gnu/store/78x8n7b58nqcllfqfpr4p73q6n2wazak-switch-to-system.scm.drv...
making '/var/guix/profiles/system-110-link' the current system...
populating /etc from /gnu/store/v206hfm2idagh2nczc6ii0m628xyg5dk-etc...
setting up privileged programs in '/run/privileged/bin'...
Backtrace:
3 (primitive-load "/gnu/store/59651880cmil350zf5hagyhdi7y…")
In ice-9/eval.scm:
619:8 2 (_ #f)
619:8 1 (_ #(#(#(#(#<directory (guile-user) 7fdc0c317…>) …) …) …))
In unknown file:
0 (rmdir "/var/run/dbus")
ERROR: In procedure rmdir:
In procedure rmdir: Directory not empty
guix system: warning: failed to activate '/gnu/store/59651880cmil350zf5hagyhdi7y66dgz-activate-service.scm'.
The following derivation will be built:
/gnu/store/m1c65sxmqvvpfdsazcka51miixcpsy9g-install-bootloader.scm.drv
building /gnu/store/m1c65sxmqvvpfdsazcka51miixcpsy9g-install-bootloader.scm.drv...
guix system: bootloader successfully installed on '(/efi)'
--8<---------------cut here---------------end--------------->8---
(Cc'd Ludo) Any concern on this change? Does the "TODO: Use 'load-compiled'."
still apply?
Information forwarded
to
bug-guix <at> gnu.org
:
bug#76698
; Package
guix
.
(Fri, 07 Mar 2025 21:30:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 76698 <at> debbugs.gnu.org (full text, mbox):
Hilton Chain <hako <at> ultrarare.space> writes:
> Hi Tomas,
>
> On Mon, 03 Mar 2025 09:02:22 +0800,
> Tomas Volf wrote:
>>
>> Hello,
>>
>> when using `activation-service-type' combined with `with-extension', the
>> various modules seem to interfere with each other.
>>
>> In my case the samba-service-type interferes with my custom service:
>>
>> --8<---------------cut here---------------start------------->8---
>> (define (watcher-activation* config)
>> (match-record config <watcher-configuration>
>> (user group cache-dir state-dir)
>> (with-extension/guile-wolfsden
>> #~(begin
>> (use-modules (wolfsden fs)
>> (wolfsden sh))
>> (for-each (lambda (dir)
>> (mkdir-p dir)
>> (invoke* #$(file-append coreutils "/bin/chown")
>> "-Rv" (string-append #$user ":" #$group) dir)
>> (chmod dir #o700))
>> '(#$cache-dir
>> #$state-dir))))))
>> --8<---------------cut here---------------end--------------->8---
>>
>> samba-service-type's activation starts with:
>>
>> --8<---------------cut here---------------start------------->8---
>> (define (samba-activation config)
>> (let ((package (samba-configuration-package config))
>> (config-file (samba-configuration-config-file config)))
>> (with-imported-modules '((guix build utils))
>> --8<---------------cut here---------------end--------------->8---
>>
>> Both (guix build utils) and (wolfsden sh) provide (invoke) procedure,
>> however with incompatible parameters, leading to somewhat annoying to
>> debug issues. In my case the error was:
>>
>> --8<---------------cut here---------------start------------->8---
>> guix deploy: error: failed to deploy x: failed to switch systems while deploying '127.0.0.1':
>> keyword-argument-error #f "Invalid keyword" () ("/etc/samba/smb.conf")
>> --8<---------------cut here---------------end--------------->8---
>>
>> Which makes sense now when I understand what the problem is, but it took
>> while to get to it.
>>
>> I do not think this should be the case. Either each activation service
>> should be isolated into a fresh user module, or the services provided by
>> Guix should not introduce any additional modules into the scope.
>> Alternatively, each activation service could be wrapped into
>> program-file, that would ensure isolation as well.
>
> Activation scripts are already ‘program-file’s,
Ah, yes, on second look you are right. I did not realized at first,
since they are sourced using primitive-load instead of executed.
> but unfortunately (gnu build activation) and (guix build utils) are
> implicit dependencies. This is hard to change at the moment.
I do not think this is true. When I look at the activation script for
my service, I do not see any additional code then my service has. So
assuming it would be executed, instead of loaded, (guix build utils)
should not be in the environment. Am I missing something?
>
> I have sent a patch which might partially address your issue:
>
> [PATCH v2 3/3] services: activation: Continue on exceptions.
> https://issues.guix.gnu.org/73494#26
>
> It executes activation scripts by ‘invoke’, so they won't change the
> environment.
>
> What I'm trying to achieve is to avoid blocking the activation process when one
> script fails.
Well, that patch would probably resolve my issues, correct. What I am
unsure about is whether ignoring errors is a good idea and what (if any)
impact it will have on the rest of the deploy process. Like, if the
activation fails, would it not be better to rollback instead of push
forward? Dunno, I probably just do not know enough about this. :)
Tomas
--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
Information forwarded
to
bug-guix <at> gnu.org
:
bug#76698
; Package
guix
.
(Sun, 09 Mar 2025 05:21:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 76698 <at> debbugs.gnu.org (full text, mbox):
On Sat, 08 Mar 2025 05:29:51 +0800,
Tomas Volf wrote:
>
> > but unfortunately (gnu build activation) and (guix build utils) are
> > implicit dependencies. This is hard to change at the moment.
>
> I do not think this is true. When I look at the activation script for
> my service, I do not see any additional code then my service has. So
> assuming it would be executed, instead of loaded, (guix build utils)
> should not be in the environment. Am I missing something?
(gnu build activation) and (guix build utils) are added to the environment
before loading activation scripts, existing activation services may depend on
this. For example firmware-service-type uses ‘activate-firmware’ directly
without importing (gnu build activation).
> > I have sent a patch which might partially address your issue:
> >
> > [PATCH v2 3/3] services: activation: Continue on exceptions.
> > https://issues.guix.gnu.org/73494#26
> >
> > It executes activation scripts by ‘invoke’, so they won't change the
> > environment.
> >
> > What I'm trying to achieve is to avoid blocking the activation process when one
> > script fails.
>
> Well, that patch would probably resolve my issues, correct. What I am
> unsure about is whether ignoring errors is a good idea and what (if any)
> impact it will have on the rest of the deploy process. Like, if the
> activation fails, would it not be better to rollback instead of push
> forward? Dunno, I probably just do not know enough about this. :)
Makes sense, but too late at this stage since it's already switched to the new
generation before activation.
The current behavior is, one failed activation breaks the whole activation
process, without a clear indication. As a result, all services depending on
activation may fail. And I want to limit failed services to relevant ones.
Information forwarded
to
bug-guix <at> gnu.org
:
bug#76698
; Package
guix
.
(Sun, 09 Mar 2025 11:39:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 76698 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hilton Chain <hako <at> ultrarare.space> writes:
> On Sat, 08 Mar 2025 05:29:51 +0800,
> Tomas Volf wrote:
>>
>> > but unfortunately (gnu build activation) and (guix build utils) are
>> > implicit dependencies. This is hard to change at the moment.
>>
>> I do not think this is true. When I look at the activation script for
>> my service, I do not see any additional code then my service has. So
>> assuming it would be executed, instead of loaded, (guix build utils)
>> should not be in the environment. Am I missing something?
>
> (gnu build activation) and (guix build utils) are added to the environment
> before loading activation scripts, existing activation services may depend on
> this. For example firmware-service-type uses ‘activate-firmware’ directly
> without importing (gnu build activation).
I am not sure I follow. When I have an activation service looking like:
--8<---------------cut here---------------start------------->8---
#~(mkdir "/x")
--8<---------------cut here---------------end--------------->8---
The generated file looks like the following:
--8<---------------cut here---------------start------------->8---
#!/gnu/store/ylwk2vn18dkzkj0nxq2h4vjzhz17bm7c-guile-3.0.9/bin/guile --no-auto-compile
!#
(mkdir "/x")
--8<---------------cut here---------------end--------------->8---
Wait... When I looked again I have now noticed that your patch actually
modifies the activation-script procedure to explicitly add the modules.
It did not do that before. That is a shame. Would it not be better to
just add the appropriate use-modules into the services that are missing
them?
I am not sure these two modules being available is documented anywhere,
so in-tree users can be fixed, and out-of-tree users are relying on
something they should not assume (so they should be fixed as well,
possibly with some deprecation period).
>
>> > I have sent a patch which might partially address your issue:
>> >
>> > [PATCH v2 3/3] services: activation: Continue on exceptions.
>> > https://issues.guix.gnu.org/73494#26
>> >
>> > It executes activation scripts by ‘invoke’, so they won't change the
>> > environment.
>> >
>> > What I'm trying to achieve is to avoid blocking the activation process when one
>> > script fails.
>>
>> Well, that patch would probably resolve my issues, correct. What I am
>> unsure about is whether ignoring errors is a good idea and what (if any)
>> impact it will have on the rest of the deploy process. Like, if the
>> activation fails, would it not be better to rollback instead of push
>> forward? Dunno, I probably just do not know enough about this. :)
>
> Makes sense, but too late at this stage since it's already switched to the new
> generation before activation.
>
> The current behavior is, one failed activation breaks the whole activation
> process, without a clear indication. As a result, all services depending on
> activation may fail. And I want to limit failed services to relevant
> ones.
I see. Makes sense, thanks for explanation.
Tomas
--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
bug-guix <at> gnu.org
:
bug#76698
; Package
guix
.
(Wed, 12 Mar 2025 08:46:01 GMT)
Full text and
rfc822 format available.
Message #20 received at 76698 <at> debbugs.gnu.org (full text, mbox):
On Sun, 09 Mar 2025 19:38:51 +0800,
Tomas Volf wrote:
>
> I am not sure these two modules being available is documented anywhere,
> so in-tree users can be fixed, and out-of-tree users are relying on
> something they should not assume (so they should be fixed as well,
> possibly with some deprecation period).
Sure, the period is at least one year I think, and a news entry is needed. I'll
change Guix Home to use ‘invoke’ for activation as well.
Information forwarded
to
bug-guix <at> gnu.org
:
bug#76698
; Package
guix
.
(Mon, 17 Mar 2025 19:57:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 76698 <at> debbugs.gnu.org (full text, mbox):
Hello,
Hilton Chain <hako <at> ultrarare.space> skribis:
> Activation scripts are already ‘program-file’s, but unfortunately
> (gnu build activation) and (guix build utils) are implicit dependencies. This
> is hard to change at the moment.
>
> I have sent a patch which might partially address your issue:
>
> [PATCH v2 3/3] services: activation: Continue on exceptions.
> https://issues.guix.gnu.org/73494#26
>
> It executes activation scripts by ‘invoke’, so they won't change the
> environment.
Activation snippets all run in the same Guile process so far, mostly out
of a concern to be more efficient than running each one in a separate
process as you suggest.
The downside is what Tomas found out: the load path is global to the
entire set of activation snippets.
Now, maybe we could have the best of both worlds: instead of
‘activation-script’ doing
(for-each primitive-load '#$actions)
it could do something like:
(for-each (lambda (action)
(guard … ;like Hilton suggests
(save-module-excursion
(lambda ()
(set-current-module (resolve-module '(guile-user)))
(primitive-load action)))))
'#$actions)
Thoughts?
Ludo’.
Information forwarded
to
bug-guix <at> gnu.org
:
bug#76698
; Package
guix
.
(Mon, 17 Mar 2025 21:37:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 76698 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:
> Hello,
>
> Hilton Chain <hako <at> ultrarare.space> skribis:
>
>> Activation scripts are already ‘program-file’s, but unfortunately
>> (gnu build activation) and (guix build utils) are implicit dependencies. This
>> is hard to change at the moment.
>>
>> I have sent a patch which might partially address your issue:
>>
>> [PATCH v2 3/3] services: activation: Continue on exceptions.
>> https://issues.guix.gnu.org/73494#26
>>
>> It executes activation scripts by ‘invoke’, so they won't change the
>> environment.
>
> Activation snippets all run in the same Guile process so far, mostly out
> of a concern to be more efficient than running each one in a separate
> process as you suggest.
>
> The downside is what Tomas found out: the load path is global to the
> entire set of activation snippets.
>
> Now, maybe we could have the best of both worlds: instead of
> ‘activation-script’ doing
>
> (for-each primitive-load '#$actions)
>
> it could do something like:
>
> (for-each (lambda (action)
> (guard … ;like Hilton suggests
> (save-module-excursion
> (lambda ()
> (set-current-module (resolve-module '(guile-user)))
> (primitive-load action)))))
> '#$actions)
>
> Thoughts?
+1 for the approach, for implementation I think you need
(make-fresh-user-module) instead of (resolve-module '(guile-user)).
>
> Ludo’.
--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
bug-guix <at> gnu.org
:
bug#76698
; Package
guix
.
(Wed, 02 Apr 2025 05:42:04 GMT)
Full text and
rfc822 format available.
Message #29 received at 76698 <at> debbugs.gnu.org (full text, mbox):
Hi,
[...]
>> Activation snippets all run in the same Guile process so far, mostly out
>> of a concern to be more efficient than running each one in a separate
>> process as you suggest.
>>
>> The downside is what Tomas found out: the load path is global to the
>> entire set of activation snippets.
>>
>> Now, maybe we could have the best of both worlds: instead of
>> ‘activation-script’ doing
>>
>> (for-each primitive-load '#$actions)
>>
>> it could do something like:
>>
>> (for-each (lambda (action)
>> (guard … ;like Hilton suggests
>> (save-module-excursion
>> (lambda ()
>> (set-current-module (resolve-module '(guile-user)))
>> (primitive-load action)))))
>> '#$actions)
>>
>> Thoughts?
Sounds like a nice improvement over what we currently have, though
without having measured the impact of using multiple processes perhaps
it is premature to optimize to use a single process (guile has
a notoriously fast startup time so it may not matter much).
Still, +1 on this improvement from me.
--
Thanks,
Maxim
Merged 76698 77365.
Request was from
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Wed, 02 Apr 2025 05:43:03 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
77365 <at> debbugs.gnu.org and Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Request was from
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Mon, 26 May 2025 13:17:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 17 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.