[e2e-framework] Track SSH activity on create-vm EC2 instances #57437
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 496 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.371
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #57437"
general
weight: 0.35
louis-cqrl
What does this PR do?
EC2 VMs created with
dda inv aws.create-vmoragent-health-demokeep alast-activityAWS tag up to date while they are used over SSH, on Linux and Windows.Linux (script appended to the user data,
components/os/scripts/track-ssh-activity.sh):pam_exechook (optional, runs in the background so logins are never delayed)CreateTagscall is signed with SigV4 using onlycurlandopenssl, as the AWS CLI is not available on every AMIWindows (
components/os/scripts/track-ssh-activity.ps1):- when sshd writes to its
OpenSSH/Operationalevent log, so within seconds of an SSH connection (there is no PAM on Windows)- every 5 minutes, for long sessions
setup-ssh.ps1+ public key) already uses 9.4–10 KB of EC2's 16 KB limit, and embedding the script would go over it with RSA keysCreateTagscall is signed with SigV4 in plain .NET, so it does not depend on AWS Tools for PowerShell being on the AMIEvery step is best effort and can't fail the user data, a login or the stack.
It is gated by a new
ddinfra:aws/trackSSHActivitysetting, disabled by default and enabled by manual test scripts. Test VMs created in CI do not outlive the cleaner's threshold, so they don't need it.Motivation
test-infra-cleaner uses only the creation date to decide which EC2 instances to delete. Currently it deletes any VM older than 24h. This creates friction as contributors might lose their temporary setup, and need to recreate a new instance daily. With this tag, the cleaner can keep instances that were used recently.
Related PRs:
last-activity): https://github.com/ddoghq/test-infra-cleaner/pull/138ec2InstanceRoleto set the tag on itself only):https://github.com/DataDog/cloud-inventory/pull/72203Describe how you validated your changes
Validated with
dda inv aws.create-vm:| Scenario | Ubuntu | Windows |
|---|---|---|
| Tracking installed | user data: script,
pam_execline in/etc/pam.d/sshd, systemd timer | over SSH: script inC:/ProgramData/dd-e2e/, SYSTEM scheduled task with a time trigger and anOpenSSH/Operationalevent trigger || Tag set on SSH connect | PAM hook: login at 10:50:59Z → tag
10:50:59Z| event trigger: one-shotssh … hostnameat 13:11:29Z → tag13:11:34Z; 20 s session at 13:12:58Z → tag13:13:01Z|| Tag refreshed during a long session | timer run at 10:55:58Z with one session held open → tag
10:55:58Z| task run at 11:16:38Z with one session held open → tag11:16:40Z|| No update without an SSH session | timer run at 10:50:41Z before any user session → no tag | task run at 11:21:38Z with no session (
LastTaskResult 0) → tag unchanged || 1 min throttle | not tested on the VM (covered by the container test) | run at 13:09:59Z, 22 s after the last update → tag unchanged |
Additional Notes
aws.create-vmneeds an RSA key pair: EC2 does not support ED25519 key pairs with Windows AMIs (not changed by this PR).