From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id AMP0BnjUc2SHlwAASxT56A (envelope-from ) for ; Mon, 29 May 2023 00:23:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id mIm0BnjUc2R4NAAAauVa8A (envelope-from ) for ; Mon, 29 May 2023 00:23:52 +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 9654912CA for ; Mon, 29 May 2023 00:23:51 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3OnC-0003zn-Bl; Sun, 28 May 2023 18:23:14 -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 1q3OnB-0003ze-JO for guix-devel@gnu.org; Sun, 28 May 2023 18:23:13 -0400 Received: from mail-4323.proton.ch ([185.70.43.23]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3On7-0008DB-Nc for guix-devel@gnu.org; Sun, 28 May 2023 18:23:12 -0400 Date: Sun, 28 May 2023 22:23:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lendvai.name; s=protonmail2; t=1685312584; x=1685571784; bh=xKASRMSYfWTEQQZ7z3CEmVHn50M8Dp+chsiiRnlxt04=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=pHvZseBLRcKdIuY8fzpBlhVFz07qakesducHg04tPDVjpltIGwgxFsSoQ/mDN7HuT otdTqAvvqYW0gVJOr42CsQU5ssAzLx2o3hJYiHsGfh1fAV1zQ1Jc/RIsGl8hrYoJk7 d8JXPVBTFeboI46M+lH0qx1ND+u7tc7w6o0U9CKuaHhU26GhLRz6OKzd+ZPbIK7fBR KupvRyCP1Pt4FxlmBbhZ40wn9j0kIp97VAyDj4x+sfAzma8LuxbmvdMS26UQ3t7kzG oXeDrUt8w5cLdKZlNMZ8gHJ+bwTpLX6eUJSWk77beDGgKRPLckQ/ElvokRIfbslMkp bLiaGrxKpePVg== To: =?utf-8?Q?Ludovic_Court=C3=A8s?= From: Attila Lendvai Cc: 53580@debbugs.gnu.org, guix-devel Subject: shepherd's architecture Message-ID: In-Reply-To: References: Feedback-ID: 28384833:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.43.23; envelope-from=attila@lendvai.name; helo=mail-4323.proton.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-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=1685312632; a=rsa-sha256; cv=none; b=mS3FWIfylKMh8RGRmVt0k+hb6i7arfsQ4mUW+RCzaNRHsLooWfJ/tlg0LLJ38BT9ev1hlb /ObvMzUwPzNZ2xEsfB2hb+qlX4Jes79loqmbat+bpnwUoraHMRM7MS4G4/cMm69LezQoPt nbLna1ilg8T2QZLd276iW00YpPD43R3rQWYpoaBl4Q0S46hpZYuqITrkm33MST8o7Ryq73 yMZOy5K7ldNrCq6NGBsVhXcA1lOoAJJ0AHX+C+mwxc2bZBgXdK9gsYhEniaR5lORxI8Ljo UPYlrg7/uMyrltj55uG89fxB5/OvCG9wbJuFcHNb6PTTq5JuC1vuW6MvWRJJBA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=lendvai.name header.s=protonmail2 header.b=pHvZseBL; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1685312632; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=xKASRMSYfWTEQQZ7z3CEmVHn50M8Dp+chsiiRnlxt04=; b=RCoRQkkUDBMR+Wr7nuXPEtp5rAJ9G7gDTBppgRUqg/7GKhvqOD/NsT98Q0oOpfDNr74xJK 7ITQ1DZsirdA0VqrP9u8PVlAOqeBKNBG+u22DIbrqGpBTZjw2Nyb0Mjw2etVSEP4V3ZrE5 8oR7jdWFWzEdMSDdIRv7oaLKCSoM+wOnVmy+rENm5n8/JObnz3apcBFGAePB5zrtsqSGmv Z2IRwo/vydQLUmC4s18Uce02m/iLRqEll5V6OOFPCaXBlcxoU6fg5ZTdqMHcwEpqN01UxI oR4udrCYJDV444lQGKp54Tu8sc6H2v9rxSwfK/Thte+g7bSJvwxbBAwv5GX1KQ== X-Migadu-Spam-Score: -8.67 X-Spam-Score: -8.67 X-Migadu-Queue-Id: 9654912CA X-Migadu-Scanner: scn0.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lendvai.name header.s=protonmail2 header.b=pHvZseBL; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" X-TUID: jT9Z9a62jS/x [resending to include the guix-devel list. apologies for everyone who recei= ves this mail twice!] ------ [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? >=20 > 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 --=20 =E2=80=A2 attila lendvai =E2=80=A2 PGP: 963F 5D5F 45C7 DFCD 0A39 -- =E2=80=9CDying societies accumulate laws like dying men accumulate remedies= .=E2=80=9D =09=E2=80=94 Nicol=C3=A1s G=C3=B3mez D=C3=A1vila (1913=E2=80=931994), 'Esc= olios a un texto implicito: Seleccion'