Fix optional EROFS differ setup in transfer plugin#13328
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors transfer plugin unpack-platform configuration to correctly handle unavailable (skipped) diff plugins—especially the EROFS differ—so optional configurations don’t block transfers when a differ is not usable on the host.
Changes:
- Extracted unpack platform configuration into
configureUnpackPlatformsand centralized differ selection ingetApplier, adding logic to skip optional differs when plugin init returns errors (includingplugin.ErrSkipPlugin). - Added unit tests covering optional/required explicit differ behavior and auto-selection skipping skipped candidates.
- Added a Linux-specific test verifying the default config skips an unavailable EROFS differ and still configures the default unpack platform.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| plugins/transfer/plugin.go | Refactors unpack-platform setup and differ selection; adds skip/optional handling for unavailable differs. |
| plugins/transfer/plugin_test.go | Adds focused unit tests for configureUnpackPlatforms/getApplier skip and selection behavior. |
| plugins/transfer/plugin_linux_test.go | Adds Linux-only test validating default config behavior when EROFS differ is unavailable. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0a6e700 to
f92fef6
Compare
f92fef6 to
d0d43f4
Compare
d0d43f4 to
2591ac9
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes transfer plugin initialization/unpack platform configuration so that optional EROFS unpack entries don’t block transfers when the EROFS differ plugin is unavailable (e.g., returns plugin.ErrSkipPlugin).
Changes:
- Refactors unpack platform setup into
configureUnpackPlatformsand moves diff-applier selection intogetApplier, adding explicit handling forErrSkipPluginand optional configs. - Ensures optional unpack configs are skipped when their explicit differ is missing or fails to initialize.
- Adds unit tests (including a Linux-specific test) covering optional differ skipping and auto-selection behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| plugins/transfer/plugin.go | Refactors unpack platform configuration and fixes differ selection to skip unavailable/skip-plugin differs for optional configs. |
| plugins/transfer/plugin_test.go | Adds unit tests and helpers for plugin set initialization and unpack platform configuration scenarios. |
| plugins/transfer/plugin_linux_test.go | Adds Linux-only regression test ensuring default config skips unavailable EROFS differ and keeps only the default unpack platform. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if p := ic.Plugins().Get(plugins.SnapshotPlugin, uc.Snapshotter); p != nil { | ||
| snExports = p.Meta.Exports | ||
| snCapabilities = p.Meta.Capabilities |
prakleumas
left a comment
There was a problem hiding this comment.
beep boop
Hello! I am @samuelkarp's friendly code review robot 🤖! Sam asked me to take a look and post my comments directly on GitHub.
Please treat my comments as suggestions and advisory, not mandates. Since I am an LLM and my output is used here directly, you should evaluate carefully and see if my suggestions make sense. Feel free to directly resolve any you disagree with.
This is not an automated action. This bot does not read or reply to comments.
| if err != nil { | ||
| return fmt.Errorf("%s: platform configuration %v invalid", plugins.TransferPlugin, uc.Platform) | ||
| } |
There was a problem hiding this comment.
It is generally safer to preserve the underlying error when returning a new error so that the original cause is not lost, which aids in debugging and auditability.
| if err != nil { | |
| return fmt.Errorf("%s: platform configuration %v invalid", plugins.TransferPlugin, uc.Platform) | |
| } | |
| if err != nil { | |
| return fmt.Errorf("%s: platform configuration %v invalid: %w", plugins.TransferPlugin, uc.Platform, err) | |
| } |
There was a problem hiding this comment.
Agree, as it is though this is moved untouched.
I was already kind of iffy about including the refactor without the actual patch (as it is in the first commit) instead of just doing the patch and doing a separate change to refactor.
But I also wanted to unit test it so, here we are.
| } | ||
| return nil, false, fmt.Errorf("failed to get instance for diff plugin %q: %w", uc.Differ, err) | ||
| } | ||
| return inst.(diff.Applier), false, nil |
There was a problem hiding this comment.
It is generally safer to protect type assertions with an ok check to prevent unrecoverable panics during initialization. If a misconfigured plugin returns an instance that does not implement diff.Applier, this introduces the opportunity for a panic.
| skippedApplier = applierID | ||
| } | ||
|
|
||
| log.G(ic.Context).Warnf("multiple differs match for platform, set `differ` option to choose, skipping %q", skippedApplier) |
There was a problem hiding this comment.
Structured logging is generally preferred over printf-style formatting when injecting dynamic variables into log messages, as it preserves the fields for easier querying in log aggregators.
| log.G(ic.Context).Warnf("multiple differs match for platform, set `differ` option to choose, skipping %q", skippedApplier) | |
| log.G(ic.Context).WithField("skipped_applier", skippedApplier).Warn("multiple differs match for platform, set `differ` option to choose") |
| applier = inst.(diff.Applier) | ||
| applierID = candidate.Registration.ID |
There was a problem hiding this comment.
Similarly, ensuring that the instance satisfies the expected interface avoids panics when iterating through candidate plugins.
hsiangkao
left a comment
There was a problem hiding this comment.
Hi, it looks good to me, but in order to make the pr more reviewable and backportable, could we fix the bug first and refactor the code into helpers then instead?
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2591ac9 to
f8a5f8d
Compare
|
@hsiangkao Sure. I mainly wanted to make sure the patch had a valid test so that backports have less potential to have an issue, however I don't think this will be difficult to backport to 2.3 either way. This is updated accordingly. |
|
Closes #13346 |
hmm it looks like test code issue |
|
/cherry-pick release/2.3 |
|
@AkihiroSuda: new pull request created: #13364 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Found this during some smoke tests for containerd 2.3.
On my system I have erofs available but I was running tests in a container which didn't have mkfs.erofs.
This got containerd into a weird state.
Transfer service completely failed to load, a few other things as well, and I couldn't even
ctr plugin ls, subscribe to events, nothing despite the grpc service running (returningUnavailablefor the things I tried).mkfs.erofs.