Skip to content

Conversation

apostasie
Copy link
Contributor

@apostasie apostasie commented May 1, 2025

This addresses a few issues from #4012 as a follow-up.

Besides a couple of mundane fixes, the bulk of it focuses on the ability to test binaries that are not named docker nor nerdctl.

This feature is especially interesting:

  • for people building forks, or custom cli on top of nerdctl as a library, that may use a different binary name
  • for gomodjail variants of course
  • for busy contributors or bisectors who want to be able to quickly test a bunch of differently named nerdctl binaries

Here is a list of things I wish I could test:

  • ~/docker.xyz
  • nerdctl.gomodjail
  • lepton
  • /somerandompath/nerdctl.xyz

The proposal here is to expand on the existing --test.target flag, that currently only allows docker and nerdctl.

The upside is that it strictly minimizes the amount of change required by the rest of the test tooling, is strictly backward compatible, and does not introduce new knobs.

Of course we still need a way to differentiate between docker, and "nerdishctl" binaries (cli that are expected to behave like nerdctl), as we do have specialized test behavior.

We do that here by checking strings.HasPrefix(filepath.Base(binary), "docker").

So:

go test ./cmd/nerdctl/... -test.target=~/docker.xyz is treated as docker, while any other variant above is treated as a "nerdishctl".

NOTE that:

  • there were a bunch of hardcoded assumptions in the tests assuming that the binary was named nerdctl, so, they got modified
  • the Target type and a couple of (now useless) consts have been removed

There is still some level of duplication between testutil / testutil/nerdtest - this is not new, and is transitory while we move to the new testing tooling - can be cleaned-up later on to keep this small.

@apostasie apostasie force-pushed the fix-gomodjail-integration branch 2 times, most recently from 4a59607 to b9e19f7 Compare May 2, 2025 00:10
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@apostasie
Copy link
Contributor Author

Thanks

Thanks @AkihiroSuda
Let me finish this real quick (something is not right with GetTarget / M) and then let's have a good look at the UX and see if that works well.

@apostasie apostasie force-pushed the fix-gomodjail-integration branch 2 times, most recently from 4a83d6d to f15db06 Compare May 2, 2025 00:57
@apostasie
Copy link
Contributor Author

@AkihiroSuda updated the initial comment with some details about the UX. lmk your thoughts.

Also, I am pretty sure there currently are tests that do not pass with the gomodjail targets (seen on another PR), but I think we can address that separately.

Pending (mostly) green that should be good to go (going to do another proofread rn).

testCase := nerdtest.Setup()

testCase.Require = require.Not(nerdtest.Gomodjail) // FIXME
// XXX Why?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be removed once we confirm this passes - or uncommented with some details.

