From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id CHdCL9kiwGKFfgAAbAwnHQ (envelope-from ) for ; Sat, 02 Jul 2022 12:50:01 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id yJ82L9kiwGLcKwEA9RJhRA (envelope-from ) for ; Sat, 02 Jul 2022 12:50:01 +0200 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 468F61EFCC for ; Sat, 2 Jul 2022 12:50:01 +0200 (CEST) Received: from localhost ([::1]:44386 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7ahM-0006Rx-5C for larch@yhetil.org; Sat, 02 Jul 2022 06:50:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7aZf-0004Ek-6U for bug-guix@gnu.org; Sat, 02 Jul 2022 06:42:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:45994) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7aZe-0002SD-Dv for bug-guix@gnu.org; Sat, 02 Jul 2022 06:42:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o7aZe-00047z-CJ for bug-guix@gnu.org; Sat, 02 Jul 2022 06:42:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#55936: [PATCH] services: docker: Fix race condition. References: <87h74pa3rp.fsf@kong.network> In-Reply-To: <87h74pa3rp.fsf@kong.network> Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 02 Jul 2022 10:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55936 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 55936@debbugs.gnu.org Cc: Oleg Pykhalov , Maxim Cournoyer Received: via spool by 55936-submit@debbugs.gnu.org id=B55936.165675851815848 (code B ref 55936); Sat, 02 Jul 2022 10:42:02 +0000 Received: (at 55936) by debbugs.gnu.org; 2 Jul 2022 10:41:58 +0000 Received: from localhost ([127.0.0.1]:39890 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7aZU-00047T-Qv for submit@debbugs.gnu.org; Sat, 02 Jul 2022 06:41:58 -0400 Received: from mail-lf1-f47.google.com ([209.85.167.47]:33751) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7aZP-00046y-KR for 55936@debbugs.gnu.org; Sat, 02 Jul 2022 06:41:51 -0400 Received: by mail-lf1-f47.google.com with SMTP id a4so7840336lfm.0 for <55936@debbugs.gnu.org>; Sat, 02 Jul 2022 03:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5JClVHoelTo6PMzA+fXakvSdP+EfzOEB9jGT5rtSAzY=; b=bCLFWNWxlTAHsuL9Ry3p7iMSUMZ6Gd8utA1Wq68X4ubCFRwXryPkRQQAyyRVBjUB5h +FL8PLJYWfnv8l3bG1Uo7gMFH8oDL93qe7qn5TJe21Kpus/WejaL0eakN0HLy3bG2S4c sH6kMcrEZjvHRvZIEzygf4drpJ08KHvNY3y12NfuYL4KdY2jvrXtjpFeNWmW2CUAcROV Fq1aVTkPKr1ZoTGC/76qbjWQfgkR5DCvh20zxpCOzLFn6Ch+ugmbJ07kxT52VhQkHXtW vAn7F3k15qqoMoaVNrM36dsxfxHY1epPntHQpUwKw2HnBe5GHthrz3buDS55nRMiLwDR VrCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5JClVHoelTo6PMzA+fXakvSdP+EfzOEB9jGT5rtSAzY=; b=DNkyGL2XbUS71G1uzob3tsxImkjPnXX/H+LqsB30CVvzbNX2xRYDwf+WPPypl8+D82 WCUWLqoS5Xf42F5kCCD6LZFrpMe572CZyYaGbQ6d+NHBaAJ2kE4XIrreIsOcxnQvLbDI rtFdd6mMYPQxmurf+jLcrPM520m/aaOPwtmlfbAt2cNoXraKgDS8y+rO4pDpsOosEeKi SX/s5mhoAABzkaWilN9zvAvHgPa5rLguoDWzTuES0WcwryBFZKTCjjWLrkqoO93j3exY vZkhRxQ+6awVMHzs1oo2z5By3/Dz9g08CxaTAsGkdFcprlP4m+euejApzM0B9P4unLAO JDCw== X-Gm-Message-State: AJIora/lVCHW55RRE3y6X+TfQLmATJl+dbAjiFqIy/q2F+kVXSo2tw5f emtkk5KfLNyRJfyT+VMCnC6GRZ3hPn8= X-Google-Smtp-Source: AGRyM1veA4xflM69zsriMJ4Uo/K6HuKV7Df0dUBeLNxH4EwSUcIud6iZYqYNrOz5EKEqcI7UzAqKiQ== X-Received: by 2002:a05:6512:3b9d:b0:47f:7712:3ece with SMTP id g29-20020a0565123b9d00b0047f77123ecemr11532812lfv.127.1656758500968; Sat, 02 Jul 2022 03:41:40 -0700 (PDT) Received: from guixsd.wugi.info ([88.201.161.72]) by smtp.gmail.com with ESMTPSA id q185-20020a2e5cc2000000b0025a891f7b8dsm3614374ljb.32.2022.07.02.03.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Jul 2022 03:41:40 -0700 (PDT) From: Oleg Pykhalov Date: Sat, 2 Jul 2022 13:41:06 +0300 Message-Id: <20220702104106.16997-1-go.wigust@gmail.com> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1656759001; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=5JClVHoelTo6PMzA+fXakvSdP+EfzOEB9jGT5rtSAzY=; b=YLkBXT5xKeJ7vTTvMLzF/QJeApvvH+L7aAlFkF7w1+4g2QKpLbW51vmvB5H3AVQCx3EI3F mmBXDYZp+t0YErwFvktu5QtN+9XEfkV+OEVVximHKMUGc7TtK9/yNeHT1V3qAUEXEXA07y vqVXq9c7pWUwt3r7tjT2s5hfiIRkGJdiYr2xv5PuBxyPFD2PhviJA4RXWLP/IZ9vCvmaEg tyv4eQMlRF2cWpvu2YfTxhDaVqcY2V3ua1Ht7e3Rd6ZyKqp/dO4XObhzsvNTew6aOKMfBw Ujco54Rm5h9yhBVHESzgDNyAPlkfxOpMM2zN7LW+n68zknH803TTYLrAOrrJvA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1656759001; a=rsa-sha256; cv=none; b=CiWQdrlZlD1CQ3CG2713MkGpHc7Z/oRRi3m5PgJ1n0jzYhE09CGh8HnTznTiE56ki6WHQ/ /xXFPLOYpj1nh+IUX4fK7LvOWJCN5z8092hDQa44d9cmvq1mDaoj8XKAu9cqRC3dzGFBgx SmNwVZTqDs9EDK/y9BDTQkkzkpexHRszJ5FRosroQuKQi4Maq2zaP7EIGGvdLx4ZQIFgSx 4xk6N/Qbk19KVE1Q5eAIMChGvYMOLyOmIu8vAjc6zeX/WbmNZhjAn5ZvzJ4t2UMBnmPtNK +cg/Oero06CVoqz7ldN4AGaKqlXzzPbUYrftqU8qyNtQ/F72k+EHiVKe32qBFg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=bCLFWNWx; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 5.25 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=bCLFWNWx; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 468F61EFCC X-Spam-Score: 5.25 X-Migadu-Scanner: scn0.migadu.com X-TUID: rH9hbaMOM/6Z Fixes . * gnu/packages/patches/containerd-create-pid-file.patch: New file. * gnu/local.mk (dist_patch_DATA): Add this. * gnu/packages/docker.scm (containerd)[source]: Add this patch. * gnu/services/docker.scm (containerd-shepherd-service): Add #:pid-file and #:pid-file-timeout. * gnu/services/docker.scm (docker-shepherd-service): Add --containerd flag. --- gnu/local.mk | 3 +- gnu/packages/docker.scm | 6 ++-- .../patches/containerd-create-pid-file.patch | 31 +++++++++++++++++++ gnu/services/docker.scm | 5 ++- 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 gnu/packages/patches/containerd-create-pid-file.patch diff --git a/gnu/local.mk b/gnu/local.mk index 3a56ad371d..5cd235286c 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -17,7 +17,7 @@ # Copyright © 2017, 2020 Mathieu Othacehe # Copyright © 2017, 2018, 2019 Gábor Boskovits # Copyright © 2018 Amirouche Boubekki -# Copyright © 2018, 2019, 2020, 2021 Oleg Pykhalov +# Copyright © 2018, 2019, 2020, 2021, 2022 Oleg Pykhalov # Copyright © 2018 Stefan Stefanović # Copyright © 2018, 2020, 2021, 2022 Maxim Cournoyer # Copyright © 2019, 2020, 2021, 2022 Guillaume Le Vaillant @@ -965,6 +965,7 @@ dist_patch_DATA = \ %D%/packages/patches/cmh-support-fplll.patch \ %D%/packages/patches/coda-use-system-libs.patch \ %D%/packages/patches/collectd-5.11.0-noinstallvar.patch \ + %D%/packages/patches/containerd-create-pid-file.patch \ %D%/packages/patches/combinatorial-blas-awpm.patch \ %D%/packages/patches/combinatorial-blas-io-fix.patch \ %D%/packages/patches/cool-retro-term-wctype.patch \ diff --git a/gnu/packages/docker.scm b/gnu/packages/docker.scm index ae4ee419af..184280b38f 100644 --- a/gnu/packages/docker.scm +++ b/gnu/packages/docker.scm @@ -6,7 +6,7 @@ ;;; Copyright © 2020 Michael Rohleder ;;; Copyright © 2020 Katherine Cox-Buday ;;; Copyright © 2020 Jesse Dowell -;;; Copyright © 2021 Oleg Pykhalov +;;; Copyright © 2021, 2022 Oleg Pykhalov ;;; Copyright © 2022 Pierre Langlois ;;; ;;; This file is part of GNU Guix. @@ -184,7 +184,9 @@ (define-public containerd (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 - (base32 "1vsl747i3wyy68j4lp4nprwxadbyga8qxlrk892afcd2990zp5mr")))) + (base32 "1vsl747i3wyy68j4lp4nprwxadbyga8qxlrk892afcd2990zp5mr")) + (patches + (search-patches "containerd-create-pid-file.patch")))) (build-system go-build-system) (arguments (let ((make-flags #~(list (string-append "VERSION=" #$version) diff --git a/gnu/packages/patches/containerd-create-pid-file.patch b/gnu/packages/patches/containerd-create-pid-file.patch new file mode 100644 index 0000000000..668ffcd9e9 --- /dev/null +++ b/gnu/packages/patches/containerd-create-pid-file.patch @@ -0,0 +1,31 @@ +Copyright © 2022 Oleg Pykhalov + +Create a PID file after containerd is ready to serve requests. + +Fixes . + +--- a/cmd/containerd/command/notify_linux.go 1970-01-01 03:00:01.000000000 +0300 ++++ b/cmd/containerd/command/notify_linux.go 2022-07-02 04:42:35.553753495 +0300 +@@ -22,15 +22,22 @@ + sd "github.com/coreos/go-systemd/v22/daemon" + + "github.com/containerd/containerd/log" ++ ++ "os" ++ "strconv" + ) + + // notifyReady notifies systemd that the daemon is ready to serve requests + func notifyReady(ctx context.Context) error { ++ pidFile, _ := os.Create("/run/containerd/containerd.pid") ++ defer pidFile.Close() ++ pidFile.WriteString(strconv.FormatInt(int64(os.Getpid()), 10)) + return sdNotify(ctx, sd.SdNotifyReady) + } + + // notifyStopping notifies systemd that the daemon is about to be stopped + func notifyStopping(ctx context.Context) error { ++ os.Remove("/run/containerd/containerd.pid") + return sdNotify(ctx, sd.SdNotifyStopping) + } + diff --git a/gnu/services/docker.scm b/gnu/services/docker.scm index 846ebe8334..741bab5a8c 100644 --- a/gnu/services/docker.scm +++ b/gnu/services/docker.scm @@ -98,6 +98,8 @@ (define (containerd-shepherd-service config) ;; For finding containerd-shim binary. #:environment-variables (list (string-append "PATH=" #$containerd "/bin")) + #:pid-file "/run/containerd/containerd.pid" + #:pid-file-timeout 300 #:log-file "/var/log/containerd.log")) (stop #~(make-kill-destructor))))) @@ -135,7 +137,8 @@ (define (docker-shepherd-service config) '("--userland-proxy=false")) (if #$enable-iptables? "--iptables" - "--iptables=false")) + "--iptables=false") + "--containerd" "/run/containerd/containerd.sock") #:environment-variables (list #$@environment-variables) #:pid-file "/var/run/docker.pid" -- 2.36.0