Skip to content

fix(function-autoscaler): use cp environment labels for byoc count - #501

Merged
borao merged 1 commit into
mainfrom
fix/function-autoscaler/byoc-instance-count
Jul 28, 2026
Merged

borao merged 1 commit into
mainfrom
fix/function-autoscaler/byoc-instance-count

Conversation

@borao

@borao borao commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

TL;DR

Fix the BYOC/control-plane instance-count query to use the environment label values emitted by nvcf_function_instances_current: staging and production.

Additional Details (optional for docs, build, test, refactor, ci, chore, style, and revert PRs)

The autoscaler’s CP instance-count path was mapping stg -> stage and everything else to prod when querying nvcf_function_instances_current.

That label convention is correct for other autoscaler metric queries, but this CP metric uses environment="staging" and environment="production". This caused prod BYOC instance-count lookups to query environment="prod" and miss or undercount matching CP metric series.

This change is intentionally scoped to get_byoc_instance_count; worker metrics, utilization queries, discovery queries, and the existing active-instance helper are unchanged.

For the Reviewer

Please focus on src/control-plane-services/function-autoscaler/crates/server/src/work/mod.rs.

The new test directly exercises the BYOC/CP instance-count query path and verifies the query uses production for prd and staging for stg.

For QA (optional for docs, build, test, refactor, ci, chore, style, and revert PRs)

Verified locally:

  • cargo fmt
  • cargo test -p rs-autoscaler work::tests
  • cargo test -p rs-autoscaler

Issues

NO-REF

Checklist

  • I am familiar with the Contributing Guidelines.
  • I have signed off my commits for Developer Certificate of Origin (DCO) compliance.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected environment labeling for BYOC instance-count metrics, ensuring staging and production data are queried with the appropriate labels.
    • Added validation coverage for both staging and production environments.

Signed-off-by: Bora Oztekin <boztekin@nvidia.com>
@borao
borao requested a review from a team as a code owner July 28, 2026 16:52
@borao
borao requested a review from shelleyshen-0 July 28, 2026 16:52
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 5c4ee84d-91bd-4a6c-bdaf-1a8f9675328d

📥 Commits

Reviewing files that changed from the base of the PR and between 5d6fba1 and cba508b.

📒 Files selected for processing (1)
  • src/control-plane-services/function-autoscaler/crates/server/src/work/mod.rs

📝 Walkthrough

Walkthrough

The BYOC instance-count TimeseriesDb query now labels stg as staging and other environments as production. A unit test verifies the mappings for stg and prd inputs.

Changes

BYOC environment labels

Layer / File(s) Summary
Environment mapping and validation
src/control-plane-services/function-autoscaler/crates/server/src/work/mod.rs
The BYOC query uses staging for stg and production otherwise; a mocked TimeseriesDb test validates both mappings.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: shelleyshen-0

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title follows Conventional Commits and accurately reflects a bug fix in function-autoscaler.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/function-autoscaler/byoc-instance-count

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

@github-actions

Copy link
Copy Markdown
Contributor

🛡️ CodeQL Analysis

🚨 Found 2 issue(s)

Severity Breakdown:

  • 🔴 Errors: 0
  • 🟡 Warnings: 0
  • 🔵 Notes: 0
📋 Top Issues

🔗 View full details in Security tab

🕐 Last updated: 2026-07-28 16:54:53 UTC | Commit: cba508b

@borao
borao added this pull request to the merge queue Jul 28, 2026
Merged via the queue into main with commit ad60f6d Jul 28, 2026
18 checks passed
@borao
borao deleted the fix/function-autoscaler/byoc-instance-count branch July 28, 2026 20:25
@balajinvda

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version nvcf-function-autoscaler-v1.18.8 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants