From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id qJbVHe/ccWT5sAAASxT56A (envelope-from ) for ; Sat, 27 May 2023 12:35:27 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cDpbHe/ccWR+VQAAauVa8A (envelope-from ) for ; Sat, 27 May 2023 12:35:27 +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 16084353D0 for ; Sat, 27 May 2023 12:35:27 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2rGL-0005LH-IM; Sat, 27 May 2023 06:35:05 -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 1q2rGK-0005L3-Bq for bug-guix@gnu.org; Sat, 27 May 2023 06:35:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q2rGJ-0002IQ-5h for bug-guix@gnu.org; Sat, 27 May 2023 06:35:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q2rGI-0002P1-MC for bug-guix@gnu.org; Sat, 27 May 2023 06:35:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#53580: shepherd's architecture References: In-Reply-To: Resent-From: Attila Lendvai Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 27 May 2023 10:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53580 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 53580@debbugs.gnu.org Received: via spool by 53580-submit@debbugs.gnu.org id=B53580.16851836449150 (code B ref 53580); Sat, 27 May 2023 10:35:02 +0000 Received: (at 53580) by debbugs.gnu.org; 27 May 2023 10:34:04 +0000 Received: from localhost ([127.0.0.1]:51423 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2rFL-0002NW-Dc for submit@debbugs.gnu.org; Sat, 27 May 2023 06:34:03 -0400 Received: from mail-40136.proton.ch ([185.70.40.136]:21345) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q2rFJ-0002Mw-EZ for 53580@debbugs.gnu.org; Sat, 27 May 2023 06:34:02 -0400 Date: Sat, 27 May 2023 10:33:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lendvai.name; s=protonmail2; t=1685183634; x=1685442834; bh=sEr0tmZLFsFVrG9O7/DkrLRlBsDVacqtypASo5en9Ls=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=SzVpKthbLmJH09H695FBqC8A7TQT/iwrVmyOv1ELrKAloakIFe1BGhOGSHCoRQP7S I1M3OscFI5xyJexbah4S3lHq0EPAkpxBW2nDs6PMGAglf4JKvnMFyV9N+OIwnAro1+ dxq4tvHaGTM2SdjF7c5teXApXZFiOrPqoSm4ZQlQHCv0mPm0acYIspSjk5U9S755E+ orgwnrEGgsNCAQ9Hic0nTqiUaJHPzbOnAXTSdw1nnaJUMqL5qlORULsRdyqrHWFcL3 iTp0omonR3RfymkiJLdR4FhQtgWnUPlKtzBop2d0vgjA/n/E7372a+aXZ4uLIOg2U8 WAMs1L/PxyEkA== From: Attila Lendvai Message-ID: Feedback-ID: 28384833:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1685183727; a=rsa-sha256; cv=none; b=IWYS1eFdxsoEZECVpW4IZItnJs3IE0Vm9uR1g/xQzErmDWsNzBrTsmU+s9/zqj3OCrJUjq LX8tfiVQjGb7/XIdVAnndPA6jG3Bv35NVJUmC7lEaPWlAtIVZohdc0zU5jmwJ7uSPFGDGc P7W8eE0Dbic7rA9Z6NLrpj840RTYIQSrO1e/hVuxaM7MgFd1Ff6SLTK+87RnyCCPsgEX6j r+cj7yAJeZqdQBQs+fGpDtal5EaxMZqljHGhTtHGhA17nT+S9hyIg5XEhWCqOM6xau0PNv wZ48UZA8JCbURfQJdpsw1B8pZJOpE8XZhOxo6k/zDRAvAd7oKTDGK3tRw+cQfA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lendvai.name header.s=protonmail2 header.b=SzVpKthb; dmarc=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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1685183727; 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=sEr0tmZLFsFVrG9O7/DkrLRlBsDVacqtypASo5en9Ls=; b=mq5SlIimuoMcN2Cwdlp0pT26zk4WDlHQLV/+yuHJgbAvEkrolhvhGL1k+lkLAsXj9//m/T XYjMcBcURz97NuD9lSkoC5qP7EkYEFeiInSKDO41WSNNs6YRfrg9x35IH19xdPlkN76w4m sLHst3f6j9Wpq4ZDXnB25fA2i3nHkJF6O4D2lNhSYJ4Sxe8ksAXEPCHfMYRb3dT3F71sNW V6G2zbPCTyeDgUu3UK683A18ZMuWdOUgH0yKXa6yp4bUt4ncxLPwp01w/NQGW6ERURYb2y /+0C0cmxYeEw9XGlhqfx51GXZJb8E5VWk/dfU8BFG9wKTEHS3xZwM0w18rnB1A== X-Migadu-Spam-Score: -0.21 X-Spam-Score: -0.21 X-Migadu-Queue-Id: 16084353D0 X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=lendvai.name header.s=protonmail2 header.b=SzVpKthb; dmarc=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-TUID: MEbBP/pWrnKj [forked from: bug#53580: /var/run/shepherd/socket is missing on an otherwis= e functional system] > So I think we=E2=80=99re mostly okay now. The one thing we could do is lo= ad > the whole config file in a separate fiber, and maybe it=E2=80=99s fine to= keep > going even when there=E2=80=99s an error during config file evaluation? > > WDYT? i think there's a fundamental issue to be resolved here, and addressing tha= t would implicitly resolve the entire class of issues that this one belongs= to. guile (shepherd) is run as the init process, and because of that it may not= exit or be respawn. but at the same time when we reconfigure a guix system= , then shepherd's config should not only be reloaded, but its internal stat= e merged with the new config, and potentially even with an evolved shepherd= codebase. i still lack a proper mental model of all this to succesfully predict what = will happen when i `guix system reconfigure` after i `guix pull`-ed my serv= ice code, and/or changed the config of my services. -------- this problem of migration is pretty much a CS research topic... ideally, there should be a non-shepherd-specific protocol defined for such = migrations, and the new shpeherd codebase could migrate its state from the = old to the new, with most of the migration code being automatic. some of it= must be hand written as rquired by some semantic changes. even more ideally, we should reflexive systems; admit that source code is a= graph, and store it as one (as opposed to a string of characters); and our= systems should have orthogonal persistency, etc, etc... a far cry from wha= t we have now. Fare's excellent blog has some visionary thoughts on this, especially in: https://ngnghm.github.io/blog/2015/09/08/chapter-5-non-stop-change/ but given that we will not have these any time soon... what can we do now? -------- note: what follows are wild ideas, and i'm not sure i have the necessary un= derstanding of the involved subsystems to properly judge their feasibility.= .. so take them with a pinch of salt. idea 1 -------- it doesn't seem to be an insurmontable task to make sure that guile can saf= ely unlink a module from its heap, check if there are any references into t= he module to be dropped, and then reload this module from disk. the already runing fibers would keep the required code in the heap until af= ter they are stopped/restarted. then the module would get GC'd eventually. this would help solve the problem that a reconfigured service may have a co= mpletely different start/stop code. and by taking some careful shortcuts we= may be able to make reloading work without having to stop the service proc= ess in question. idea 2 -------- another, probably better idea: split up shepherd's codebase into isolated parts: 1) the init process 2) the service runners, which are spawned by 1). let's call this part 'the runner'. 3) the CLI scripts that implement stuff like `reboot` by sending a message to 1). the runner would spawn and manage the actual daemon binaries/processes. the init process would communicate with the runners through a channel/pipe = that is created when the runner are spawn. i.e. here we wouldn't need an IP= C socket file like we need for the communication between the scripts and th= e init process. AFAIU the internal structure of shepherd is already turning into something = like this with the use of fibers and channels. i suspect Ludo has something= like this on his mind already. in this setup most of the complexity and the evolution of the shepherd code= base would happen in the runner, and the other two parts could be kept mini= mal and would rarely need to change (and thus require a reboot). the need for a reboot could be detected by noticing that the compiled binar= y of the init process has changed compared to what is currently running as = PID 1. the driver process of a service could be reloaded/respawned the next time w= hen the daemon is stopped or it quits unexpectedly. -------- recently i've succesfully wrote a shepherd service that spawns a daemon, an= d from a fiber it does two way communication with the daemon using a pipe c= onnected to the daemon's stdio. i guess that counts as a proof of concept f= or the second idea, but i'm not sure about its stability. a stuck/failing s= ervice is a different issue than a stuck/failing init process. for reference, the spawning of the daemon: https://github.com/attila-lendvai/guix-crypto/blob/8f996239bb8c2a1103c3e546= 05faf680fe1ed093/src/guix-crypto/services/swarm.scm#L315 the fiber's code that talks to it: https://github.com/attila-lendvai/guix-crypto/blob/8f996239bb8c2a1103c3e546= 05faf680fe1ed093/src/guix-crypto/swarm-utils.scm#L133 -- =E2=80=A2 attila lendvai =E2=80=A2 PGP: 963F 5D5F 45C7 DFCD 0A39 -- =E2=80=9CWe reject: kings, presidents and voting. We believe in: rough cons= ensus and running code.=E2=80=9D =09=E2=80=94 David Clark for the IETF