Subject: Re: bug#27386: offloading documentation and env

From: [email-masked] (Ludovic Courtès)
Date: Fri, 07 Jul 2017 12:00:43 +0200

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

‘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.

>> What does “ssh [email-masked] -i KEY cat /proc/loadavg” return,
>> where USER and KEY are those specified in your machines.scm file?
>
> natsu@clover ~$ 
> (list (build-machine
>              (name "magnolia.local")
>              (system "x86_64-linux")
> 	     (host-key "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMRy+enQECs2CsjrbSIfnNHExcUwzHFa7KUnhwDIeWOV")
>              (user "natsu")
> 	     (private-key
> 	      (string-append (getenv "HOME")
> 			     "/.ssh/identity-for-guix"))
>              (speed 2.)))
> ssh [email-masked] -i $HOME/.ssh/identity-for-guix cat /proc/loadavg
> 0.05 0.08 0.02 1/247 13756

Hmm, looks good.

Ludo’.