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

chore(wasix): More logging improvements #4629

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions lib/wasix/src/runtime/package_loader/load_package_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ fn commands(

/// Given a [`webc::metadata::Command`], figure out which atom it uses and load
/// that atom into a [`BinaryPackageCommand`].
#[tracing::instrument(skip_all, fields(%package_id, %command_name))]
fn load_binary_command(
package_id: &PackageId,
command_name: &str,
Expand All @@ -122,7 +123,7 @@ fn load_binary_command(

let package = &containers[package_id];

let webc = match dependency {
let (webc, resolved_package_id) = match dependency {
Some(dep) => {
let ix = resolution
.graph
Expand All @@ -137,20 +138,38 @@ fn load_binary_command(
.with_context(|| format!("Unable to find the \"{dep}\" dependency for the \"{command_name}\" command in \"{package_id}\""))?;

let other_package = graph.node_weight(edge_reference.target()).unwrap();
&containers[&other_package.id]
let id = &other_package.id;

tracing::debug!(
dependency=%dep,
resolved_package_id=%id,
"command atom resolution: resolved dependency",
);
(&containers[id], id)
}
None => package,
None => (package, package_id),
};

let atom = webc.get_atom(&atom_name);

if atom.is_none() && cmd.annotations.is_empty() {
tracing::info!("applying legacy atom hack");
return Ok(legacy_atom_hack(webc, command_name, cmd));
}

let atom = atom.with_context(|| {

let available_atoms = webc.atoms().keys().map(|x| x.as_str()).collect::<Vec<_>>().join(",");

tracing::warn!(
%atom_name,
%resolved_package_id,
%available_atoms,
"invalid command: could not find atom in package",
);

format!(
"The '{command_name}' command uses the '{atom_name}' atom, but it isn't present in the package {package_id}"
"The '{command_name}' command uses the '{atom_name}' atom, but it isn't present in the package: {resolved_package_id})"
)
})?;

Expand Down
Loading