|
32 | 32 | from .config_exception import ConfigException
|
33 | 33 | from .dateutil import UTC, format_rfc3339, parse_rfc3339
|
34 | 34 |
|
35 |
| -EXPIRY_SKEW_PREVENTION_DELAY = datetime.timedelta(minutes=5) |
| 35 | +MINIMUM_TOKEN_TIME_REMAINING = datetime.timedelta(minutes=55) |
36 | 36 | KUBE_CONFIG_DEFAULT_LOCATION = os.environ.get('KUBECONFIG', '~/.kube/config')
|
37 | 37 | _temp_files = {}
|
38 | 38 |
|
@@ -62,8 +62,8 @@ def _create_temp_file_with_content(content):
|
62 | 62 | return name
|
63 | 63 |
|
64 | 64 |
|
65 |
| -def _is_expired(expiry): |
66 |
| - return ((parse_rfc3339(expiry) - EXPIRY_SKEW_PREVENTION_DELAY) <= |
| 65 | +def _is_stale(expiry): |
| 66 | + return ((parse_rfc3339(expiry) - MINIMUM_TOKEN_TIME_REMAINING) <= |
67 | 67 | datetime.datetime.utcnow().replace(tzinfo=UTC))
|
68 | 68 |
|
69 | 69 |
|
@@ -198,7 +198,7 @@ def _load_gcp_token(self):
|
198 | 198 | if (('config' not in provider) or
|
199 | 199 | ('access-token' not in provider['config']) or
|
200 | 200 | ('expiry' in provider['config'] and
|
201 |
| - _is_expired(provider['config']['expiry']))): |
| 201 | + _is_stale(provider['config']['expiry']))): |
202 | 202 | # token is not available or expired, refresh it
|
203 | 203 | self._refresh_gcp_token()
|
204 | 204 |
|
@@ -243,7 +243,7 @@ def _load_oid_token(self):
|
243 | 243 | expire = jwt_attributes.get('exp')
|
244 | 244 |
|
245 | 245 | if ((expire is not None) and
|
246 |
| - (_is_expired(datetime.datetime.fromtimestamp(expire, |
| 246 | + (_is_stale(datetime.datetime.fromtimestamp(expire, |
247 | 247 | tz=UTC)))):
|
248 | 248 | self._refresh_oidc(provider)
|
249 | 249 |
|
|
0 commit comments