Skip to content

Commit

Permalink
fix: cache by project
Browse files Browse the repository at this point in the history
With argoproj#18388 we need to scope our cached chart paths by project.

Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
  • Loading branch information
blakepettersson committed Sep 10, 2024
1 parent 175a983 commit 701222e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,13 @@ func (s *Service) runRepoOperation(
}

if settings.noCache {
err = ociClient.CleanCache(digest)
err = ociClient.CleanCache(digest, repo.Project)
if err != nil {
return err
}
}

ociPath, closer, err := ociClient.Extract(ctx, digest, s.initConstants.HelmManifestMaxExtractedSize, s.initConstants.DisableHelmManifestMaxExtractedSize)
ociPath, closer, err := ociClient.Extract(ctx, digest, repo.Project, s.initConstants.HelmManifestMaxExtractedSize, s.initConstants.DisableHelmManifestMaxExtractedSize)
if err != nil {
return err
}
Expand Down
16 changes: 8 additions & 8 deletions util/oci/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ type Client interface {
GetTags(ctx context.Context, noCache bool) (*TagsList, error)
ResolveDigest(ctx context.Context, revision string) (string, error)
ResolveRevision(ctx context.Context, revision string, noCache bool) (string, error)
CleanCache(revision string) error
Extract(ctx context.Context, revision string, manifestMaxExtractedSize int64, disableManifestMaxExtractedSize bool) (string, argoio.Closer, error)
CleanCache(revision string, project string) error
Extract(ctx context.Context, revision string, project string, manifestMaxExtractedSize int64, disableManifestMaxExtractedSize bool) (string, argoio.Closer, error)
TestRepo(ctx context.Context) (bool, error)
}

Expand Down Expand Up @@ -147,8 +147,8 @@ func (c *nativeOciClient) TestRepo(ctx context.Context) (bool, error) {
return err == nil, err
}

func (c *nativeOciClient) Extract(ctx context.Context, revision string, manifestMaxExtractedSize int64, disableManifestMaxExtractedSize bool) (string, argoio.Closer, error) {
cachedPath, err := c.getCachedPath(revision)
func (c *nativeOciClient) Extract(ctx context.Context, revision string, project string, manifestMaxExtractedSize int64, disableManifestMaxExtractedSize bool) (string, argoio.Closer, error) {
cachedPath, err := c.getCachedPath(revision, project)
if err != nil {
return "", nil, err
}
Expand Down Expand Up @@ -176,16 +176,16 @@ func (c *nativeOciClient) Extract(ctx context.Context, revision string, manifest
return cachedPath, fs, nil
}

func (c *nativeOciClient) getCachedPath(version string) (string, error) {
keyData, err := json.Marshal(map[string]string{"url": c.repoURL, "version": version})
func (c *nativeOciClient) getCachedPath(version, project string) (string, error) {
keyData, err := json.Marshal(map[string]string{"url": c.repoURL, "project": project, "version": version})
if err != nil {
return "", err
}
return c.repoCachePaths.GetPath(string(keyData))
}

func (c *nativeOciClient) CleanCache(revision string) error {
cachePath, err := c.getCachedPath(revision)
func (c *nativeOciClient) CleanCache(revision, project string) error {
cachePath, err := c.getCachedPath(revision, project)
if err != nil {
return err
}
Expand Down

0 comments on commit 701222e

Please sign in to comment.