Skip to content

refactor(compute-providers): isolate EC2 provider handling - #5254

Open
edersonbrilhante wants to merge 10 commits into
mainfrom
refactor-ec2-provider-isolation
Open

refactor(compute-providers): isolate EC2 provider handling#5254
edersonbrilhante wants to merge 10 commits into
mainfrom
refactor-ec2-provider-isolation

Conversation

@edersonbrilhante

@edersonbrilhante edersonbrilhante commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Description

  • Move dynamic-label provider selection out of the webhook Lambda and into the compute-provider package.
  • Centralize dynamic-label enablement, provider targeting, queue fallback, logging, and dispatch-target construction in a provider-neutral selector.
  • Narrow DynamicLabelProvider to provider-owned validation through getViolations while preserving EC2 legacy-policy fallback.
  • Extract reusable AWS dynamic-label policy evaluation and resolve configured provider types strictly.
  • Add shared cross-provider label detection while deferring the MicroVM-specific queue-fallback scenario until that provider is added.

This PR is based directly on refactor-compute-providers. The Lambda MicroVM implementation remains out of scope for a separate PR.

Test Plan

  • Ran yarn install --immutable.
  • Ran the complete Lambda test suite: 49 test files and 788 tests passed.
  • Ran the directly affected selector, EC2 policy, provider-type, registry, template, webhook dispatch, pool, and scale-up suites: 9 test files and 164 tests passed.
  • Ran ESLint for libs/compute-providers, functions/webhook/src, and the affected control-plane tests.
  • Ran Prettier checks for the affected compute-provider, webhook, and control-plane test files.
  • Built the webhook Lambda bundle with ncc.
  • Confirmed git diff --check.

Related Issues

Related to #5252.

@edersonbrilhante
edersonbrilhante marked this pull request as ready for review August 7, 2026 20:54
@edersonbrilhante
edersonbrilhante requested a review from a team as a code owner August 7, 2026 20:54
@edersonbrilhante
edersonbrilhante force-pushed the refactor-ec2-provider-isolation branch from 1fc78c4 to b948b89 Compare August 7, 2026 21:42
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@edersonbrilhante
edersonbrilhante force-pushed the experimental-multi-runner-config-v2-20260805 branch from 0849752 to 2aa54f7 Compare August 12, 2026 21:58
@edersonbrilhante
edersonbrilhante requested a review from a team as a code owner August 12, 2026 21:58
@edersonbrilhante
edersonbrilhante force-pushed the refactor-ec2-provider-isolation branch 3 times, most recently from ecba660 to 6d3c6ba Compare August 12, 2026 22:38
@edersonbrilhante
edersonbrilhante changed the base branch from experimental-multi-runner-config-v2-20260805 to main August 12, 2026 22:38
@edersonbrilhante
edersonbrilhante force-pushed the refactor-ec2-provider-isolation branch 2 times, most recently from cefb18a to 6a5922a Compare August 12, 2026 22:57
@edersonbrilhante
edersonbrilhante changed the base branch from main to refactor-compute-providers August 12, 2026 22:58
@edersonbrilhante edersonbrilhante changed the title refactor(runner-providers): isolate EC2 provider handling refactor(compute-providers): isolate EC2 provider handling Aug 12, 2026
Base automatically changed from refactor-compute-providers to main August 14, 2026 10:46

Copilot AI 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.

Pull request overview

Moves dynamic-label routing from the webhook Lambda into the compute-provider abstraction while preserving EC2 policy behavior.

Changes:

  • Adds provider-neutral queue selection and label detection.
  • Narrows provider responsibility to policy violation reporting.
  • Extracts shared AWS policy evaluation and updates tests/callers.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lambdas/libs/compute-providers/webhook.ts Adds centralized provider queue selection.
lambdas/libs/compute-providers/webhook.test.ts Tests selector behavior.
lambdas/libs/compute-providers/templates/provider/webhook.ts Updates provider template contract.
lambdas/libs/compute-providers/templates/provider/provider.test.ts Updates template capability assertion.
lambdas/libs/compute-providers/registry.test.ts Updates registry capability assertion.
lambdas/libs/compute-providers/provider-types.ts Consolidates strict provider resolution.
lambdas/libs/compute-providers/provider-types.test.ts Tests provider resolution.
lambdas/libs/compute-providers/dynamic-labels.ts Detects labels targeting other providers.
lambdas/libs/compute-providers/dynamic-labels.test.ts Adds label-detection coverage.
lambdas/libs/compute-providers/contracts.ts Replaces queue selection with violation reporting.
lambdas/libs/compute-providers/aws/ec2/src/webhook/dynamic-labels.ts Adapts EC2 to the new contract.
lambdas/libs/compute-providers/aws/ec2/src/webhook/dynamic-labels.test.ts Tests EC2 violation reporting and fallback.
lambdas/libs/compute-providers/aws/ec2/src/webhook/dynamic-labels-policy.ts Delegates to shared AWS policy logic.
lambdas/libs/compute-providers/aws/dynamic-labels-policy.ts Adds reusable AWS policy evaluation.
lambdas/functions/webhook/src/runners/dispatch.ts Uses the provider-neutral selector.
lambdas/functions/webhook/src/runners/dispatch.test.ts Updates dispatch tests and mocks.
lambdas/functions/webhook/src/runners/aws-dynamic-labels.ts Removes obsolete Lambda selector.
lambdas/functions/webhook/src/runners/aws-dynamic-labels.test.ts Removes obsolete selector tests.
lambdas/functions/webhook/src/runners/aws-dynamic-labels-policy.ts Removes obsolete type re-export.
lambdas/functions/control-plane/src/scale-runners/scale-up.test.ts Updates unsupported-provider fixture.
lambdas/functions/control-plane/src/pool/pool.test.ts Updates unsupported-provider fixture.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lambdas/libs/compute-providers/webhook.ts
Comment thread lambdas/libs/compute-providers/dynamic-labels.test.ts Outdated
@edersonbrilhante

Copy link
Copy Markdown
Contributor Author

@Brend-Smits @guicaulada when the time permits, could you review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants