Skip to content
Open
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
23 changes: 5 additions & 18 deletions crates/openshell-driver-kubernetes/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3851,12 +3851,9 @@ fn sandbox_template_to_k8s_with_validated_config(
apply_pod_driver_config(&mut spec, &driver_config.pod);

// Per-sandbox portable intent overrides the cluster-wide default. This
// driver owns the Kubernetes-specific `hostUsers` translation. Accept the
// former platform_config encoding during rolling upgrades from gateways
// that predate the typed field.
// driver owns the Kubernetes-specific `hostUsers` translation.
let use_user_namespaces = template
.user_namespaces
.or_else(|| platform_config_bool(template, "host_users").map(|host_users| !host_users))
.unwrap_or(params.enable_user_namespaces);

if use_user_namespaces {
Expand Down Expand Up @@ -4469,15 +4466,6 @@ fn platform_config_string(template: &SandboxTemplate, key: &str) -> Option<Strin
}
}

fn platform_config_bool(template: &SandboxTemplate, key: &str) -> Option<bool> {
let config = template.platform_config.as_ref()?;
let value = config.fields.get(key)?;
match value.kind.as_ref() {
Some(prost_types::value::Kind::BoolValue(value)) => Some(*value),
_ => None,
}
}

/// Extract a nested Struct value from the template's `platform_config`,
/// converting it to `serde_json::Value`.
fn platform_config_struct(template: &SandboxTemplate, key: &str) -> Option<serde_json::Value> {
Expand Down Expand Up @@ -7728,7 +7716,7 @@ mod tests {
}

#[test]
fn user_namespaces_accepts_legacy_host_users_encoding() {
fn user_namespaces_ignores_legacy_host_users_encoding() {
let template = SandboxTemplate {
platform_config: Some(Struct {
fields: std::iter::once((
Expand All @@ -7751,10 +7739,9 @@ mod tests {
&params,
);

assert_eq!(
pod_template["spec"]["hostUsers"],
serde_json::json!(false),
"legacy host_users: false must still enable user namespaces"
assert!(
pod_template["spec"]["hostUsers"].is_null(),
"legacy host_users must not enable user namespaces"
);
}

Expand Down
Loading