Skip to content

Commit a04f1b9

Browse files
committed
fix: dynamodb fixes
Signed-off-by: Ramkumar Chinchani <rchincha.dev@gmail.com>
1 parent b2bd4d2 commit a04f1b9

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

pkg/storage/cache/dynamodb.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
zerr "zotregistry.dev/zot/v2/errors"
1616
zlog "zotregistry.dev/zot/v2/pkg/log"
17+
"zotregistry.dev/zot/v2/pkg/storage/constants"
1718
)
1819

1920
type DynamoDBDriver struct {
@@ -186,11 +187,22 @@ func (d *DynamoDBDriver) PutBlob(digest godigest.Digest, path string) error {
186187
return zerr.ErrEmptyValue
187188
}
188189

189-
if originBlob, _ := d.GetBlob(digest); originBlob == "" {
190+
originBlob, _ := d.GetBlob(digest)
191+
if originBlob == "" {
190192
// first entry, so add original blob
191193
if err := d.putOriginBlob(digest, path); err != nil {
194+
d.log.Error().Err(err).Str("bucket", constants.OriginalBucket).Str("value", path).Msg("failed to put record")
195+
192196
return err
193197
}
198+
199+
d.log.Debug().Str("digest", digest.String()).Str("path", path).Msg("inserted in original bucket")
200+
201+
return nil
202+
} else if originBlob == path { // idempotent
203+
d.log.Debug().Str("digest", digest.String()).Str("path", path).Msg("inserted same key in original bucket")
204+
205+
return nil
194206
}
195207

196208
expression := "ADD DuplicateBlobPath :i"
@@ -202,6 +214,8 @@ func (d *DynamoDBDriver) PutBlob(digest godigest.Digest, path string) error {
202214
return err
203215
}
204216

217+
d.log.Debug().Str("digest", digest.String()).Str("path", path).Msg("inserted in duplicates bucket")
218+
205219
return nil
206220
}
207221

0 commit comments

Comments
 (0)