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

daemonconfig: only load mirrorsConfig for target host #401

Merged

Conversation

sctb512
Copy link
Member

@sctb512 sctb512 commented Mar 7, 2023

Now, we load all the mirrorsConfig from directory. And the mirrorsConfig is available to all hosts. This is not compatible with containerd's mirror configuration. This PR tries to solve this issue.


func loadHostDir(hostsDir string) ([]hostConfig, error) {
b, err := os.ReadFile(filepath.Join(hostsDir, "hosts.toml"))
if err != nil && !os.IsNotExist(err) {
Copy link
Member

Choose a reason for hiding this comment

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

"hosts.toml" does not exit, should we skip parsing hosts config and don't update nydusd's mirrors config

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we should avoid returning an error if the file does not exist. Fixed.

return nil, err
}

parsedMirrors, err := parseMirrorsConfig(hostConfig)
Copy link
Member

Choose a reason for hiding this comment

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

Forget to handle err==nil && hostDir="" ?

Copy link
Member

Choose a reason for hiding this comment

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

Please handle that host.toml or registry host namespace dir can't be found accross

Copy link
Member Author

@sctb512 sctb512 Mar 7, 2023

Choose a reason for hiding this comment

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

Forget to handle err==nil && hostDir="" ?

If err==nil && hostDir="", just return nil to skip loading the mirror configuration for this host.

hostDir, err := hostDirFromRoot(mirrorsConfigDir, registryHost)
if err != nil {
    return nil, err
}
if hostDir == "" {
    return mirrors, nil
}

Now, we load all the mirrorsConfig from directory. And the mirrorsConfig
is available to all hosts. This is not compatible with containerd's
mirror configuration. This PR tries to solve this issue.

Signed-off-by: Bin Tang <tangbin.bin@bytedance.com>
@sctb512 sctb512 force-pushed the load-mirrror-config-for-target-host branch 2 times, most recently from a49bf01 to 4bf294d Compare March 7, 2023 12:39
Signed-off-by: Bin Tang <tangbin.bin@bytedance.com>
@sctb512 sctb512 force-pushed the load-mirrror-config-for-target-host branch from 4bf294d to 8994651 Compare March 7, 2023 12:45
@changweige changweige merged commit a2c67a5 into containerd:main Mar 8, 2023
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

2 participants