Skip to content

Commit

Permalink
fix: use more correct condition to skip generating hosts files
Browse files Browse the repository at this point in the history
After a fix a while ago, the condition was hard to understand - but we
should skip this block as long as there's no TLS config, which might
mean either being nil or having default values.

I found this while debugging #9594, but it doesn't change anything.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Oct 30, 2024
1 parent 62ec7ec commit b379506
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
10 changes: 4 additions & 6 deletions internal/pkg/containers/cri/containerd/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,19 +172,17 @@ func GenerateHosts(cfg config.Registries, basePath string) (*HostsConfig, error)
}

// process TLS config for non-mirrored endpoints (even if they were already processed)
for hostname, tlsConfig := range cfg.Config() {
for hostname, registryConfig := range cfg.Config() {
directoryName := hostDirectory(hostname)

if _, ok := config.Directories[directoryName]; ok {
// skip, already configured
continue
}

if tlsConfig.TLS() != nil {
if tlsConfig.TLS().CA() == nil && tlsConfig.TLS().ClientIdentity() == nil && !tlsConfig.TLS().InsecureSkipVerify() {
// skip, no specific config
continue
}
if registryConfig.TLS() == nil || (registryConfig.TLS().CA() == nil && registryConfig.TLS().ClientIdentity() == nil && !registryConfig.TLS().InsecureSkipVerify()) {
// skip, no specific config
continue
}

if hostname == "*" {
Expand Down
9 changes: 0 additions & 9 deletions internal/pkg/containers/cri/containerd/hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,6 @@ func TestGenerateHostsWithoutTLS(t *testing.T) {
},
},
},
"some.host_123_": {
Files: []*containerd.HostsFile{
{
Name: "hosts.toml",
Mode: 0o600,
Contents: []byte("[host]\n [host.'https://some.host:123']\n"),
},
},
},
"_default": {
Files: []*containerd.HostsFile{
{
Expand Down

0 comments on commit b379506

Please sign in to comment.