inline GC in expiring cache

This allows us to drop the background goroutine with negligable
difference in performance.
This commit is contained in:
Mike Danese
2019-11-15 17:04:28 -08:00
parent f2469a7a2c
commit d16dde36a3
11 changed files with 41 additions and 115 deletions

View File

@@ -70,7 +70,7 @@ func getTestTokenAuth() authenticator.Request {
return group.NewGroupAdder(bearertoken.New(tokenAuthenticator), []string{user.AllAuthenticated})
}
func getTestWebhookTokenAuth(ctx context.Context, serverURL string) (authenticator.Request, error) {
func getTestWebhookTokenAuth(serverURL string) (authenticator.Request, error) {
kubecfgFile, err := ioutil.TempFile("", "webhook-kubecfg")
if err != nil {
return nil, err
@@ -90,7 +90,7 @@ func getTestWebhookTokenAuth(ctx context.Context, serverURL string) (authenticat
if err != nil {
return nil, err
}
return bearertoken.New(cache.New(ctx, webhookTokenAuth, false, 2*time.Minute, 2*time.Minute)), nil
return bearertoken.New(cache.New(webhookTokenAuth, false, 2*time.Minute, 2*time.Minute)), nil
}
func path(resource, namespace, name string) string {
@@ -1176,11 +1176,7 @@ func TestReadOnlyAuthorization(t *testing.T) {
func TestWebhookTokenAuthenticator(t *testing.T) {
authServer := newTestWebhookTokenAuthServer()
defer authServer.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
authenticator, err := getTestWebhookTokenAuth(ctx, authServer.URL)
authenticator, err := getTestWebhookTokenAuth(authServer.URL)
if err != nil {
t.Fatalf("error starting webhook token authenticator server: %v", err)
}