Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .agents/agents/gator/skills/gator-gate/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ Use `test:e2e` for changes that affect:

Use `test:e2e` for Helm, Agent Sandbox CRDs, Kubernetes scheduling, namespace, workspace mode, or controller behavior; it runs the Kubernetes, managed-workspace, and operator-workspace suites.

Add `test:e2e-kubernetes` for gateway high availability or Kubernetes Secrets and Vault credential driver storage. It runs only the HA and credential-driver suites, so apply it alongside `test:e2e` when other Kubernetes coverage is also needed.
Add `test:e2e-kubernetes` for gateway high availability, shared-supervisor HA, or Kubernetes Secrets and Vault credential driver storage. It runs the HA, shared-supervisor HA, and credential-driver suites, so apply it alongside `test:e2e` when other Kubernetes coverage is also needed.

Apply `test:windows` whenever a PR affects Windows support. This includes Windows or MSVC CI and `mise` tasks, Windows lock-file platform entries, the MXC driver, and `cfg(windows)` implementations or tests in otherwise cross-platform crates. Apply it alongside any applicable E2E label; it is not a substitute for runtime coverage.

Expand Down
15 changes: 14 additions & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test-group = "kubernetes-ha"
# they kill members or gateways, or scale the pool. Never run them at once.
# Test names, not binary(), for the reason above.
[[profile.e2e-kubernetes.overrides]]
filter = "test(/^(losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them|scaling_a_supervisor_pool_up_and_down_keeps_its_sandboxes_running|pool_sessions_follow_their_supervisors_gateway|shared_supervisor_acts_as_each_sandboxs_stable_spiffe_identity|supervisors_spread_evenly_across_gateways)$/)"
filter = "test(/^(losing_a_supervisor_pod_moves_its_sandboxes_without_restarting_them|exec_survives_an_abrupt_supervisor_kill|exec_survives_a_supervisor_rollout_restart|scaling_a_supervisor_pool_up_and_down_keeps_its_sandboxes_running|pool_sessions_follow_their_supervisors_gateway|shared_supervisor_acts_as_each_sandboxs_stable_spiffe_identity|supervisors_spread_evenly_across_gateways)$/)"
test-group = "kubernetes-shared-supervisor-pool"

# Scaling the pool runs two bounded Helm upgrades (up to 6 minutes each), waits
Expand All @@ -47,6 +47,19 @@ slow-timeout = { period = "60s", terminate-after = 20 }
filter = "test(/^pool_sessions_follow_their_supervisors_gateway$/)"
slow-timeout = { period = "60s", terminate-after = 20 }

# One abrupt kill, the bounded wait for another member to admit the route,
# and the settle and recovery exec rounds. Waited exec probes block for up to
# the CLI's wait budget each.
[[profile.e2e-kubernetes.overrides]]
filter = "test(/^exec_survives_an_abrupt_supervisor_kill$/)"
slow-timeout = { period = "60s", terminate-after = 15 }

# A rollout restart of both supervisor members plus a per-sandbox recovery
# bound, and the known-Stopped sandbox is still probed to its deadline.
[[profile.e2e-kubernetes.overrides]]
filter = "test(/^exec_survives_a_supervisor_rollout_restart$/)"
slow-timeout = { period = "60s", terminate-after = 20 }

