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

fix/feat: add duplicate envs without instance suffix #710

Merged
Merged
Changes from 1 commit
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
30 changes: 21 additions & 9 deletions agent/src/plugin_manager/device_plugin_instance_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,16 +422,28 @@ fn cdi_device_to_car(device: &cdi::Device) -> ContainerAllocateResponse {
.last()
.unwrap_or_default()
.to_uppercase();

// Mount all device environment variables with and without a suffix of the
// instance hash. Envs without a suffix could be undeterministically
// overridden by other allocated instances discovered by the same Discovery
// Handler. Unsuffixed envs should only be referrenced if they are
// additional Configuration.broker_properties or if only one instance of a
// DH is allocated to the broker.
let envs = device
.container_edits
.env
.iter()
.map(|e| match e.split_once('=') {
Some((k, v)) => (k.to_string(), v.to_string()),
None => (e.to_string(), "".to_string()),
});

let suffixed_envs = envs
.clone()
.map(|(k, v)| (format!("{}_{}", k, instance_hash), v));

ContainerAllocateResponse {
envs: device
.container_edits
.env
.iter()
.map(|e| match e.split_once('=') {
Some((k, v)) => (format!("{}_{}", k, instance_hash), v.to_string()),
None => (format!("{}_{}", e, instance_hash), "".to_string()),
})
.collect(),
envs: envs.chain(suffixed_envs).collect(),
mounts: device
.container_edits
.mounts
Expand Down
Loading