From 452d6c14b445480d91a90b43462b3775f92a4bdf Mon Sep 17 00:00:00 2001 From: Angelo Failla Date: Fri, 10 Jan 2025 03:35:34 -0800 Subject: [PATCH] [antlir systemd timer API] Stop hard coding `TimeoutStartSec=15min` and make it configurable Summary: I realised, when I created this API, that I had hard coded this... Let's make this configurable. Test Plan: I kept the public facing macro defaulting to 15m so this will be a NOOP as I manually tested: ``` # pallotron @ devvm3927 in ~/fbcode [0:26:16] $ buck run '//netos/os:os[container]' File changed: fbcode//antlir/bzl/linux/systemd/service_unit.jinja2 File changed: fbcode//antlir/bzl/linux/systemd File changed: fbcode//antlir/bzl 3 additional file change events Buck UI: https://www.internalfb.com/buck2/29417122-84a5-4da1-b482-c554323a5edb Network: Up: 4.9MiB Down: 5.7GiB (reSessionID-927494fa-ef86-4736-9947-81106077633f) Analyzing targets. Remaining 0/101 7 actions Executing actions. Remaining 0/45605 56:13:47.2s exec time total Command: run. Finished 63 local, 168 remote, 42119 cache (99% hit) 55:48:28.4s exec time cached (99%) Time elapsed: 4:15.1s BUILD SUCCEEDED bash-5.1# ``` ``` bash-5.1# cat /usr/lib/systemd/system/fb_procprint.service | grep TimeoutStart TimeoutStartSec=15m ``` Reviewed By: lsiudut Differential Revision: D68008374 fbshipit-source-id: 891db5b23a63ab47a687ef04c02e45c6ea7e8e0d --- antlir/bzl/linux/systemd/service_unit.jinja2 | 4 +++- antlir/bzl/linux/systemd/systemd.shape.bzl | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/antlir/bzl/linux/systemd/service_unit.jinja2 b/antlir/bzl/linux/systemd/service_unit.jinja2 index 2a92273ae24..ca2a8218142 100644 --- a/antlir/bzl/linux/systemd/service_unit.jinja2 +++ b/antlir/bzl/linux/systemd/service_unit.jinja2 @@ -12,7 +12,9 @@ EnvironmentFile={{ environment_file }} {% for cmd in exec_start %} ExecStart={{ cmd }} {% endfor %} -TimeoutStartSec=15min +{% if timeout_start %} +TimeoutStartSec={{ timeout_start }} +{% endif %} TimeoutStopSec=90s {% for key, val in environment.items() %} Environment={{ key }}={{ val }} diff --git a/antlir/bzl/linux/systemd/systemd.shape.bzl b/antlir/bzl/linux/systemd/systemd.shape.bzl index 9f2b289a0c3..b7257cc3875 100644 --- a/antlir/bzl/linux/systemd/systemd.shape.bzl +++ b/antlir/bzl/linux/systemd/systemd.shape.bzl @@ -22,6 +22,7 @@ service_t = shape.shape( environment = shape.field(shape.dict(str, str), optional = True), exec_start = shape.field(shape.list(str), optional = True), standard_output = shape.field(str, optional = True), + timeout_start = shape.field(str, optional = True), ) timer_t = shape.shape(