[[profile.e2e-kubernetes.overrides]]
filter = "test(/^shared_supervisor_acts_as_each_sandboxs_stable_spiffe_identity$/)"
# Fresh acquisitions through every node and a replacement agent precede
Expand Down
38 changes: 37 additions & 1 deletion .github/workflows/branch-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
run_core_e2e: ${{ steps.labels.outputs.run_core_e2e }}
run_kubernetes_ha_e2e: ${{ steps.labels.outputs.run_kubernetes_ha_e2e }}
run_kubernetes_credential_drivers_e2e: ${{ steps.labels.outputs.run_kubernetes_credential_drivers_e2e }}
run_kubernetes_shared_supervisor_ha_e2e: ${{ steps.labels.outputs.run_kubernetes_shared_supervisor_ha_e2e }}
run_continuity_e2e: ${{ steps.labels.outputs.run_continuity_e2e }}
run_any_e2e: ${{ steps.labels.outputs.run_any_e2e }}
steps:
Expand All @@ -54,23 +55,28 @@ jobs:
run_core_e2e="$(jq -r 'index("test:e2e") != null' <<< "$LABELS_JSON")"
run_kubernetes_ha_e2e="$(jq -r 'index("test:e2e-kubernetes") != null' <<< "$LABELS_JSON")"
run_kubernetes_credential_drivers_e2e="$(jq -r 'index("test:e2e-kubernetes") != null' <<< "$LABELS_JSON")"
run_kubernetes_shared_supervisor_ha_e2e="$(jq -r 'index("test:e2e-kubernetes") != null' <<< "$LABELS_JSON")"
run_continuity_e2e="$(jq -r 'index("test:e2e:continuity") != null' <<< "$LABELS_JSON")"
;;
*)
sha="$DISPATCH_SHA"
run_core_e2e=true
run_kubernetes_ha_e2e=false
run_kubernetes_credential_drivers_e2e=false
run_kubernetes_shared_supervisor_ha_e2e=false
run_continuity_e2e=true
;;
esac
if [ "$should_run" = false ]; then
run_core_e2e=false
run_kubernetes_ha_e2e=false
run_kubernetes_credential_drivers_e2e=false
run_kubernetes_shared_supervisor_ha_e2e=false
run_continuity_e2e=false
fi
if [ "$run_core_e2e" = "true" ] || [ "$run_kubernetes_ha_e2e" = "true" ] || [ "$run_kubernetes_credential_drivers_e2e" = "true" ]; then
if [ "$run_core_e2e" = "true" ] || [ "$run_kubernetes_ha_e2e" = "true" ] \
|| [ "$run_kubernetes_credential_drivers_e2e" = "true" ] \
|| [ "$run_kubernetes_shared_supervisor_ha_e2e" = "true" ]; then
run_any_e2e=true
else
run_any_e2e=false
Expand All @@ -82,6 +88,7 @@ jobs:
echo "run_core_e2e=$run_core_e2e"
echo "run_kubernetes_ha_e2e=$run_kubernetes_ha_e2e"
echo "run_kubernetes_credential_drivers_e2e=$run_kubernetes_credential_drivers_e2e"
echo "run_kubernetes_shared_supervisor_ha_e2e=$run_kubernetes_shared_supervisor_ha_e2e"
echo "run_continuity_e2e=$run_continuity_e2e"
echo "run_any_e2e=$run_any_e2e"
} >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -799,6 +806,22 @@ jobs:
job-name: Kubernetes Credential Drivers E2E
e2e-task: e2e:kubernetes:credential-drivers

kubernetes-shared-supervisor-ha-e2e:
needs: [pr_metadata, build-binaries-linux, build-conformance, build-images]
if: needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_shared_supervisor_ha_e2e == 'true'
permissions:
actions: read
contents: read
packages: read
uses: ./.github/workflows/e2e-kubernetes-test.yml
with:
checkout-ref: ${{ needs.pr_metadata.outputs.sha }}
prebuilt-conformance: true
image-tag: ${{ needs.pr_metadata.outputs.sha }}
job-name: Kubernetes Shared Supervisor HA E2E
e2e-task: e2e:kubernetes:shared-supervisor-ha
external-postgres-secret: openshell-ha-pg

core-e2e-result:
name: Core E2E result
needs:
Expand Down Expand Up @@ -857,3 +880,16 @@ jobs:
- uses: ./.github/actions/check-job-results
with:
results: ${{ toJSON(needs) }}

