Subject: [SOLVED] Re: bug#27386: offloading documentation and env

From: Oleg Pykhalov <[email-masked]>
Date: Fri, 07 Jul 2017 23:31:38 +0300

[email-masked] (Ludovic Courtès) writes:

> Oleg Pykhalov <[email-masked]> skribis:
>
>> [email-masked] (Ludovic Courtès) writes:
>>
>>> Hmm could it be that ‘machine-load’ in (guix scripts offload) always
>>> returns +inf.0, for instance because it fails to run “cat /proc/loadavg”
>>> on the remote machine?  (If it succeeded we would see the message “load
>>> on machine XYZ is N”.)
>>>
>>>   https://git.savannah.gnu.org/cgit/guix.git/tree/guix/scripts/offload.scm#n393
>>
>> Can I actually look what is happening somehow?
>
> Yes, you can make a checkout of Guix, add ‘pk’ calls in (guix scripts
> offload) (see below), and run the daemon from there:
>
>   ./pre-inst-env guix-daemon --build-users-group=guixbuild

Note for somebody else having similar issue:
sudo -E ./pre-inst-env guix-daemon --build-users-group=guixbuild

> ‘pk’ is a function that prints its argument and returns it, so you could
> do:
>
> diff --git a/guix/scripts/offload.scm b/guix/scripts/offload.scm
> index 566d117b0..0dd849942 100644
> --- a/guix/scripts/offload.scm
> +++ b/guix/scripts/offload.scm
> @@ -398,7 +398,7 @@ allowed on MACHINE.  Return +∞ if MACHINE is unreachable."
>      ((? session? session)
>       (let* ((pipe (open-remote-pipe* session OPEN_READ
>                                       "cat" "/proc/loadavg"))
> -            (line (read-line pipe)))
> +            (line (pk 'line (read-line pipe))))
>         (close-port pipe)
>  
>         (if (eof-object? line)
>
>
> to print the line that is read.

(Skip bellow this stupid text to Solution)

I don't see any sshd message during `guix build` in `/var/log/messages`
on build machine.  Not any message in STDOUT on build machine, too.
`/var/log/guix-daemon.log` is silent, too.

I made above diff change on build machine and notebook.  On notebook I
get `accepted connection from pid 2576, user natsu` in
`/var/log/guix-daemon.log` AND `process 2587 acquired build slot
'/var/guix/offload/magnolia.local/0` in STDOUT.  `/var/log/messages` no
changes.

pk is silent :-(

So, I thought, if no sshd log on build machine, why?  I did
`./pre-inst-env guix offload test` and got a `guix offload: testing 0
build machines defined in '/usr/local/etc/guix/machines.scm'...`.

Adding `--prefix=/` in ./configure helped, but I got
'//etc/guix/machines.scm.  Maybe need set `--prefix=''`.

`./pre-inst-env guix offload` succeeded. `/var/log/guix-daemon.log`
reports like 'accepted connection from pid 2694, user natsu'
messages. `/var/log/messages` reports about sshd successfully
connections.

But I still failed with `build` command.

I also checked how to get some logs in
https://lists.gnu.org/archive/html/guix-devel/2014-03/msg00264.html and
made some logs.

.

Solution
========

https://lists.gnu.org/archive/html/help-guix/2017-05/msg00196.html

> The ‘guix offload’ command is invoked by guix-daemon as root.  So when
> it is invoked, (getenv "HOME") returns "/root" or similar.  Could that
> be the problem?

So, I need a ssh key pair in /root too!

May be put this in doc?  I prepared a patch for this.
From e119cf8cdc3eaa5774e44a301f1bcc975c31ce41 Mon Sep 17 00:00:00 2001
From: Oleg Pykhalov <[email-masked]>
Date: Fri, 7 Jul 2017 23:25:40 +0300
Subject: [PATCH] doc: Add note about private-key during offload.

* doc/guix.texi (Using the Offload Facility): Add note about private-key.
---
 doc/guix.texi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index eab1704d4..8d1b2ff3d 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -947,6 +947,10 @@ Port number of SSH server on the machine.
 The SSH private key file to use when connecting to the machine, in
 OpenSSH format.
 
+Note that during ‘guix build’ the ‘guix offload’ command is invoked by
+guix-daemon as root.  So when it is invoked, (getenv "HOME") returns
+"/root".  Be sure that root account has access to private-key.
+
 @item @code{compression} (default: @code{"zlib@@openssh.com,zlib"})
 @itemx @code{compression-level} (default: @code{3})
 The SSH-level compression methods and compression level requested.
-- 
2.13.2