Skip to content

Fix nsenter working dir for child - #3385

Merged
AkihiroSuda merged 1 commit into
containerd:mainfrom
apostasie:dev-nsenter
Sep 1, 2024
Merged

AkihiroSuda merged 1 commit into
containerd:mainfrom
apostasie:dev-nsenter

Conversation

@apostasie

@apostasie apostasie commented Aug 31, 2024 •

Copy link
Copy Markdown
Contributor

Currently, we are losing the working directory after we nsenter in some circumstances.

It is not entirely clear to me why.

This is manifest in testing (for example TestRunVolumeRelativePath) if you try to change the Dir of the icmd command to a newly created temp directory, nerdctl will then error when trying to mount the relative path inside

absPath, err := filepath.Abs(source)
(as Getwd cannot be retrieved).

It is not clear to me either if that would be a bug in nsenter (as I would expect -w to still be used as a default?).

Note that @fahedouch clearly had the right intuition as they suggested to change to -W in (related) PR: #3329 (comment)

This PR here was triggered by the ongoing refactoring of the cmd package, as one of the incidental changes required for tests to pass after the refactoring.

@apostasie apostasie mentioned this pull request Aug 31, 2024
@apostasie

Copy link
Copy Markdown
Contributor Author

GEEEZ I hate nsenter.

Turns out older versions do not have -W.

@apostasie

Copy link
Copy Markdown
Contributor Author

@AkihiroSuda @fahedouch

This is the last straw with nsenter...

Can we just replace with re-exec? Any reason I should know of to be concerned about doing that?

@AkihiroSuda

Copy link
Copy Markdown
Member

Can we just replace with re-exec?

Yes

Any reason I should know of to be concerned about doing that?

The complexity can be a concern.
A similar pattern can be found in https://github.com/rootless-containers/rootlesskit/blob/v2.3.1/cmd/rootlesskit/main.go#L45-L52

@apostasie apostasie changed the title [WIP] Fix nsenter working dir for child Fix nsenter working dir for child Aug 31, 2024
@apostasie
apostasie marked this pull request as ready for review August 31, 2024 20:57
@apostasie

apostasie commented Aug 31, 2024 •

Copy link
Copy Markdown
Contributor Author

Ok.
Cooling down a bit.
Will look seriously into re-exec - just not right now.

This PR here does fix my problem, and it is ready to go - CI is green.

@AkihiroSuda PTAL at your convenience.

(note that I am not completely sure what's going on inside nsenter - but fact is, that does fix the issue)

@AkihiroSuda AkihiroSuda left a comment

Copy link
Copy Markdown
Member

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 286b024 into containerd:main Sep 1, 2024
@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Sep 1, 2024
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