← Back to Pull requests

ci(uat): clear an orphaned flow-logs log group before AWS bringup #4011

Closed
unknown closed this pull request without merging on Nov 23, 2026 22:28 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 20:26 UTC
Author

Summary

Before Bringup, the AWS UAT workflow now deletes an orphaned VPC flow-logs log group left by an earlier attempt of the same run, so a re-run no longer fails minutes into Bringup on ResourceAlreadyExistsException.

Motivation / Context

A re-run attempt reuses the run ID, so DEPLOYMENT_ID and every name derived from it repeat. When the previous attempt was destroyed, a flow-log delivery still in flight recreated /aws/vpc/<DEPLOYMENT_ID>-flow-logs behind Terraform's delete, unmanaged and with no flow log attached. The re-run's Bringup then failed creating the same group, after about 18 minutes and with the capacity reservation held.

Fixes: #3006

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

  • New feature (non-breaking change that adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to change)

  • Documentation update

  • Refactoring (no functional changes)

  • Build/CI/tooling
  • Component(s) Affected

  • CLI (cmd/aicr, pkg/cli)

  • API server (cmd/aicrd, pkg/server)

  • Recipe engine / data (pkg/recipe)

  • Bundler and deployers (pkg/bundler, pkg/component)

  • Collectors / snapshotter (pkg/collector, pkg/snapshotter)

  • Validator (pkg/validator)

  • Core libraries (pkg/errors, pkg/k8s)

  • Docs/examples (docs/, examples/)

  • Other: .github/workflows/uat-aws.yaml, tests/uat/lib, infra/uat-aws-account/README.md
  • Implementation Notes

  • The step. "Clear an orphaned flow-logs log group" runs right before Bringup Infra, under the same condition (skipped for daytime-down). It looks up the exact group name; if the group exists and no flow log uses it, it deletes it.

  • A group still in use is left alone, not a stop. The issue suggested failing the run when a flow log still uses the group. That can only be the previous attempt of the same run, whose deployment Terraform's state still holds: on main, the re-run's Bringup converges on that state and teardown removes it at the end. Stopping before Bringup would also skip teardown (it is gated on Bringup having run) and leak that deployment. So the step never deletes a group in use, which is what the issue's fail-closed rule protects, and otherwise leaves that case exactly as it is today, with a notice.

  • Matching. Flow logs are matched client-side by group name or by destination ARN (with or without a : suffix), because a flow log created with a destination ARN may not report a group name, which a server-side log-group-name filter would miss. A failed or unreadable lookup stops the run without deleting anything.

  • Name. The group name, /aws/vpc/<DEPLOYMENT_ID>-flow-logs, comes from the actuator's Terraform error quoted in the issue; the actuator's source is not in this repo. A different name would make the step a no-op, not delete anything else.

  • Not in this PR. The issue's optional extras: a re-check on the destroy path, and a janitor sweep of /aws/vpc/aicr-uat- groups (the UAT janitor is #3669).

  • infra/uat-aws-account/README.md names the new log-group calls under CloudWatch Logs; the role already grants them.
  • Testing

    make qualify
    bash tests/uat/lib/aws-flow-logs-preflight_test.sh
    

  • make qualify: passes, including the new shell test.

  • tests/uat/lib/aws-flow-logs-preflight_test.sh (run by make test-shell) extracts the step with yq and runs it against a stub aws. It checks that the step sits right before Bringup Infra under the same condition, and 11 cases: no group; a longer name sharing the prefix; an orphan; flow logs of other groups; a group in use by name, by destination ARN, and by a :* ARN; failed log-group and flow-log lookups; an unreadable flow-log response; a failed delete. It fails rather than skips when yq or jq is missing.

  • Mutations, each caught: exact match turned into a prefix match (for the group and for flow logs), the flow-log check removed, destination-ARN matching removed, pipefail removed, the flow-log lookup's failure swallowed, the step's condition inverted.

  • A live re-run is not reproducible on demand; the step reads and deletes only this run's own group.
  • Risk Assessment

  • Low — Isolated change, well-tested, easy to revert

  • Medium — Touches multiple components or has broader impact

  • High — Breaking change, affects critical paths, or complex rollout
  • Rollout notes: N/A. CI only.

    Checklist

  • Tests pass locally (make test with -race)

  • Linter passes (make lint)

  • I did not skip/disable tests to make CI green

  • I added/updated tests for new functionality

  • I updated docs if user-facing behavior changed

  • Changes follow existing patterns in the codebase

  • Commits are signed off and cryptographically signed (git commit -s -S) — GPG signing info
  • Diff: 623 lines (+467 / -156) across 7 files Reviewer: dims Review duration: 122m
    All Vouch review confidence checks passed
    Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 623 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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.385
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #4011"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.3% (MEDIUM) · Higher = larger blast radius
    50.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 19.9% · Safe to merge
    19.9%
    Repository