Skip to content

Improve AWS runner attribution and watchdog coverage - #3851

Open
shi-eric wants to merge 1 commit into
newton-physics:mainfrom
shi-eric:ershi/update-aws-tags
Open

Improve AWS runner attribution and watchdog coverage#3851
shi-eric wants to merge 1 commit into
newton-physics:mainfrom
shi-eric:ershi/update-aws-tags

Conversation

@shi-eric

@shi-eric shi-eric commented Aug 8, 2026

Copy link
Copy Markdown
Member

Description

EC2 instances and attached EBS volumes created by Newton's AWS runner workflows now receive launch-time tags for the repository, normalized trigger category, workload, GitHub run ID, and run attempt. The repository tag uses ${{ github.repository }} so authorized fork runs remain attributable.

Caller workflows explicitly classify pull requests, merge queue runs, pushes, scheduled nightly runs, and manual dispatches. This makes AWS Console spend easier to map back to the CI activity that created it.

This PR also checks the existing overdue-runner watchdog CloudFormation template into scripts/ci/aws with deployment instructions. The watchdog scans all running instances with Newton's ownership tag instead of filtering on a single repository, closing the monitoring gap for temporary development runs from authorized forks. Instances created before the new attribution tags are still reported with unknown metadata rather than ignored.

The watchdog continues to calculate runner age from the EC2 launch time, so this change does not add an expiration tag. It implements the attribution portion of the Newton AWS EC2 runner mitigation plan without changing the runner provisioning or cleanup mechanism.

This is a CI infrastructure change and does not affect Newton's public API.

Checklist

  • New or existing tests cover these changes
  • The documentation is up to date with these changes
  • No changelog fragment is needed because this change affects CI infrastructure only

Test plan

  • uv run --no-project -m unittest discover -s scripts/ci/tests -v
  • uvx pre-commit run -a
  • Ran the AWS GPU workflow from shi-eric/newton and confirmed that the EC2 instance and attached EBS volume received the expected dynamic repository, trigger, workload, run ID, and run-attempt tags before cleanup: https://github.com/shi-eric/newton/actions/runs/31274733298
  • Validated and deployed the committed CloudFormation template to the existing watchdog stack, invoked the Lambda function, and confirmed the stack was UPDATE_COMPLETE, drift status was IN_SYNC, and the alarm was OK

The local tests cover workflow configuration contracts and watchdog logic. They do not call AWS; the fork workflow run and watchdog deployment provide the live AWS verification.

Summary by CodeRabbit

  • New Features
    • Added automated monitoring for overdue CI runners, including scheduled checks, metrics, alarms, and notifications.
    • Added normalized workflow trigger categories and detailed attribution metadata to CI runner resources for improved tracking.
  • Documentation
    • Added AWS CI infrastructure setup, validation, deployment, and rollback guidance.
  • Tests
    • Added validation for workflow metadata, trigger configuration, runner tagging, and watchdog behavior.

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

AWS CI workflows now propagate normalized trigger categories and run metadata to EC2 runner tags. A CloudFormation watchdog scans overdue runners, publishes metrics, and sends alerts. Documentation and tests cover deployment procedures and workflow contracts.

Changes

AWS CI observability

Layer / File(s) Summary
Workflow inputs and resource tags
.github/workflows/aws_gpu_benchmarks.yml, .github/workflows/aws_gpu_tests.yml, .github/workflows/minimum_deps_tests.yml, .github/workflows/mujoco_warp_tests.yml, .github/workflows/warp_nightly_tests.yml
Reusable workflows accept trigger-category. EC2 runners receive trigger, workload, run ID, and run attempt tags.
Trigger category propagation and contract tests
.github/workflows/merge_queue_aws_gpu.yml, .github/workflows/pr_target_aws_gpu_benchmarks.yml, .github/workflows/pr_target_aws_gpu_tests.yml, .github/workflows/push_aws_gpu.yml, .github/workflows/scheduled_nightly.yml, scripts/ci/tests/test_runner_workflow_contract.py
Caller workflows pass normalized categories for merge queue, pull request, push, and scheduled nightly runs. Contract tests validate inputs, tags, JSON encoding, and dispatch arguments.
Overdue runner watchdog
scripts/ci/aws/overdue-newton-github-runner-watchdog.yaml, scripts/ci/aws/README.md, scripts/ci/tests/test_watchdog_logic.py
Adds the scheduled Lambda watchdog, CloudWatch alarm, IAM resources, deployment procedures, rollback guidance, and unit tests for runner discovery and attribution fallback values.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant EventBridge
  participant WatchdogLambda
  participant EC2
  participant CloudWatch
  participant SNS
  EventBridge->>WatchdogLambda: invoke every four hours
  WatchdogLambda->>EC2: scan running attributed runners
  EC2-->>WatchdogLambda: return instance tags and metadata
  WatchdogLambda->>CloudWatch: publish overdue-runner metrics
  CloudWatch->>SNS: send alarm or recovery notification
