Skip to content

Commit

Permalink
chore(kuma-cp) reduce cache key size (#2214)
Browse files Browse the repository at this point in the history
(cherry picked from commit 776523f)
  • Loading branch information
nhamlh authored and mergify-bot committed Jun 28, 2021
1 parent debb9fc commit ef5d527
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/xds/cache/cla/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cla
import (
"context"
"fmt"
"crypto/sha256"
"encoding/base64"
"time"

"github.com/golang/protobuf/proto"
Expand Down Expand Up @@ -56,7 +58,14 @@ func NewCache(
}

func (c *Cache) GetCLA(ctx context.Context, meshName, meshHash string, cluster envoy_common.Cluster, apiVersion envoy_common.APIVersion) (proto.Message, error) {
key := fmt.Sprintf("%s:%s:%s:%s", apiVersion, meshName, cluster.Hash(), meshHash)
hash := sha256.New()
_, err := hash.Write([]byte(fmt.Sprintf("%s:%s:%s:%s", apiVersion, meshName, cluster.Hash(), meshHash)))
if err != nil {
return nil, err
}

key := base64.StdEncoding.EncodeToString(hash.Sum(nil))

elt, err := c.cache.GetOrRetrieve(ctx, key, once.RetrieverFunc(func(ctx context.Context, key string) (interface{}, error) {
dataplanes, err := topology.GetDataplanes(claCacheLog, ctx, c.rm, c.ipFunc, meshName)
if err != nil {
Expand Down

0 comments on commit ef5d527

Please sign in to comment.