Skip to content

Improve error detection when loading config#5027

Merged
mxpv merged 1 commit intocontainerd:masterfrom
kevpar:config-check
Feb 10, 2021
Merged

Improve error detection when loading config#5027
mxpv merged 1 commit intocontainerd:masterfrom
kevpar:config-check

Conversation

@kevpar
Copy link
Copy Markdown
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 [email protected]

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 <[email protected]>
@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Feb 10, 2021

Build succeeded.

Copy link
Copy Markdown
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.

4 participants