Skip to content

Commit

Permalink
fix(metadb): populate image pushTimestamp if it's 0 value
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
eusebiu-constantin-petu-dbk committed Nov 8, 2023
1 parent 7f52f58 commit 7313d43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/meta/boltdb/boltdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Check warning on line 204 in pkg/meta/boltdb/boltdb.go

View check run for this annotation

Codecov / codecov/patch

pkg/meta/boltdb/boltdb.go#L204

Added line #L204 was not covered by tests
}

if _, ok := protoRepoMeta.Signatures[imageMeta.Digest.String()]; !ok {
Expand Down
2 changes: 2 additions & 0 deletions pkg/meta/dynamodb/dynamodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Check warning on line 327 in pkg/meta/dynamodb/dynamodb.go

View check run for this annotation

Codecov / codecov/patch

pkg/meta/dynamodb/dynamodb.go#L327

Added line #L327 was not covered by tests
}

if _, ok := repoMeta.Signatures[imageMeta.Digest.String()]; !ok {
Expand Down

0 comments on commit 7313d43

Please sign in to comment.