Skip to content

Commit

Permalink
store: Enable to recieve TOCDigest from runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Kohei Tokunaga <[email protected]>
  • Loading branch information
ktock committed May 21, 2024
1 parent f837845 commit ae56e3c
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 125 deletions.
5 changes: 2 additions & 3 deletions cmd/stargz-store/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,8 @@ func main() {
Fatalf("failed to prepare mountpoint %q", mountPoint)
}
}
if !config.Config.DisableVerification {
log.G(ctx).Warnf("content verification is not supported; switching to non-verification mode")
config.Config.DisableVerification = true
if config.Config.DisableVerification {
log.G(ctx).Fatalf("content verification can't be disabled")
}
mt, err := getMetadataStore(*rootDir, config)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions fs/layer/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ type Info struct {
FetchedSize int64 // layer fetched size in bytes
PrefetchSize int64 // layer prefetch size in bytes
ReadTime time.Time // last time the layer was read
TOCDigest digest.Digest
}

// Resolver resolves the layer location and provieds the handler of that layer.
Expand Down Expand Up @@ -415,6 +416,7 @@ func (l *layer) Info() Info {
FetchedSize: l.blob.FetchedSize(),
PrefetchSize: l.prefetchedSize(),
ReadTime: readTime,
TOCDigest: l.verifiableReader.Metadata().TOCDigest(),
}
}

Expand Down
1 change: 0 additions & 1 deletion script/demo-store/etc/stargz-store/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
metrics_address = "127.0.0.1:8234"
disable_verification = true
[[resolver.host."registry2-store:5000".mirrors]]
host = "registry2-store:5000"
insecure = true
10 changes: 9 additions & 1 deletion store/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,20 @@ func (n *layernode) Lookup(ctx context.Context, name string, out *fuse.EntryOut)
return nil, syscall.EIO
}
log.G(ctx).WithField(remoteSnapshotLogKey, prepareFailed).
WithField("layerdigest", n.digest).
WithField("digest", n.digest).
WithError(err).
Debugf("error resolving layer (context error: %v)", cErr)
log.G(ctx).WithError(err).Warnf("failed to mount layer %q: %q", name, n.digest)
return nil, syscall.EIO
}
if err := l.Verify(n.digest); err != nil {
log.G(ctx).WithField(remoteSnapshotLogKey, prepareFailed).
WithField("digest", n.digest).
WithError(err).
Debugf("failed to verify layer")
log.G(ctx).WithError(err).Warnf("failed to mount layer %q: %q", name, n.digest)
return nil, syscall.EIO
}
if name == blobLink {
sAttr := layerToAttr(l, &out.Attr)
cn := &blobnode{l: l}
Expand Down
Loading

0 comments on commit ae56e3c

Please sign in to comment.