GNU bug report logs - #28128
[PATCH] scripts: system: Add support for container network sharing.

Previous Next

Package: guix-patches;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Thu, 17 Aug 2017 19:14:01 UTC

Severity: normal

Tags: patch

Done: Arun Isaac <arunisaac <at> systemreboot.net>

Bug is archived. No further changes may be made.

Full log


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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Arun Isaac <arunisaac <at> systemreboot.net>
Cc: mail <at> cbaines.net, 28128 <at> debbugs.gnu.org
Subject: Re: [PATCH 2/2] scripts: system: Support container network sharing.
Date: Wed, 13 Mar 2019 12:34:26 +0100
Hello!

Some comments below.

Arun Isaac <arunisaac <at> systemreboot.net> skribis:

> * gnu/services.scm (shared-network-service-type): New variable.
> * gnu/services/base.scm (%base-services): Add shared-network-service.
> * gnu/system.scm (essential-services): If shared-network-service exists,
> extend it to add /etc/services, /etc/nsswitch.conf and /etc/hosts.
> (operating-system-etc-service): Do not add /etc/services, /etc/nsswitch.conf
> and /etc/hosts.
> * gnu/system/linux-container.scm (container-script): Support returning a
> container script that shares the host network.
> * guix/scripts/system.scm (system-derivation-for-action, perform-action): Add
> #:container-shared-network? argument.
> (show-help): Add "-N, --network" help information.
> (%options): Add network option.
> (process-action): Call perform-action with #:container-shared-network?.
>
> Co-authored-by: Christopher Baines <mail <at> cbaines.net>

[...]

> +(define shared-network-service-type
> +  (service-type (name 'shared-network)
> +                (extensions (list (service-extension etc-service-type identity)))
> +                (compose concatenate)
> +                (extend append)
> +                (default-value '())))

I’d encourage you to add a ‘description’ field as well.  :-)

> --- a/gnu/system.scm
> +++ b/gnu/system.scm
> @@ -5,6 +5,7 @@
>  ;;; Copyright © 2016 Chris Marusich <cmmarusich <at> gmail.com>
>  ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe <at> gmail.com>
>  ;;; Copyright © 2019 Meiyo Peng <meiyo.peng <at> gmail.com>
> +;;; Copyright © 2019 Arun Isaac <arunisaac <at> systemreboot.net>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -501,7 +502,21 @@ a container or that of a \"bare metal\" system."
>                         (list %containerized-shepherd-service)
>                         (list %linux-bare-metal-service
>                               (service firmware-service-type
> -                                      (operating-system-firmware os))))))))
> +                                      (operating-system-firmware os))))
> +                   (if (find (lambda (service)
> +                               (eq? (service-type-name (service-kind service))
> +                                    'shared-network))
> +                             (operating-system-user-services os))
> +                       (let ((nsswitch (plain-file "nsswitch.conf"
> +                                                   (name-service-switch->string
> +                                                    (operating-system-name-service-switch os)))))
> +                         (list (simple-service 'shared-network-extension
> +                                               shared-network-service-type
> +                                               `(("services" ,(file-append net-base "/etc/services"))
> +                                                 ("nsswitch.conf" ,#~#$nsswitch)
> +                                                 ("hosts" ,#~#$(or (operating-system-hosts-file os)
> +                                                                   (default-/etc/hosts (operating-system-host-name os))))))))
> +                       (list))))))

A couple of things:

  1. ‘service-type-name’ exists for debugging purposes, and I think we
     shouldn’t rely on it at all in our code.  Instead, we should
     compare service types by identity, as in:

       (eq? (service-kind service) foo-service-type)

  2. The notion of “shared network” is very much a container (or VM)
     thing, so somehow it still doesn’t feel right to me that (gnu
     system) has to be aware of these special cases.

I think the ‘host-database-service-type’ wouldn’t have this problem, but
maybe it has other issues.  I guess this needs more experimentation,
sorry for not coming up with clearer ideas!

Ludo’.




This bug report was last modified 6 years and 104 days ago.

Previous Next


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