Merge pull request #8558 from jodh-intel/load-config-improvement

runtime-rs: Show config files attempted on config load failure
This commit is contained in:
James O. D. Hunt 2023-12-05 11:48:42 +00:00 committed by GitHub
commit d9daadf15c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

View File

@ -216,6 +216,14 @@ impl TomlConfig {
Err(io::Error::from(io::ErrorKind::NotFound))
}
/// Return a list of default config file paths.
pub fn get_default_config_file_list() -> Vec<PathBuf> {
default::DEFAULT_RUNTIME_CONFIGURATIONS
.iter()
.map(|s| PathBuf::from(*s))
.collect()
}
}
/// Validate the `path` matches one of the pattern in `patterns`.

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)?;

View File

@ -43,7 +43,7 @@ impl TaskService {
debug!(logger, "====> task service {:?}", &r);
let resp =
self.handler.handler_message(r).await.map_err(|err| {
ttrpc::Error::Others(format!("failed to handler message {:?}", err))
ttrpc::Error::Others(format!("failed to handle message {:?}", err))
})?;
debug!(logger, "<==== task service {:?}", &resp);
resp.try_into()