From 4d4137aa285421f820c79ebd366059930b1a194b Mon Sep 17 00:00:00 2001 From: Johannes Nicolai Date: Thu, 25 Feb 2021 01:07:49 +0100 Subject: [PATCH] Avoid zombie runners that missed token expiration by a bit (#345) * if a new runner pod was just scheduled to start up right before a registration expired, it will not get a new registration token and go in an infinite update loop (until #341) kicks in * if registzration tokens got updated a little bit before they actually expired, just starting up pods will way more likely get a working token --- github/github.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/github/github.go b/github/github.go index 027ad76e..e1f6dc8e 100644 --- a/github/github.go +++ b/github/github.go @@ -85,7 +85,10 @@ func (c *Client) GetRegistrationToken(ctx context.Context, enterprise, org, repo key := getRegistrationKey(org, repo, enterprise) rt, ok := c.regTokens[key] - if ok && rt.GetExpiresAt().After(time.Now()) { + // we like to give runners a chance that are just starting up and may miss the expiration date by a bit + runnerStartupTimeout := 3 * time.Minute + + if ok && rt.GetExpiresAt().After(time.Now().Add(runnerStartupTimeout)) { return rt, nil }