From patchwork Sat Jun 4 08:37:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 2804 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 089E527BBEA; Sat, 4 Jun 2022 09:38:42 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id C46D627BBE9 for ; Sat, 4 Jun 2022 09:38:41 +0100 (BST) Received: from localhost ([::1]:46782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nxPIv-0002ar-04 for patchwork@mira.cbaines.net; Sat, 04 Jun 2022 04:38:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxPIJ-0002X9-PA for guix-patches@gnu.org; Sat, 04 Jun 2022 04:38:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35496) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nxPII-00046h-Jv for guix-patches@gnu.org; Sat, 04 Jun 2022 04:38:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nxPII-00077W-Hc for guix-patches@gnu.org; Sat, 04 Jun 2022 04:38:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55792] [PATCH 3/3] hydra: web: Make mcron job derivations deterministic. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 04 Jun 2022 08:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55792 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55792@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 55792-submit@debbugs.gnu.org id=B55792.165433187527344 (code B ref 55792); Sat, 04 Jun 2022 08:38:02 +0000 Received: (at 55792) by debbugs.gnu.org; 4 Jun 2022 08:37:55 +0000 Received: from localhost ([127.0.0.1]:57623 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nxPIB-00076y-Dx for submit@debbugs.gnu.org; Sat, 04 Jun 2022 04:37:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52764) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nxPIA-00076a-Cf for 55792@debbugs.gnu.org; Sat, 04 Jun 2022 04:37:54 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47302) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxPI5-000466-4w; Sat, 04 Jun 2022 04:37:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=3uX5daEgeP3qpagwAg7GKzpdAiR2H+CWyiIQTwUM4LQ=; b=i/Pm8q6Vaxhb5KYarp8N F0LxJ2jHg25v2jImXg7jKWLVd8qQXClBvBy87KSdkhOr99/1UZDZss2TFSD+uSXLL78ZJY8MFSW/M Q+DDiTXzJvemuJm9rsFBThXibpzfdCzGiX8tUlO8l6buXinbBleSh0e4zzZD0yahebc9e2/1MoPUE r4afsRKeCfWnPlycFHh1njd0OnsAEuiQcifqSowZcVQemgar2Pk1oFpGX5DLBMx0e+8ClWx0Z7yq5 M5KnoR1/UoNXSYKsc7BrRWU0JFwGmN1pcu3OvG17AgpQa8OdXSxlD6Nh0imCDyC/E/tmn0zA3f7TL 3XJb6sLHdfGfiA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:60197 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nxPI4-0005ty-IK; Sat, 04 Jun 2022 04:37:48 -0400 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Sat, 4 Jun 2022 10:37:36 +0200 Message-Id: <20220604083736.22152-3-ludo@gnu.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220604083736.22152-1-ludo@gnu.org> References: <20220604083736.22152-1-ludo@gnu.org> MIME-Version: 1.0 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: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches The result of (hash config period) varies between runs. Thus, starting from bdb914a1242cb0c00957050c96d1e279d2eb5dec, each run of "guix system build -d ..." would produce a different derivation. This commit fixes that. * hydra/modules/sysadmin/web.scm (static-web-site-mcron-jobs)[record->list]: New procedure. Use it. --- hydra/modules/sysadmin/web.scm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hydra/modules/sysadmin/web.scm b/hydra/modules/sysadmin/web.scm index e04ac1b..f26ed24 100644 --- a/hydra/modules/sysadmin/web.scm +++ b/hydra/modules/sysadmin/web.scm @@ -179,11 +179,19 @@ that's built with Haunt or similar." (basename (static-web-site-configuration-directory config))))) + (define (record->list record) + (let ((fields (record-type-fields ))) + (map (lambda (n) + (struct-ref record n)) + (iota (length fields))))) + (map (lambda (config) ;; Add an offset to spread web site updates over the period to avoid I/O - ;; load peaks when there are several such jobs. + ;; load peaks when there are several such jobs. Compute a hash over + ;; a list representation of CONFIG, rather than over CONFIG, because + ;; hash of a struct depends on the object identity of its vtable. (let* ((period (static-web-site-configuration-period config)) - (offset (hash config period))) + (offset (hash (record->list config) period))) #~(job (lambda (now) (let ((elapsed (modulo now #$period))) (+ now (- #$period elapsed) #$offset)))