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

Improve error detection when loading config #5027

Merged
merged 1 commit into from Feb 10, 2021

Conversation

kevpar
Copy link
Member

@kevpar kevpar commented Feb 10, 2021

Previously we simply ignored any not found error when loading the
containerd config. This created unintuitive behavior:

  • If the user specified a path that didn't exist via --config, we would
    silently ignore the error.
  • If a config specified an import that didn't exist, we would silently
    ignore the error.

In either of these cases, it appears we would end up using a potentially
corrupted config, as it would contain any files that were merged into it
before the not found error was hit.

However, we can't just remove the check for !os.IsNotExist(err),
as we shouldn't throw an error when --config is not passed, but the
default config doesn't exist.

This change updates the logic to only attempt to load the config if
we know it exists, or the user passed --config.

Signed-off-by: Kevin Parsons kevpar@microsoft.com

Note: This is a change in behavior for config loading, but as far as I can tell the previous behavior could be dangerous and end up with an incomplete config. So I think it's worth fixing this, but looking for feedback. :)

Previously we simply ignored any not found error when loading the
containerd config. This created unintuitive behavior:

- If the user specified a path that didn't exist via --config, we would
  silently ignore the error.
- If a config specified an import that didn't exist, we would silently
  ignore the error.

In either of these cases, it appears we would end up using a potentially
corrupted config, as it would contain any files that were merged into it
before the not found error was hit.

However, we can't just remove the check for !os.IsNotExist(err),
as we shouldn't throw an error when --config is not passed, but the
default config doesn't exist.

This change updates the logic to only attempt to load the config if
we know it exists, or the user passed --config.

Signed-off-by: Kevin Parsons <kevpar@microsoft.com>
@theopenlab-ci
Copy link

theopenlab-ci bot commented Feb 10, 2021

Build succeeded.

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

reminds me I still have to do the same for docker/cli#1637 😅

@mxpv mxpv merged commit 88d9736 into containerd:master Feb 10, 2021
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.

None yet

4 participants