Skip to content

Error parsing hosts.toml without any host tree #10027

@brandond

Description

@brandond

Description

The docs on using hosts.toml indicate that fields for the registry host namespace can be specified in the root level:
https://github.com/containerd/containerd/blob/release/1.7/docs/hosts.md

For each registry host namespace directory in your registry config_path you may include a hosts.toml configuration file. The following root level toml fields apply to the registry host namespace:

However, containerd fails to parse the config file if only root fields are passed, for example:

root@systemd-node-1:/# cat /var/lib/rancher/k3s/agent/etc/containerd/certs.d/172-17-0-7.sslip.io/hosts.toml
ca = ["/usr/local/share/ca-certificates/registry.crt"]

When pulling from 172-17-0-7.sslip.io, containerd will log the following error:

time="2024-04-01T22:11:02.070675417Z" level=error msg="failed to decode hosts.toml" error="invalid `host` tree"

However, the following file with a stub host tree will work as intended:

root@systemd-node-1:/# cat /var/lib/rancher/k3s/agent/etc/containerd/certs.d/172-17-0-7.sslip.io/hosts.toml
ca = ["/usr/local/share/ca-certificates/registry.crt"]
[host]

Steps to reproduce the issue

  1. provide a hosts.toml as described above
  2. start containerd

Describe the results you received and expected

hosts.toml should be usable with no hosts tree, just root-level fields, as described in the docs.

What version of containerd are you using?

v1.7.11-k3s2

Any other relevant information

No response

Show configuration if it is related to CRI plugin.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions