Skip to content

Commit

Permalink
snapshot: fix error on proxy driver when switching different snapshotter
Browse files Browse the repository at this point in the history
Fixes: #592

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
  • Loading branch information
ChengyuZhu6 committed Apr 28, 2024
1 parent ce4848e commit b9cb808
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ func (o *snapshotter) Cleanup(ctx context.Context) error {
}

func (o *snapshotter) Stat(ctx context.Context, key string) (snapshots.Info, error) {
log.L.Debugf("[Stat] snapshots")
_, info, _, err := snapshot.GetSnapshotInfo(ctx, o.ms, key)
if checkErr := o.checkLabelsWithDriver(info.Labels); checkErr != nil {
return snapshots.Info{}, errors.New("not found")
}
return info, err
}

Expand Down Expand Up @@ -1011,3 +1015,14 @@ func (o *snapshotter) snapshotRoot() string {
func (o *snapshotter) snapshotDir(id string) string {
return filepath.Join(o.snapshotRoot(), id)
}

func (o *snapshotter) checkLabelsWithDriver(labels map[string]string) error {
isProxyDriver := config.GetFsDriver() == config.FsDriverProxy
isProxyLabel := label.IsNydusProxyMode(labels)
if (isProxyDriver && !isProxyLabel) || (!isProxyDriver && isProxyLabel) {
return errors.Errorf("check Labels With Driver failed, driver = %q, labels = %q", config.GetFsDriver(), labels)
}
//TODO fix the same issue in tarfs driver

Check failure on line 1025 in snapshot/snapshot.go

View workflow job for this annotation

GitHub Actions / Build and Lint

commentFormatting: put a space between `//` and comment text (gocritic)

return nil
}

0 comments on commit b9cb808

Please sign in to comment.