fix(meta): fixes for LastUpdated and TaggedTimestamp (#3754)

1. Parse repos without metadata in ParseStorage

The timestamp check in ParseStorage was skipping repos that exist in
storage but don't have metadata. When GetRepoLastUpdated returns zero
time (no metadata), we should always parse the repo to create its
metadata. Check if metaLastUpdated is zero before comparing timestamps.
If zero, always parse regardless of storageLastUpdated.

2. Change the logic of how LastUpdated is computed in RepoSummary

It is not the latest tagged timestamp from the available images or
the last updated image created timestamp, based on whichever is the
latest.

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
Andrei Aaron
2026-02-03 21:10:35 +02:00
committed by GitHub
parent d5b1b2d25b
commit 3c8030b2c7
18 changed files with 602 additions and 55 deletions
+6 -1
View File
@@ -1182,7 +1182,12 @@ func (bdw *BoltDB) ResetRepoReferences(repo string, tagsToKeep map[string]bool)
repoMetaBlob := buck.Get([]byte(repo))
protoRepoMeta, err := unmarshalProtoRepoMeta(repo, repoMetaBlob)
if err != nil && !errors.Is(err, zerr.ErrRepoMetaNotFound) {
if err != nil {
if errors.Is(err, zerr.ErrRepoMetaNotFound) {
// Repo doesn't exist, nothing to reset
return nil
}
return err
}
+37
View File
@@ -308,6 +308,43 @@ func TestWrapperErrors(t *testing.T) {
})
Convey("ResetRepoReferences", func() {
Convey("repo doesn't exist - returns early without error", func() {
ctx := context.Background()
// Verify repo doesn't exist
_, err := boltdbWrapper.GetRepoMeta(ctx, "nonexistent-repo")
So(err, ShouldNotBeNil)
So(errors.Is(err, zerr.ErrRepoMetaNotFound), ShouldBeTrue)
// ResetRepoReferences should return early without error
err = boltdbWrapper.ResetRepoReferences("nonexistent-repo", nil)
So(err, ShouldBeNil)
// Verify repo still doesn't exist
_, err = boltdbWrapper.GetRepoMeta(ctx, "nonexistent-repo")
So(err, ShouldNotBeNil)
So(errors.Is(err, zerr.ErrRepoMetaNotFound), ShouldBeTrue)
})
Convey("repo doesn't exist with tagsToKeep - returns early without error", func() {
ctx := context.Background()
// Verify repo doesn't exist
_, err := boltdbWrapper.GetRepoMeta(ctx, "nonexistent-repo2")
So(err, ShouldNotBeNil)
So(errors.Is(err, zerr.ErrRepoMetaNotFound), ShouldBeTrue)
// ResetRepoReferences should return early without error even with tagsToKeep
tagsToKeep := map[string]bool{"tag1": true}
err = boltdbWrapper.ResetRepoReferences("nonexistent-repo2", tagsToKeep)
So(err, ShouldBeNil)
// Verify repo still doesn't exist
_, err = boltdbWrapper.GetRepoMeta(ctx, "nonexistent-repo2")
So(err, ShouldNotBeNil)
So(errors.Is(err, zerr.ErrRepoMetaNotFound), ShouldBeTrue)
})
Convey("unmarshalProtoRepoMeta error", func() {
err := setRepoMeta("repo", badProtoBlob, boltdbWrapper.DB)
So(err, ShouldBeNil)