From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:1008:1e59::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id EGq2BsGgV2Y4DwEAA41jLg (envelope-from ) for ; Wed, 29 May 2024 23:40:17 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id OI7FAMGgV2bMPQAA62LTzQ (envelope-from ) for ; Wed, 29 May 2024 23:40:17 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=autistici.org header.s=stigmate header.b=rUshopFw; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1717018816; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=dYNFlJvCIPj1IpiBTm/0Bkd4FI18jAmcFmPwVBTWp30=; b=ZO2CP5BS8fgyOP+DLEXDujCmYHz4y7ZiHZbGPqpBqMSTNuvJ8+Q+lZiWRzHYx4IEjvRKnU biob4rUdzHrriwE8CZOayHAx/OSNOIwyOhs8CP+dVvqnknfv0d9n3/Pm87bgPaWnKdWowC jJH7YBsrkw8eZEag2mCxD+qc3uajWKSZR7RoEWXvbHOlnSPD0LE/7CD4abMCC0cPqTJUVH l19MGIC+kOHdPPkGBzZ+RltjxmEUqrEsvvkkTPzMMuLduM0wI+9vUDH+6uRdQelg6eHSYl qLkZ9+4xNW5lIEHqm5piVjh/3t1jrqcuT/6YJTxcsj11xAQxBGCMT6QsI8cHiQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1717018816; a=rsa-sha256; cv=none; b=cQokipT/GAmW0IxP3EUTxNPEwv07AUHm8/8T0c3jqaWEyneFQgB/RSUlGRI23EiXl18MNC yTmxGTfYQFxn6CFSouxg4JSnJt++Rsk7ENZnMN1+UBLYReAeSrCSfkW90ScA6d/rLoK9Ap Fm2aAmGknPX7UZSEvpoPOnDbwdjfLIvi7yMY1V5FWY/ZmJiJu4z8LCkPbjrxBYLGKJtBf4 ql0/WnSCIATV7c8iJH7SC6K3WBIjSRmw3H1nSbtuGh7ROYXbFuilliE0fm98jtPaebIbBq PTRGYIDk2bfNhl8bpOaO934t8jh4LqEdYcdHxUFVLCtF/Rzagqf6XFwCZKlcTQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=autistici.org header.s=stigmate header.b=rUshopFw; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CA46F7021B for ; Wed, 29 May 2024 23:40:16 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCR1a-0000p1-V5; Wed, 29 May 2024 17:39:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCR1Z-0000oQ-GI for guix-patches@gnu.org; Wed, 29 May 2024 17:39:57 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sCR1Z-0001os-7F; Wed, 29 May 2024 17:39:57 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sCR1i-0008E3-EZ; Wed, 29 May 2024 17:40:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#71263] [PATCH 5/5] gnu: docker: Allow setting Shepherd actions in oci-container-configuration. Resent-From: Giacomo Leidi Original-Sender: "Debbugs-submit" Resent-CC: pelzflorian@pelzflorian.de, ludo@gnu.org, matt@excalamus.com, maxim.cournoyer@gmail.com, guix-patches@gnu.org Resent-Date: Wed, 29 May 2024 21:40:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71263 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 71263@debbugs.gnu.org Cc: Giacomo Leidi , Florian Pelz , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer X-Debbugs-Original-Xcc: Florian Pelz , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Matthew Trzcinski , Maxim Cournoyer Received: via spool by 71263-submit@debbugs.gnu.org id=B71263.171701877831477 (code B ref 71263); Wed, 29 May 2024 21:40:06 +0000 Received: (at 71263) by debbugs.gnu.org; 29 May 2024 21:39:38 +0000 Received: from localhost ([127.0.0.1]:55977 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR1F-0008BY-DC for submit@debbugs.gnu.org; Wed, 29 May 2024 17:39:37 -0400 Received: from confino.investici.org ([93.190.126.19]:27333) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sCR19-0008Af-7y for 71263@debbugs.gnu.org; Wed, 29 May 2024 17:39:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1717018753; bh=dYNFlJvCIPj1IpiBTm/0Bkd4FI18jAmcFmPwVBTWp30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rUshopFwlaSCxA9ajS0wwwnuzUPjeYzVq6EmoFc5CKeTS1Qu0eMZ1fLZaAb8op+W2 3o/haFBFeftmOFEj2Pg8dBc17NVOJl7cM85ZbVLKib2sT51co2SuA1EpqaHlD0B/a8 sgRYgW4mmRWVJNiOfz39r84xS4SKp3zBxVFDfiWs= Received: from mx1.investici.org (unknown [127.0.0.1]) by confino.investici.org (Postfix) with ESMTP id 4VqN7P2lB1z1117; Wed, 29 May 2024 21:39:13 +0000 (UTC) Received: from [93.190.126.19] (mx1.investici.org [93.190.126.19]) (Authenticated sender: goodoldpaul@autistici.org) by localhost (Postfix) with ESMTPSA id 4VqN7P2C32z110x; Wed, 29 May 2024 21:39:13 +0000 (UTC) Date: Wed, 29 May 2024 23:38:56 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> References: <31ff6a93a8c7b50e5152f75b091b28851d5c4cc8.1717018735.git.goodoldpaul@autistici.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Giacomo Leidi X-ACL-Warn: , Giacomo Leidi via Guix-patches From: Giacomo Leidi via Guix-patches via Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -1.95 X-Spam-Score: -1.95 X-Migadu-Queue-Id: CA46F7021B X-Migadu-Scanner: mx11.migadu.com X-TUID: 5S4jRvRKNNAU * gnu/services/docker.scm (oci-container-configuration) [shepherd-actions]: New field; (sanitize-shepherd-actions): sanitize it; (oci-container-shepherd-service): use it. Change-Id: I0ca9826542be7cb8ca280a07a9bff1a262c2a8a7 --- doc/guix.texi | 4 ++++ gnu/services/docker.scm | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 9abdc77869..4c137ee31e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -40657,6 +40657,10 @@ Miscellaneous Services Whether to have Shepherd restart the service when it stops, for instance when the underlying process dies. +@item @code{shepherd-actions} (default: @code{'()}) (type: list-of-symbols) +This is a list of @code{shepherd-action} records defining actions supported +by the service. + @item @code{network} (default: @code{""}) (type: string) Set a Docker network for the spawned container. diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm index bc566e6316..78d7e2f04e 100644 --- a/gnu/services/docker.scm +++ b/gnu/services/docker.scm @@ -77,6 +77,7 @@ (define-module (gnu services docker) oci-container-configuration-log-file oci-container-configuration-auto-start? oci-container-configuration-respawn? + oci-container-configuration-shepherd-actions oci-container-configuration-network oci-container-configuration-ports oci-container-configuration-volumes @@ -328,6 +329,17 @@ (define (oci-sanitize-volumes value) ;; '(("/mnt/dir" . "/dir") "/run/current-system/profile:/java") (oci-sanitize-mixed-list "volumes" value ":")) +(define (oci-sanitize-shepherd-actions value) + (map + (lambda (el) + (if (shepherd-action? el) + el + (raise + (formatted-message + (G_ "shepherd-actions may only be shepherd-action records +but ~a was found") el)))) + value)) + (define (oci-sanitize-extra-arguments value) (define (valid? member) (or (string? member) @@ -477,6 +489,11 @@ (define-configuration/no-serialization oci-container-configuration (boolean #f) "Whether to restart the service when it stops, for instance when the underlying process dies.") + (shepherd-actions + (list '()) + "This is a list of @code{shepherd-action} records defining actions supported +by the service." + (sanitizer oci-sanitize-shepherd-actions)) (network (maybe-string) "Set a Docker network for the spawned container.") @@ -680,6 +697,7 @@ (define (oci-container-shepherd-service config) (oci-image-repository image)))))) (let* ((docker (file-append docker-cli "/bin/docker")) + (actions (oci-container-configuration-shepherd-actions config)) (auto-start? (oci-container-configuration-auto-start? config)) (user (oci-container-configuration-user config)) @@ -732,15 +750,17 @@ (define (oci-container-shepherd-service config) (actions (if (oci-image? image) '() - (list - (shepherd-action - (name 'pull) - (documentation - (format #f "Pull ~a's image (~a)." - name image)) - (procedure - #~(lambda _ - (invoke #$docker "pull" #$image)))))))))) + (append + (list + (shepherd-action + (name 'pull) + (documentation + (format #f "Pull ~a's image (~a)." + name image)) + (procedure + #~(lambda _ + (invoke #$docker "pull" #$image))))) + actions)))))) (define %oci-container-accounts (list (user-account -- 2.41.0