From b89f882c7e4d756ba3fb60548a59d869ae3dfc4d Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Wed, 27 Dec 2023 21:14:05 +0100 Subject: [PATCH] Allow guest settle timeout to be configured Falls back to 120seconds per default if the key isn't in the config file. Assumes startup-timeout is in seconds e.g. 120 for 2 minutes --- worker/tasks.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/worker/tasks.go b/worker/tasks.go index 2e3b21f..8b3de1b 100644 --- a/worker/tasks.go +++ b/worker/tasks.go @@ -100,7 +100,23 @@ func (ctx *JobContext) Settle() error { settleTimer := prometheus.NewTimer(settleTime.WithLabelValues(ctx.Manifest.Image, arch)) defer settleTimer.ObserveDuration() - timeout, cancel := context.WithTimeout(ctx.Context, 120*time.Second) + var ( + ok bool + err error + startupTimeout int + startupTimeoutRaw string + ) + // assumes the timeout is specified as an int in seconds + // e.g. 120 for 2 minutes + if startupTimeoutRaw, ok = config.Get("builds.sr.ht::worker", "startup-timeout"); !ok { + // default to old hardcoded value if the key wasn't found in the config file + startupTimeoutRaw = "120" + } + if startupTimeout, err = strconv.Atoi(startupTimeoutRaw); err != nil { + return errors.New("The startup-timeout could not be read") + } + + timeout, cancel := context.WithTimeout(ctx.Context, time.Duration(startupTimeout)*time.Second) defer cancel() done := make(chan error, 1) attempt := 0 -- 2.38.5