Skip to content
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

libct/init_linux: retry chdir to fix EACCES (regression in rc93) #2894

Merged
merged 1 commit into from
Apr 7, 2021

Conversation

haircommander
Copy link
Contributor

Alas, the EPERM on chdir saga continues...

Unfortunately, the there were two releases between when 5e0e67d was released
and when the workaround #2712 was added.

Between this, folks started relying on the ability to have a workdir that the container user doesn't have access to.

Since this case was previously valid, we should continue support for it.

Now, we retry the chdir:
Once at the top of the function (to catch cases where the runc user has access, but container user does not)
and once after we setup user (to catch cases where the container user has access, and the runc user does not)

Add a test case for this as well.

Signed-off-by: Peter Hunt [email protected]

@haircommander haircommander force-pushed the chdir-fix-2 branch 2 times, most recently from 84558ba to d4c3bbf Compare April 6, 2021 18:19
@kolyshkin kolyshkin added this to the 1.0.0-rc94 milestone Apr 6, 2021
kolyshkin
kolyshkin previously approved these changes Apr 6, 2021
Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

LGTM

libcontainer/init_linux.go Outdated Show resolved Hide resolved
@kolyshkin kolyshkin self-requested a review April 6, 2021 18:32
@kolyshkin kolyshkin dismissed their stale review April 6, 2021 18:33

CI is failing

@haircommander
Copy link
Contributor Author

I think IsPermission fixes the failures

Alas, the EPERM on chdir saga continues...

Unfortunately, the there were two releases between when opencontainers@5e0e67d  was released
and when the workaround opencontainers#2712 was added.

Between this, folks started relying on the ability to have a workdir that the container user doesn't have access to.

Since this case was previously valid, we should continue support for it.

Now, we retry the chdir:
Once at the top of the function (to catch cases where the runc user has access, but container user does not)
and once after we setup user (to catch cases where the container user has access, and the runc user does not)

Add a test case for this as well.

Signed-off-by: Peter Hunt <[email protected]>
@kolyshkin
Copy link
Contributor

Ah, the EPERM check fails because the error returned by chdir is EACCES. As per chdir(2) man page:

   EACCES Search permission is denied for one of the components of path.  (See also path_resolution(7).)

and there's no EPERM in the list of errors returned by chdir.

So we could use case EACCES: but I think using os.IsPermission is actually a bit cleaner and more readable.

@kolyshkin
Copy link
Contributor

CI on CentOS hit a snag; restarted.

@kolyshkin kolyshkin changed the title libct/init_linux: retry chdir to fix EPERM libct/init_linux: retry chdir to fix EPERM (regression in rc93) Apr 6, 2021
case err == nil:
doChdir = false
case os.IsPermission(err):
// If we hit an EPERM, we should attempt again after setting up user.
Copy link
Contributor

Choose a reason for hiding this comment

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

this needs to mention EACCES not EPERM.

Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

LGTM except for a nit in a comment (not that important)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants