Merge pull request #72673 from liggitt/automated-cherry-pick-of-#72437-upstream-release-1.12

Automated cherry pick of #72437: Shorten re-read period for token files to work with

Kubernetes-commit: 4875c91e02890e082af959e94abc91f6e5e0c939
This commit is contained in:
Kubernetes Publisher
2019-01-09 05:10:25 -08:00

View File

@@ -45,14 +45,14 @@ func TokenSourceWrapTransport(ts oauth2.TokenSource) func(http.RoundTripper) htt
func newCachedPathTokenSource(path string) oauth2.TokenSource {
return &cachingTokenSource{
now: time.Now,
leeway: 1 * time.Minute,
leeway: 10 * time.Second,
base: &fileTokenSource{
path: path,
// This period was picked because it is half of the minimum validity
// duration for a token provisioned by they TokenRequest API. This is
// unsophisticated and should induce rotation at a frequency that should
// work with the token volume source.
period: 5 * time.Minute,
// This period was picked because it is half of the duration between when the kubelet
// refreshes a projected service account token and when the original token expires.
// Default token lifetime is 10 minutes, and the kubelet starts refreshing at 80% of lifetime.
// This should induce re-reading at a frequency that works with the token volume source.
period: time.Minute,
},
}
}