From 7313d431aa14bc59b769bbd077ab67e98db6f82f Mon Sep 17 00:00:00 2001 From: Petu Eusebiu Date: Thu, 2 Nov 2023 18:54:38 +0200 Subject: [PATCH] fix(metadb): populate image pushTimestamp if it's 0 value in the case of an already existing meta db without pushTimestamp field its value would be 0 until image is updated, check for zero values and update them with time.Now() so that retention logic won't remove them. Signed-off-by: Petu Eusebiu --- pkg/meta/boltdb/boltdb.go | 2 ++ pkg/meta/dynamodb/dynamodb.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/pkg/meta/boltdb/boltdb.go b/pkg/meta/boltdb/boltdb.go index 904f5e3b02..8abe51f6ac 100644 --- a/pkg/meta/boltdb/boltdb.go +++ b/pkg/meta/boltdb/boltdb.go @@ -200,6 +200,8 @@ func (bdw *BoltDB) SetRepoReference(ctx context.Context, repo string, reference PushTimestamp: timestamppb.Now(), PushedBy: userid, } + } else if protoRepoMeta.Statistics[imageMeta.Digest.String()].PushTimestamp.AsTime().IsZero() { + protoRepoMeta.Statistics[imageMeta.Digest.String()].PushTimestamp = timestamppb.Now() } if _, ok := protoRepoMeta.Signatures[imageMeta.Digest.String()]; !ok { diff --git a/pkg/meta/dynamodb/dynamodb.go b/pkg/meta/dynamodb/dynamodb.go index 92ec2271ca..dc89913917 100644 --- a/pkg/meta/dynamodb/dynamodb.go +++ b/pkg/meta/dynamodb/dynamodb.go @@ -323,6 +323,8 @@ func (dwr *DynamoDB) SetRepoReference(ctx context.Context, repo string, referenc PushTimestamp: timestamppb.Now(), PushedBy: userid, } + } else if repoMeta.Statistics[imageMeta.Digest.String()].PushTimestamp.AsTime().IsZero() { + repoMeta.Statistics[imageMeta.Digest.String()].PushTimestamp = timestamppb.Now() } if _, ok := repoMeta.Signatures[imageMeta.Digest.String()]; !ok {