Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catalogd never uses filesystem cache for image references with tags #392

Closed
Tracked by #950
m1kola opened this issue Sep 11, 2024 · 1 comment · Fixed by #394
Closed
Tracked by #950

catalogd never uses filesystem cache for image references with tags #392

m1kola opened this issue Sep 11, 2024 · 1 comment · Fixed by #394
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@m1kola
Copy link
Member

m1kola commented Sep 11, 2024

Steps to reproduce

  1. Create a ClusterCatalog which uses an image ref with a tag
    apiVersion: olm.operatorframework.io/v1alpha1
    kind: ClusterCatalog
    metadata:
      name: operatorhubio
    spec:
      source:
        type: image
        image:
          ref: quay.io/operatorhubio/catalog:latest
          pollInterval: 5s
  2. Observe logs

Expected result

On a second poll (after 5 seconds in our example) you should see a log line (code) saying that we hit the cache containing the following string:

found image in filesystem cache

Actual results

No log line/cache hit.

Analysis

We never enter this condition because isDigest is always false:

digest, isDigest := imgRef.(name.Digest)
if isDigest {
hexVal := strings.TrimPrefix(digest.DigestStr(), "sha256:")
unpackPath := filepath.Join(i.BaseCachePath, catalog.Name, hexVal)
if stat, err := os.Stat(unpackPath); err == nil && stat.IsDir() {
l.V(1).Info("found image in filesystem cache", "digest", hexVal)
return unpackedResult(os.DirFS(unpackPath), catalog, digest.String(), metav1.Time{Time: time.Now()}), nil
}
}

This is because imgRef is just a parsed .spec.source.image.ref. We only resolve the ref below: after checking the cache. So if this field contains a ref with a tag - we only write into the filesystem cache and never read from it.

We have test cases for both digest and tag image refs, but the test is somehow green. The test is very complex and has a lot of parameters so I suspect there is a bug within the test somewhere.

@m1kola m1kola added the kind/bug Categorizes issue or PR as related to a bug. label Sep 11, 2024
@m1kola
Copy link
Member Author

m1kola commented Sep 11, 2024

It looks like "tag based image, digest already exists in cache" test case supposed to hit cache, but doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant