Skip to content

Commit

Permalink
change(service-account-server): more adjustments r.e. cache
Browse files Browse the repository at this point in the history
  • Loading branch information
l3uddz committed May 16, 2020
1 parent c34dd39 commit 44dd989
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions syncer/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type ServiceAccountRequest struct {
/* Const */

const (
maxSaCacheHits int = 4
maxSaCacheHits int = 6
durationSaCacheEntry time.Duration = 10 * time.Second
)

Expand Down Expand Up @@ -153,7 +153,7 @@ func (ws *WebServer) ServiceAccountHandler(c *fiber.Ctx) {
now := time.Now().UTC()
nsa, ok := ws.saCache.cache[req.OldServiceAccount]
switch {
case ok && nsa.Expires.After(now):
case ok && now.Before(nsa.Expires):
// we issued a replacement sa for this one already
nsa.Hits++
if nsa.Hits <= maxSaCacheHits {
Expand All @@ -164,7 +164,7 @@ func (ws *WebServer) ServiceAccountHandler(c *fiber.Ctx) {

// remove entries that have exceeded max hits
delete(ws.saCache.cache, req.OldServiceAccount)
case ok && nsa.Expires.Before(now):
case ok:
// we issued a replacement sa for this one already, but it has expired
delete(ws.saCache.cache, req.OldServiceAccount)
default:
Expand Down

0 comments on commit 44dd989

Please sign in to comment.