kubernetes-shared-supervisor-ha-e2e-result:
name: Kubernetes Shared Supervisor HA E2E result
needs: [pr_metadata, build-binaries-macos, kubernetes-shared-supervisor-ha-e2e]
if: always() && needs.pr_metadata.outputs.should_run == 'true' && needs.pr_metadata.outputs.run_kubernetes_shared_supervisor_ha_e2e == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: ./.github/actions/check-job-results
with:
results: ${{ toJSON(needs) }}
80 changes: 80 additions & 0 deletions crates/openshell-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,19 @@ enum SandboxCommands {
#[arg(long)]
no_login_shell: bool,

/// Seconds to wait for the sandbox to become Ready before running the
/// command (default: 45, or `OPENSHELL_EXEC_WAIT_TIMEOUT`). Only a
/// sandbox in Provisioning or Starting waits, such as during a
/// supervisor takeover; every other phase fails immediately. `0`
/// disables the wait, like `--no-exec-wait`.
#[arg(long, value_name = "SECONDS", overrides_with = "no_exec_wait")]
exec_wait_timeout: Option<u32>,

/// Fail immediately when the sandbox is not Ready instead of waiting
/// for a supervisor takeover to finish.
#[arg(long, overrides_with = "exec_wait_timeout")]
no_exec_wait: bool,

/// Set a non-secret environment variable for the command.
/// Do not use this option for API keys, tokens, or other secrets; attach
/// a provider to the sandbox instead. Repeatable.
Expand Down Expand Up @@ -3885,6 +3898,8 @@ async fn run_async() -> Result<()> {
envs,
command,
no_login_shell,
exec_wait_timeout,
no_exec_wait,
} => {
let name =
resolve_sandbox_name(name.or(sandbox), &ctx.name, &cli.workspace)?;
Expand All @@ -3896,13 +3911,23 @@ async fn run_async() -> Result<()> {
} else {
None // auto-detect
};
// Resolve --exec-wait-timeout / --no-exec-wait. A
// zero budget disables the wait; the environment
// and the 45s default are applied in
// `run::sandbox_exec_grpc`.
let exec_wait_timeout_secs = if no_exec_wait {
Some(0)
} else {
exec_wait_timeout
};
let env_map = run::parse_env_pairs(&envs)?;
let exit_code = run::sandbox_exec_grpc(
endpoint,
&name,
&command,
workdir.as_deref(),
timeout,
exec_wait_timeout_secs,
tty_override,
&env_map,
no_login_shell,
Expand Down Expand Up @@ -6794,6 +6819,61 @@ mod tests {
);
}

fn exec_wait_flags(args: &[&str]) -> (Option<u32>, bool) {
let cli = Cli::try_parse_from(
["openshell", "sandbox", "exec", "test-sandbox"]
.into_iter()
.chain(args.iter().copied())
.chain(["--", "true"]),
)
.unwrap();
match cli.command {
Some(Commands::Sandbox {
command:
Some(SandboxCommands::Exec {
exec_wait_timeout,
no_exec_wait,
..
}),
..
}) => (exec_wait_timeout, no_exec_wait),
other => panic!("expected SandboxCommands::Exec, got: {other:?}"),
}
}

#[test]
fn sandbox_exec_wait_flags_parse() {
assert_eq!(
exec_wait_flags(&["--exec-wait-timeout", "5"]),
(Some(5), false)
);
assert_eq!(
exec_wait_flags(&["--exec-wait-timeout", "0"]),
(Some(0), false),
"a zero budget must parse: it disables the wait like --no-exec-wait"
);
assert_eq!(exec_wait_flags(&["--no-exec-wait"]), (None, true));
assert_eq!(
exec_wait_flags(&[]),
(None, false),
"neither flag leaves both unset so the 45s default applies"
);
}

#[test]
fn sandbox_exec_wait_flags_use_the_last_one_given() {
assert_eq!(
exec_wait_flags(&["--no-exec-wait", "--exec-wait-timeout", "5"]),
(Some(5), false),
"a later --exec-wait-timeout must clear an earlier --no-exec-wait"
);
assert_eq!(
exec_wait_flags(&["--exec-wait-timeout", "5", "--no-exec-wait"]),
(None, true),
"a later --no-exec-wait must clear an earlier --exec-wait-timeout"
);
}

#[test]
fn sandbox_create_restart_policy_rejects_unknown_value() {
assert!(
Expand Down
Loading
Loading