From aaab03e1da26422709861b2939541a1f7ac00845 Mon Sep 17 00:00:00 2001 From: magic_rb Date: Fri, 14 Jun 2024 15:15:33 +0200 Subject: [PATCH] Fix JWT token renewal condition Signed-off-by: magic_rb --- buildbot_nix/github/jwt_token.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildbot_nix/github/jwt_token.py b/buildbot_nix/github/jwt_token.py index 79fe56b..0d78171 100644 --- a/buildbot_nix/github/jwt_token.py +++ b/buildbot_nix/github/jwt_token.py @@ -73,7 +73,7 @@ class JWTToken(RepoToken): # return list(map(lambda installation: create_installation_access_token(installation['id']).json()["token"], installations)) def get(self) -> str: - if datetime.now(tz=UTC) - self.expiration > self.lifetime * 0.8: + if self.expiration - datetime.now(tz=UTC) < self.lifetime * 0.2: self.token, self.expiration = JWTToken.generate_token( self.app_id, self.app_private_key, self.lifetime )