runtime-rs: Show config files attempted on config load failure

PR #8483 changed the location of the rust runtime config files to
`/etc/kata-containers/runtime-rs/`. However, if you haven't updated your
system to create that directory, attempting to create a container using
the rust runtime was giving the following cryptic message
(formatted for easier reading):

```
failed to handler message try init runtime instance

Caused by:
    0: load config
    1: load toml config
    2: entity not found
```

Now, the message is as follows (again, reformatted for easier reading):

```
failed to handle message try init runtime instance

Caused by:
    0: load config
    1: load TOML config failed (tried [
        \"/etc/kata-containers/runtime-rs/configuration.toml\",
        \"/usr/share/defaults/kata-containers/runtime-rs/configuration.toml\",
        \"/opt/kata/share/defaults/kata-containers/runtime-rs/configuration.toml\"
    ])
```

Fixes: #8557.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt
2023-12-04 14:14:10 +00:00
parent 45c0364d4c
commit d627893975
2 changed files with 12 additions and 2 deletions

View File

@@ -489,8 +489,10 @@ fn load_config(spec: &oci::Spec, option: &Option<Vec<u8>>) -> Result<TomlConfig>
let logger = slog::Logger::clone(&slog_scope::logger());
info!(logger, "get config path {:?}", &config_path);
let (mut toml_config, _) =
TomlConfig::load_from_file(&config_path).context("load toml config")?;
let (mut toml_config, _) = TomlConfig::load_from_file(&config_path).context(format!(
"load TOML config failed (tried {:?})",
TomlConfig::get_default_config_file_list()
))?;
annotation.update_config_by_annotation(&mut toml_config)?;
update_agent_kernel_params(&mut toml_config)?;