-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
snapshot: fix error on proxy driver when switching different snapshotter #593
Conversation
b9cb808
to
c1fbf56
Compare
cc @imeoer |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #593 +/- ##
==========================================
- Coverage 34.64% 34.36% -0.29%
==========================================
Files 65 65
Lines 6552 6606 +54
==========================================
Hits 2270 2270
- Misses 3967 4021 +54
Partials 315 315
|
@ChengyuZhu6 Thanks! I'll try to reproduce the bug and test the PR. |
76c8880
to
437002b
Compare
This does work around the problem we've encountered when using guest-pull with Confidential Containers. More than working around the issue, it gives us enough time to work on containerd (which has a pace of release and adoption that can be slow to reach all the CSPs) fix without worrying much about which version of containerd will be used with Confidential Containers. Huge thumbs up for having this one in! |
@ChengyuZhu6, I'd love to see, as part of the commit message, as much information as you provided in the issue. |
FYI - I've also testing this code and quay.io/chengyu_zhu/nydus-snapshotter@sha256:4b5e333ecd27d7b630cbe42fe686f8b3c38df7727c99f4b5cef724be6f3926fa with peer pods and it seemed to work without the workaround of cleaning up the images and content on the node. Amazing work! |
e14a326
to
115a8ac
Compare
snapshot/process.go
Outdated
@@ -57,6 +57,12 @@ func chooseProcessor(ctx context.Context, logger *logrus.Entry, | |||
} | |||
} | |||
|
|||
proxyhandler := func() (bool, []mount.Mount, error) { | |||
logger.Infof("Nydus proxy handler") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a necessary log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
snapshot/process.go
Outdated
@@ -118,6 +124,10 @@ func chooseProcessor(ctx context.Context, logger *logrus.Entry, | |||
// It should not be committed during this Prepare() operation. | |||
|
|||
pID, pInfo, _, pErr := snapshot.GetSnapshotInfo(ctx, sn.ms, parent) | |||
if checkErr := checkLabelsWithDriver(pInfo.Labels); checkErr != nil { | |||
logger.Infof("not found proxy label: %v, err = %v", pInfo.Labels, checkErr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infof
-> Warnf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
snapshot/process.go
Outdated
@@ -57,6 +57,12 @@ func chooseProcessor(ctx context.Context, logger *logrus.Entry, | |||
} | |||
} | |||
|
|||
proxyhandler := func() (bool, []mount.Mount, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better be proxyhandler
-> proxyHandler
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
snapshot/snapshot.go
Outdated
"github.com/containerd/nydus-snapshotter/config" | ||
"github.com/containerd/nydus-snapshotter/config/daemonconfig" | ||
rafs "github.com/containerd/nydus-snapshotter/pkg/rafs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is an alias necessary?
snapshot/snapshot.go
Outdated
@@ -432,6 +432,11 @@ func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er | |||
return nil, errors.Wrapf(err, "get snapshot %s", key) | |||
} | |||
|
|||
if checkErr := checkLabelsWithDriver(info.Labels); checkErr != nil { | |||
log.L.Debug("[Mounts] not found proxy label") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also print the detail reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
snapshot/snapshot.go
Outdated
@@ -1011,3 +1063,18 @@ func (o *snapshotter) snapshotRoot() string { | |||
func (o *snapshotter) snapshotDir(id string) string { | |||
return filepath.Join(o.snapshotRoot(), id) | |||
} | |||
|
|||
func checkLabelsWithDriver(labels map[string]string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about func treatAsProxyDriver(labels map[string]string) bool
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
snapshot/snapshot.go
Outdated
FsDriver: config.GetFsDriver(), | ||
ImageID: "", | ||
SnapshotID: "", | ||
SnapshotDir: "", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that FsDriver, ImageID, SnapshotID, SnapshotDir can be omitted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed ImageID, SnapshotID, SnapshotDir, but we still need FsDriver and annotations.
38d0d9f
to
fa24178
Compare
a27f916
to
6e06754
Compare
snapshot/snapshot.go
Outdated
@@ -1011,3 +1060,18 @@ func (o *snapshotter) snapshotRoot() string { | |||
func (o *snapshotter) snapshotDir(id string) string { | |||
return filepath.Join(o.snapshotRoot(), id) | |||
} | |||
|
|||
func treatAsProxyDriver(labels map[string]string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about change the return type to bool
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
snapshot/process.go
Outdated
@@ -118,6 +123,10 @@ func chooseProcessor(ctx context.Context, logger *logrus.Entry, | |||
// It should not be committed during this Prepare() operation. | |||
|
|||
pID, pInfo, _, pErr := snapshot.GetSnapshotInfo(ctx, sn.ms, parent) | |||
if checkErr := treatAsProxyDriver(pInfo.Labels); checkErr != nil { | |||
logger.Warnf("not found proxy label: %v, err = %v", pInfo.Labels, checkErr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can print a clarify message like treat as proxy mode for the prepared snapshot by other snapshotter possibly: id = %s, labels = %v
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
snapshot/snapshot.go
Outdated
@@ -432,6 +432,11 @@ func (o *snapshotter) Mounts(ctx context.Context, key string) ([]mount.Mount, er | |||
return nil, errors.Wrapf(err, "get snapshot %s", key) | |||
} | |||
|
|||
if checkErr := treatAsProxyDriver(info.Labels); checkErr != nil { | |||
log.L.Debugf("[Mounts] not found proxy label, err = %v", checkErr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
b5b72c5
to
b01f842
Compare
During image pull, the containerd client calls Prepare API with the label containerd.io/snapshot.ref. When an image is pulled by other snapshotter, containerd doesn't send the label "containerd.io/snapshot.ref" to nydus snapshotter to let snapshotter prepare ro layers. Consequently, the code logic in nydus snapshotter cannot find label "containerd.io/snapshot/nydus-proxy-mode" and the logic of guest pull (proxy) is skipped. This occurs while reading the label data of parent snapshots(ro layers) during the preparation of the active snapshot(rw layer). Thus, when the snapshotter driver is configured to proxy mode, nydus snapshotter is compelled to implement the proxy logic. Fixes: containerd#592 Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the fix!
- Bump the nydus snapshotter version to v0.13.13, in order to pick the nydus-snapshotter caching workaround containerd/nydus-snapshotter#593 Signed-off-by: stevenhorsman <steven@uk.ibm.com>
- Bump the nydus snapshotter version to v0.13.13, in order to pick the nydus-snapshotter caching workaround containerd/nydus-snapshotter#593 Signed-off-by: stevenhorsman <steven@uk.ibm.com>
Fixes: #592