Loading

Possibly related PRs

Suggested reviewers: jcarius-nv

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the PR's main changes to AWS runner attribution and watchdog coverage.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@shi-eric
shi-eric requested a review from jcarius-nv August 8, 2026 20:34
@shi-eric shi-eric self-assigned this Aug 8, 2026
@shi-eric shi-eric added the automation Issues related to ci/cd and automation in general label Aug 8, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/mujoco_warp_tests.yml:
- Around line 94-98: JSON-encode the free-form trigger-category input before
constructing the aws-resource-tags JSON, then use the encoded value for the
Newton-Trigger tag in both .github/workflows/mujoco_warp_tests.yml lines 94-98
and .github/workflows/warp_nightly_tests.yml lines 94-98. Apply the same
workflow-level encoding approach at both sites so characters such as quotes
cannot break the tag array.

In `@scripts/ci/aws/overdue-newton-github-runner-watchdog.yaml`:
- Around line 212-229: The CloudFormation deployment procedure must seed the
watchdog metric before treating the alarm as operational. In
scripts/ci/aws/overdue-newton-github-runner-watchdog.yaml lines 212-229, update
the alarm configuration or stack outputs as needed to support waiting for the
alarm to leave INSUFFICIENT_DATA, then publish a successful OverdueRunnerCount=0
datapoint using the Newton/GitHubRunnerWatchdog dimension before accepting the
result. Document this exact post-stack procedure in scripts/ci/aws/README.md
lines 99-104.

In `@scripts/ci/tests/test_watchdog_logic.py`:
- Around line 64-65: Add a narrow, documented Ruff suppression for S102 directly
on the intentional exec call in the test setup that compiles TEMPLATE; keep the
suppression scoped to this test-only execution and do not alter global lint
configuration.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 363800ce-926f-43c3-b171-7e688efba1cb

📥 Commits

Reviewing files that changed from the base of the PR and between 71fe5e6 and 719df10.

📒 Files selected for processing (14)
  • .github/workflows/aws_gpu_benchmarks.yml
  • .github/workflows/aws_gpu_tests.yml
  • .github/workflows/merge_queue_aws_gpu.yml
  • .github/workflows/minimum_deps_tests.yml
  • .github/workflows/mujoco_warp_tests.yml
  • .github/workflows/pr_target_aws_gpu_benchmarks.yml
  • .github/workflows/pr_target_aws_gpu_tests.yml
  • .github/workflows/push_aws_gpu.yml
  • .github/workflows/scheduled_nightly.yml
  • .github/workflows/warp_nightly_tests.yml
  • scripts/ci/aws/README.md
  • scripts/ci/aws/overdue-newton-github-runner-watchdog.yaml
  • scripts/ci/tests/test_runner_workflow_contract.py
  • scripts/ci/tests/test_watchdog_logic.py

Comment thread .github/workflows/mujoco_warp_tests.yml
Comment thread scripts/ci/aws/overdue-newton-github-runner-watchdog.yaml
Comment thread scripts/ci/tests/test_watchdog_logic.py
@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

EC2 runners carried only ownership and repository tags. This made AWS
spend difficult to map to the workflow run and workload that created it.
Add stable trigger and workload categories plus run identifiers at
instance and volume creation time.

Version the overdue-runner watchdog beside the CI code and broaden its
ownership-tag scan to include permitted development runs from forks.
Keep alert routing deployment-specific and require change-set review for
live updates.
@shi-eric
shi-eric force-pushed the ershi/update-aws-tags branch from 719df10 to 01d8b74 Compare August 8, 2026 21:42
@shi-eric
shi-eric marked this pull request as ready for review August 8, 2026 21:46
@shi-eric
shi-eric requested a review from a team as a code owner August 8, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation Issues related to ci/cd and automation in general

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant