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

Assorted CLI nitpicks #3374

Merged
merged 6 commits into from
Mar 9, 2022
Merged

Assorted CLI nitpicks #3374

merged 6 commits into from
Mar 9, 2022

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Feb 12, 2022

This is mostly some minor refactoring, making things cleaner.

The only significant change is runc --root non-existent-dir list now reports an error for non-existent root directory. The error is not reported in case a default root is used.

This is a preparation for #3373.

@kolyshkin kolyshkin mentioned this pull request Feb 14, 2022
7 tasks
@kolyshkin kolyshkin added the kind/refactor refactoring label Feb 16, 2022
@kolyshkin
Copy link
Contributor Author

kolyshkin commented Feb 17, 2022

I have two three more PRs that depend on changes in this one, and the changes here are rather trivial and easy to review; PTAL @opencontainers/runc-maintainers 🙏🏻

The value of root is already an absolute path since commit
ede8a86, so it does not make sense to call filepath.Abs()
again.

Signed-off-by: Kir Kolyshkin <[email protected]>
There is a mix of styles when handling CLI commands. In most cases we
return an error, which is handled from app.Run in main.go (it calls
fatal if there is an error).

In a few cases, though, we call fatal(err) from random places.

Let's be consistent and always return an error. The only exception is
runc exec, which needs to exit with a particular exit code.

Signed-off-by: Kir Kolyshkin <[email protected]>
1. Variable xdgRuntimeDir is only checked to be non-empty. Change it to
   a boolean.

2. Refactor so that os.Getenv is not called twice.

Signed-off-by: Kir Kolyshkin <[email protected]>
1. In case --root option is not provided, do nothing.

2. Instead of checking if root value is empty string, check it after
   filepath.Abs, and reject "/". Improve docstring while at it.

Signed-off-by: Kir Kolyshkin <[email protected]>
It is questionable whether runc list should return an empty list of
containers when non-existent --root is specified or not.

The current behavior is the directory is always created and then the
empty list of container is shown.

To my mind, specifying a non-existent root is an error and should be
reported as such. This is what this patch does.

For backward compatibility, if --root is not set (i.e. a default is
used), ENOENT is not reported.

Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
@kolyshkin
Copy link
Contributor Author

centos 8 CI failure is a flake; working on a fix in #3392

@kolyshkin
Copy link
Contributor Author

I have two three more PRs that depend on changes in this one, and the changes here are rather trivial and easy to review; PTAL @opencontainers/runc-maintainers @AkihiroSuda @thaJeztah @cyphar 🙏🏻

@AkihiroSuda AkihiroSuda merged commit 7fd8b57 into opencontainers:main Mar 9, 2022
@cyphar cyphar mentioned this pull request Mar 14, 2024
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