test(aws): harden the phase 7 live test; record the update probe
The guard paginates Auto Scaling groups and treats a failed read as not yet gone; the test asserts exactly one live task after a cold start, the sandbox off in the task's settings and bwrap failing (E8). README: updating a group to an unsupported template version is denied by the launch check (live probe); run 6 after the review fixes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
10f473f3da
commit
374fb5a35d
2 files changed
+32
-3
No files matched your search
@@ -1986,13 +1986,22 @@ mod environment {
|
||||
}
|
||||
// Groups (force: terminates their instances, ignores protection).
|
||||
let mut groups: Vec<String> = probe_groups.to_vec();
|
||||
if let Ok(out) = asg.describe_auto_scaling_groups().send().await {
|
||||
let mut next = None;
|
||||
loop {
|
||||
let Ok(out) = asg.describe_auto_scaling_groups().set_next_token(next.take()).send().await else {
|
||||
eprintln!("cleanup: WARNING: could not list Auto Scaling groups; only the known ones are deleted");
|
||||
break;
|
||||
};
|
||||
for g in out.auto_scaling_groups() {
|
||||
let n = g.auto_scaling_group_name().unwrap_or_default();
|
||||
if n.starts_with(&prefix) && !groups.iter().any(|x| x == n) {
|
||||
groups.push(n.to_string());
|
||||
}
|
||||
}
|
||||
next = out.next_token().map(str::to_string);
|
||||
if next.is_none() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for g in &groups {
|
||||
match asg.delete_auto_scaling_group().auto_scaling_group_name(g).force_delete(true).send().await {
|
||||
@@ -2007,13 +2016,14 @@ mod environment {
|
||||
}
|
||||
if !groups.is_empty() {
|
||||
for _ in 0..60 {
|
||||
// A failed read is "not yet gone", never "gone".
|
||||
let left = asg
|
||||
.describe_auto_scaling_groups()
|
||||
.set_auto_scaling_group_names(Some(groups.clone()))
|
||||
.send()
|
||||
.await
|
||||
.map(|o| o.auto_scaling_groups().len())
|
||||
.unwrap_or(0);
|
||||
.unwrap_or(usize::MAX);
|
||||
if left == 0 {
|
||||
break;
|
||||
}
|
||||
@@ -3528,10 +3538,23 @@ log_stream_prefix, project_secret_name, task_family};
|
||||
td.volumes().iter().map(|v| v.name().unwrap_or_default()).collect::<Vec<_>>()
|
||||
);
|
||||
|
||||
// The cold start's first (ECS Exec off) task is gone: exactly one
|
||||
// live task of the project on the user's cluster.
|
||||
let family = crate::aws::tofu_modules::task_family(&name, &okey, &id);
|
||||
let live = api.list_project_tasks(&rec.cluster_arn, &family).await.expect("list the project's tasks");
|
||||
eprintln!("RESULT live tasks on the user's cluster after start 1: {live:?}");
|
||||
assert_eq!(live, vec![task1.clone()], "exactly one live task");
|
||||
|
||||
// ── through the agent (ECS Exec port forward into the bridge task) ──
|
||||
let (out, code) = sh(&target, "claude", "echo hello-from-ec2; id").await;
|
||||
eprintln!("RESULT agent tunnel over ECS Exec into the bridge-mode task: exit {code}: {}", out.trim());
|
||||
assert_eq!(code, 0, "{out}");
|
||||
// E8: the sandbox is forced off in the task's settings.
|
||||
let (settings_json, code) = sh(&target, "claude", "printenv CLAUDE_CODE_SETTINGS_JSON").await;
|
||||
assert_eq!(code, 0, "no CLAUDE_CODE_SETTINGS_JSON");
|
||||
let v: serde_json::Value = serde_json::from_str(settings_json.trim()).expect("settings JSON");
|
||||
eprintln!("RESULT sandbox in the task's Claude Code settings: {}", v["sandbox"]);
|
||||
assert_eq!(v["sandbox"]["enabled"], false, "the sandbox is off on EC2");
|
||||
let (mut docker_ok, mut vpn_ok, mut src_valid_mark, mut bwrap_ok) = (true, true, true, false);
|
||||
if !quick {
|
||||
let (out, code) = sh(&target, "claude", "ls -l /var/run/docker.sock; docker ps 2>&1; docker version --format '{{.Server.Version}}' 2>&1").await;
|
||||
@@ -3712,6 +3735,8 @@ log_stream_prefix, project_secret_name, task_family};
|
||||
);
|
||||
let _ = ws;
|
||||
assert!(docker_ok, "docker ps failed as claude");
|
||||
// E8, stable in every run: Docker's seccomp profile refuses it.
|
||||
assert!(quick || !bwrap_ok, "bwrap worked in the task: revisit sandbox_allowed (E8)");
|
||||
assert!(vpn_ok && src_valid_mark, "the VPN pieces are missing");
|
||||
});
|
||||
let body = async {
|
||||
|
||||
+5
-1
@@ -584,6 +584,10 @@ and what is still open:
|
||||
(`ForAllValues` on the key once present, and the launch check).
|
||||
- ✓ **Instance types in templates.** The admin *can* create a template version naming
|
||||
`p5.48xlarge` (as expected, no condition key). A group pinned to it is denied by the launch check.
|
||||
- ✓ **Updating a group to an unsupported template version** runs the same launch check. In a
|
||||
probe (a throwaway role whose `ec2:RunInstances` allows only `m7i.large`), a group pinned to an
|
||||
`m7i.large` version updated to a `p5.48xlarge` version was refused ("You are not authorized to
|
||||
use launch template"). A size-only update (no template) passed.
|
||||
- ✓ **`aws:PrincipalTag/triple-c-user`** from a **role tag**: the tagged workspace role's session
|
||||
ran tasks on its own `--u-<tag>` cluster. `RunTask` on another `--u-<other>` cluster was denied,
|
||||
and the app shows the wrong-triple-c-user message. — An Identity Center attribute and an
|
||||
@@ -843,4 +847,4 @@ the guard runs.
|
||||
| Removal | ✓ `remove_aws_resources(…, true)` after stop 2: Ok (task, secret, access point) |
|
||||
| Re-apply without EC2, instance still up | ✓ `prepare_onboarding(…, None)` then the apply as the environment admin, 79 s: "0 added, 0 changed, 9 destroyed". The provider drained the group (the instance was InService, scale-in protected) and deleted it; after the apply no group, no live instance, capacity provider INACTIVE, cluster INACTIVE, launch template gone, instance profile and role gone, the user record Absent (as the workspace user). No denied action |
|
||||
| Offboard and destroy | ✓ as the environment admin: onboarding destroy (9) and environment destroy (15) with no denied action; the account admin's boundary destroy after |
|
||||
| Runs and cleanup | Five runs. Run 1: the `InstanceTypes` denial. Run 2: ECS Exec off on the cold start. Run 3: inspection over SSM (Session Manager core attached by hand to the instance role, boundary removed, both undone before the teardown), the ECS Exec diagnosis and the in-task checks. Run 4: everything to the scale-in, which the guard could not finish because the credentials expired. Run 5, `TRIPLEC_E2E_PHASE7_SHORT=1` (life cycle only): passed in 577 s. Every run's guard, or by hand with tofu destroy from the run's work folders once the credentials were renewed, left nothing: the final inventory of us-west-2 has no instance, group, launch template, Triple-C capacity provider, cluster, `triple-c*` role, policy or instance profile, `/triple-c` parameter, log group, ECR repository, file system, secret, task definition, VPC, state bucket or boundary. The environments' KMS keys are pending deletion (7 days). Spend: about 1.5 m7i.large instance-hours plus minutes of EFS and public IPv4, under $0.30 |
|
||||
| Runs and cleanup | Five runs. Run 1: the `InstanceTypes` denial. Run 2: ECS Exec off on the cold start. Run 3: inspection over SSM (Session Manager core attached by hand to the instance role, boundary removed, both undone before the teardown), the ECS Exec diagnosis and the in-task checks. Run 4: everything to the scale-in, which the guard could not finish because the credentials expired. Run 5, `TRIPLEC_E2E_PHASE7_SHORT=1` (life cycle only): passed in 577 s. Run 6 (short, after the review fixes: the rerun's launch through `find_or_run`, exactly one live task after the cold start, `sandbox.enabled = false` in the task's settings): passed in 583 s, with a cold start of 222 s and a warm one of 19 s. Every run's guard, or by hand with tofu destroy from the run's work folders once the credentials were renewed, left nothing: the final inventory of us-west-2 has no instance, group, launch template, Triple-C capacity provider, cluster, `triple-c*` role, policy or instance profile, `/triple-c` parameter, log group, ECR repository, file system, secret, task definition, VPC, state bucket or boundary. The environments' KMS keys are pending deletion (7 days). Spend: about 1.5 m7i.large instance-hours plus minutes of EFS and public IPv4, under $0.30 |
|
||||
Reference in new issue
Block a user