Skip to content

Commit

Permalink
Fix unnecessary lastUnpacked status updates
Browse files Browse the repository at this point in the history
We should not be updating lastUnpacked status fields when
we read from the cache

Signed-off-by: Mikalai Radchuk <[email protected]>
  • Loading branch information
m1kola committed Sep 12, 2024
1 parent 8e71e93 commit 0fffaed
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions internal/source/image_registry_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ func (i *ImageRegistry) Unpack(ctx context.Context, catalog *catalogdv1alpha1.Cl
resolvedRef := fmt.Sprintf("%s@sha256:%s", imgRef.Context().Name(), digestHex)
if stat, err := os.Stat(unpackPath); err == nil && stat.IsDir() {
l.V(1).Info("found image in filesystem cache", "digest", digestHex)
// TODO: https://github.com/operator-framework/catalogd/issues/389
return unpackedResult(os.DirFS(unpackPath), catalog, resolvedRef, metav1.Time{Time: time.Now()}), nil
lastUnpacked := metav1.Time{}
if catalog.Status.ResolvedSource != nil && catalog.Status.ResolvedSource.Image != nil {
lastUnpacked = catalog.Status.ResolvedSource.Image.LastUnpacked
}
return unpackedResult(os.DirFS(unpackPath), catalog, resolvedRef, lastUnpacked), nil
}

if _, err = os.Stat(unpackPath); errors.Is(err, os.ErrNotExist) { //nolint: nestif
Expand Down

0 comments on commit 0fffaed

Please sign in to comment.