func TestRunSigProxy(t *testing.T) {
testCase := nerdtest.Setup()
testCase.Require = require.Not(nerdtest.Gomodjail) // FIXME
// XXX Why?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ibid.

@apostasie apostasie changed the title [WIP] Follow-up fixes May 2, 2025
@apostasie apostasie marked this pull request as ready for review May 2, 2025 01:40
@apostasie apostasie closed this May 2, 2025
@apostasie apostasie reopened this May 2, 2025
@AkihiroSuda
Copy link
Member

Follow-up fixes

The PR title isn't descriptive

@apostasie apostasie changed the title Follow-up fixes [FIX]: #4012 follow-ups (fixes and target test binaries) May 2, 2025
@apostasie apostasie force-pushed the fix-gomodjail-integration branch from f15db06 to 836ab28 Compare May 2, 2025 03:07
@AkihiroSuda AkihiroSuda added this to the v2.1.0 milestone May 2, 2025
@AkihiroSuda
Copy link
Member

https://github.com/containerd/nerdctl/actions/runs/14787855221/job/41521670427?pr=4180

TestRunSigProxy is consistently failing

        |         | 🟠 time=2025-05-02T04:37:41.054Z level=WARN msg=***Blocked*** pid=47791 exe=/home/rootless/.cach |
        |         | e/gomodjail/1f381f194c295770/nerdctl syscall=openat entry=/go/pkg/mod/github.com/syndtr/gocapabi |
        |         | [email protected]/capability/capability_linux.go:53:github.com/syndtr/goca |
        |         | pability/capability.initLastCap module=github.com/syndtr/gocapability                            |
        |         | time=2025-05-02T04:37:41.055Z level=WARN msg=***Blocked*** pid=47791 exe=/home/rootless/.cache/g |
        |         | omodjail/1f381f194c295770/nerdctl syscall=fcntl entry=/go/pkg/mod/github.com/syndtr/gocapability |
        |         | @v0.0.0-20200815063812-42c35b437635/capability/capability_linux.go:53:github.com/syndtr/gocapabi |
        |         | lity/capability.initLastCap module=github.com/syndtr/gocapability                                |
        |         | time=2025-05-02T04:37:41.055Z level=WARN msg=***Blocked*** pid=47791 exe=/home/rootless/.cache/g |
        |         | omodjail/1f381f194c295770/nerdctl syscall=fcntl entry=/go/pkg/mod/github.com/syndtr/gocapability |
        |         | @v0.0.0-20200815063812-42c35b437635/capability/capability_linux.go:53:github.com/syndtr/gocapabi |
        |         | lity/capability.initLastCap module=github.com/syndtr/gocapability                                |
        |         | time=2025-05-02T04:37:41.055Z level=WARN msg=***Blocked*** pid=47791 exe=/home/rootless/.cache/g |
        |         | omodjail/1f381f194c295770/nerdctl syscall=fcntl entry=/go/pkg/mod/github.com/syndtr/gocapability |
        |         | @v0.0.0-20200815063812-42c35b437635/capability/capability_linux.go:53:github.com/syndtr/gocapabi |
        |         | lity/capability.initLastCap module=github.com/syndtr/gocapability                                |
        |         | time=2025-05-02T04:37:41.084Z level=WARN msg=***Blocked*** pid=47791 exe=/home/rootless/.cache/g |
        |         | omodjail/1f381f194c295770/nerdctl syscall=openat entry=/go/pkg/mod/github.com/syndtr/gocapabilit |
        |         | [email protected]/capability/capability_linux.go:53:github.com/syndtr/gocapab |
        |         | ility/capability.initLastCap module=github.com/syndtr/gocapability                               |
        |         | time=2025-05-02T04:37:41.084Z level=WARN msg=***Blocked*** pid=47791 exe=/home/rootless/.cache/g |
        |         | omodjail/1f381f194c295770/nerdctl syscall=fcntl entry=/go/pkg/mod/github.com/syndtr/gocapability |
        |         | @v0.0.0-20200815063812-42c35b437635/capability/capability_linux.go:53:github.com/syndtr/gocapabi |
        |         | lity/capability.initLastCap module=github.com/syndtr/gocapability                                |
        |         | time=2025-05-02T04:37:41.085Z level=WARN msg=***Blocked*** pid=47791 exe=/home/rootless/.cache/g |
        |         | omodjail/1f381f194c295770/nerdctl syscall=fcntl entry=/go/pkg/mod/github.com/syndtr/gocapability |
        |         | @v0.0.0-20200815063812-42c35b437635/capability/capability_linux.go:53:github.com/syndtr/gocapabi |
        |         | lity/capability.initLastCap module=github.com/syndtr/gocapability                                |
        |         | time=2025-05-02T04:37:41.085Z level=WARN msg=***Blocked*** pid=47791 exe=/home/rootless/.cache/g |
        |         | omodjail/1f381f194c295770/nerdctl syscall=fcntl entry=/go/pkg/mod/github.com/syndtr/gocapability |
        |         | @v0.0.0-20200815063812-42c35b437635/capability/capability_linux.go:53:github.com/syndtr/gocapabi |
        |         | lity/capability.initLastCap module=github.com/syndtr/gocapability                                |

gocapability seems to need //gomodjail:unconfined

@apostasie
Copy link
Contributor Author

https://github.com/containerd/nerdctl/actions/runs/14787855221/job/41521670427?pr=4180

TestRunSigProxy is consistently failing

gocapability seems to need //gomodjail:unconfined

Maybe...

I am reading their source now. Do not like seeing an init in there https://github.com/syndtr/gocapability/blob/master/capability/capability_linux.go#L32-L45 but then this lib is used everywhere so there is no changing that.

Curious why would that prevent the signal from being caught by the bash trap?

Anyhow, I think the priority one is the flock question so that we can debug on a more solid ground.

@apostasie
Copy link
Contributor Author

apostasie commented May 2, 2025

Why would we even need to actively check capabilities in that code path? 🤔

init should be banned.

@apostasie
Copy link
Contributor Author

Why would we even need to actively check capabilities in that code path? 🤔

init should be banned.

@AkihiroSuda this is new.

v2.0.4 we do not have this.

This got dragged in by cdi.

IMHO this is just wrong (well, especially the init part).

graph-main

@AkihiroSuda
Copy link
Member

AkihiroSuda commented May 2, 2025

Thanks, the warning seems legit, but why is the warning printed only on TestRunSigProxy on CI 🤔

EDIT: now it is printed every time, as #4170 (CDI) was merged after #4012 (gomodjail)

@apostasie
Copy link
Contributor Author

It is likely printed everywhere (where we hit one of the code paths above)
https://github.com/containerd/nerdctl/actions/runs/14787855221/job/41521670427?pr=4180#step:8:4964

@apostasie
Copy link
Contributor Author

Thanks, the warning seems legit, but why is the warning printed only on TestRunSigProxy on CI 🤔

EDIT: now it is printed every time, as #4170 (CDI) was merged after #4012 (gomodjail)

Yeah...

@AkihiroSuda
Copy link
Member

The gocapability warning is noisy, but probably irrelevant to the failure of the test.

The CI is green for the merge commit for #4170
8d7539a

@apostasie
Copy link
Contributor Author

I think it is a red herring.

Well, this thing is a big problem in itself - but I am not convinced it is responsible for the test failure, which is probably a different issue.

@apostasie
Copy link
Contributor Author

Cross posting a lot...
I am too tired. Logging off.
Good night Akihiro.

@apostasie
Copy link
Contributor Author

Morning there (or whatever time it is) :-)

I am going to disable signal related tests for gomodjail for now, so that we can merge this PR.

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 944dbe6 into containerd:main May 3, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants