Skip to content

Commit

Permalink
šŸ› update catalog status field being used for stale cache identificatiā€¦
Browse files Browse the repository at this point in the history
ā€¦on (#529)

* (bugfix): update catalog status field being used for stale cache identification

Signed-off-by: Bryce Palmer <everettraven@gmail.com>

* fix failing unit test

Signed-off-by: Bryce Palmer <everettraven@gmail.com>

---------

Signed-off-by: Bryce Palmer <everettraven@gmail.com>
  • Loading branch information
everettraven committed Nov 9, 2023
1 parent b5c6bc9 commit bf39dc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions internal/catalogmetadata/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (fsc *filesystemCache) FetchCatalogContents(ctx context.Context, catalog *c

fsc.mutex.RLock()
if data, ok := fsc.cacheDataByCatalogName[catalog.Name]; ok {
if catalog.Status.ResolvedSource.Image.Ref == data.ResolvedRef {
if catalog.Status.ResolvedSource.Image.ResolvedRef == data.ResolvedRef {
fsc.mutex.RUnlock()
return os.Open(cacheFilePath)
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func (fsc *filesystemCache) FetchCatalogContents(ctx context.Context, catalog *c
}

fsc.cacheDataByCatalogName[catalog.Name] = cacheData{
ResolvedRef: catalog.Status.ResolvedSource.Image.Ref,
ResolvedRef: catalog.Status.ResolvedSource.Image.ResolvedRef,
}

return file, nil
Expand Down
12 changes: 6 additions & 6 deletions internal/catalogmetadata/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestCache(t *testing.T) {
ResolvedSource: &catalogd.ResolvedCatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ResolvedImageSource{
Ref: "fake/catalog@sha256:fakesha",
ResolvedRef: "fake/catalog@sha256:fakesha",
},
},
},
Expand All @@ -90,7 +90,7 @@ func TestCache(t *testing.T) {
ResolvedSource: &catalogd.ResolvedCatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ResolvedImageSource{
Ref: "fake/catalog@sha256:fakesha",
ResolvedRef: "fake/catalog@sha256:fakesha",
},
},
},
Expand All @@ -110,7 +110,7 @@ func TestCache(t *testing.T) {
ResolvedSource: &catalogd.ResolvedCatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ResolvedImageSource{
Ref: "fake/catalog@sha256:fakesha",
ResolvedRef: "fake/catalog@sha256:fakesha",
},
},
},
Expand All @@ -130,7 +130,7 @@ func TestCache(t *testing.T) {
ResolvedSource: &catalogd.ResolvedCatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ResolvedImageSource{
Ref: "fake/catalog@sha256:fakesha",
ResolvedRef: "fake/catalog@sha256:fakesha",
},
},
},
Expand All @@ -149,7 +149,7 @@ func TestCache(t *testing.T) {
ResolvedSource: &catalogd.ResolvedCatalogSource{
Type: catalogd.SourceTypeImage,
Image: &catalogd.ResolvedImageSource{
Ref: "fake/catalog@sha256:fakesha",
ResolvedRef: "fake/catalog@sha256:fakesha",
},
},
},
Expand Down Expand Up @@ -223,7 +223,7 @@ func TestCache(t *testing.T) {

if tt.testCaching {
if !tt.shouldHitCache {
tt.catalog.Status.ResolvedSource.Image.Ref = "fake/catalog@sha256:shafake"
tt.catalog.Status.ResolvedSource.Image.ResolvedRef = "fake/catalog@sha256:shafake"
}
tt.tripper.content = append(tt.tripper.content, []byte(`{"schema": "olm.package", "name": "foobar"}`)...)
rc, err := c.FetchCatalogContents(ctx, tt.catalog)
Expand Down

0 comments on commit bf39dc7

Please sign in to comment.