Skip to content

feat: add per-function vcpu parameter#645

Merged
eduardoboucas merged 3 commits into
masterfrom
feat/functions-vcpu
May 19, 2026
Merged

feat: add per-function vcpu parameter#645
eduardoboucas merged 3 commits into
masterfrom
feat/functions-vcpu

Conversation

@eduardoboucas
Copy link
Copy Markdown
Member

No description provided.

@eduardoboucas eduardoboucas requested review from a team as code owners May 19, 2026 09:33
@netlify
Copy link
Copy Markdown

netlify Bot commented May 19, 2026

Deploy Preview for open-api ready!

Name Link
🔨 Latest commit 5317c42
🔍 Latest deploy log https://app.netlify.com/projects/open-api/deploys/6a0c347702218000089ff6c6
😎 Deploy Preview https://deploy-preview-645--open-api.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed869e18-3a2b-4acc-ab16-10701e727220

📥 Commits

Reviewing files that changed from the base of the PR and between f2723cf and 5317c42.

📒 Files selected for processing (1)
  • go/porcelain/functions_manifest.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • go/porcelain/functions_manifest.go

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Functions now support vCPU provisioning (0.5–2) as an alternative to memory-based sizing.
    • vCPU and memory remain mutually exclusive options for function resource allocation.
    • Deployment and manifest workflows now propagate vCPU settings so configured values are applied.
  • Documentation

    • API/schema docs and manifests updated to expose the new vCPU option and clarify the mutual-exclusion with memory.

Walkthrough

This PR adds optional vCPU configuration support to function deployments. The Swagger schema introduces a new vcpu field (type number, range 0.5–2) and updates the memory field description to note mutual exclusivity. The FunctionConfig Go model reflects this new field with JSON serialization. The functionsManifestEntry struct gains a corresponding Vcpu field. The bundleFromManifest function in deploy.go is updated to consider vCPU when deciding to generate FunctionConfig and to populate the vCPU value during config construction.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • netlify/open-api#643: Adds Memory field support through similar schema and deployment wiring changes to bundleFromManifest and FunctionConfig.

Suggested reviewers

  • paulo
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No description was provided by the author, which makes it impossible to verify relevance to the changeset. Add a pull request description explaining the purpose, benefits, and context of adding the vcpu parameter feature.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and clearly describes the main change: adding a new vcpu parameter for per-function configuration across multiple files.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 feat/functions-vcpu

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
swagger.yml (1)

5558-5581: ⚠️ Potential issue | 🔴 Critical

Add cross-field validation for memory/vcpu mutual exclusivity in FunctionConfig.

The schema documents that memory and vcpu are mutually exclusive, but the current FunctionConfig.Validate() method does not enforce this constraint. The codebase has an established pattern for this (ValidateCrossFieldConstraints() in database_compute_settings_request_validate.go). Implement similar validation for FunctionConfig to ensure the server rejects payloads where both fields are set.

🤖 Prompt for 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.

In `@swagger.yml` around lines 5558 - 5581, FunctionConfig.Validate() doesn't
enforce the documented mutual exclusivity of memory and vcpu; add a cross-field
check similar to ValidateCrossFieldConstraints() in
database_compute_settings_request_validate.go that returns an error when both
FunctionConfig.memory and FunctionConfig.vcpu are non-nil/set. Update
FunctionConfig.Validate() to call the new check (or inline the same logic),
ensure the returned error matches existing validation error types/format used
elsewhere, and reference FunctionConfig, ValidateCrossFieldConstraints, and
FunctionConfig.Validate in your change so reviewers can find the logic easily.
🤖 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 `@swagger.yml`:
- Around line 5576-5581: The OpenAPI schema for the vcpu property currently only
documents "0.5–2" in the description; add schema-level numeric constraints to
enforce this by adding minimum: 0.5 and maximum: 2 (keep type: number and
format: float) on the vcpu property so clients and generators can validate the
allowed range for the vcpu field.

---

Outside diff comments:
In `@swagger.yml`:
- Around line 5558-5581: FunctionConfig.Validate() doesn't enforce the
documented mutual exclusivity of memory and vcpu; add a cross-field check
similar to ValidateCrossFieldConstraints() in
database_compute_settings_request_validate.go that returns an error when both
FunctionConfig.memory and FunctionConfig.vcpu are non-nil/set. Update
FunctionConfig.Validate() to call the new check (or inline the same logic),
ensure the returned error matches existing validation error types/format used
elsewhere, and reference FunctionConfig, ValidateCrossFieldConstraints, and
FunctionConfig.Validate in your change so reviewers can find the logic easily.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1542f82e-0337-4b88-ada3-f975e3b90263

📥 Commits

Reviewing files that changed from the base of the PR and between 1764a43 and f2dcbcd.

📒 Files selected for processing (4)
  • go/models/function_config.go
  • go/porcelain/deploy.go
  • go/porcelain/functions_manifest.go
  • swagger.yml

Comment thread swagger.yml
Comment on lines +5576 to +5581
vcpu:
type: number
format: float
description: |
Number of vCPUs to provision for the function. Allowed range is
0.5–2.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add schema-level constraints for the vCPU range.

The vcpu field documents an allowed range of 0.5–2 in the description, but the schema lacks minimum and maximum constraints. Adding these constraints will enable client validation, improve generated documentation, and provide clearer API contract enforcement.

📋 Proposed fix to add range constraints
   vcpu:
     type: number
     format: float
+    minimum: 0.5
+    maximum: 2
     description: |
       Number of vCPUs to provision for the function. Allowed range is
       0.5–2.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
vcpu:
type: number
format: float
description: |
Number of vCPUs to provision for the function. Allowed range is
0.5–2.
vcpu:
type: number
format: float
minimum: 0.5
maximum: 2
description: |
Number of vCPUs to provision for the function. Allowed range is
0.5–2.
🤖 Prompt for 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.

In `@swagger.yml` around lines 5576 - 5581, The OpenAPI schema for the vcpu
property currently only documents "0.5–2" in the description; add schema-level
numeric constraints to enforce this by adding minimum: 0.5 and maximum: 2 (keep
type: number and format: float) on the vcpu property so clients and generators
can validate the allowed range for the vcpu field.

@eduardoboucas eduardoboucas merged commit e55927e into master May 19, 2026
15 checks passed
@eduardoboucas eduardoboucas deleted the feat/functions-vcpu branch May 19, 2026 10:12
eduardoboucas pushed a commit that referenced this pull request May 19, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.55.0](v2.54.0...v2.55.0)
(2026-05-19)


### Features

* add per-function `memory` parameter
([#643](#643))
([1764a43](1764a43))
* add per-function `vcpu` parameter
([#645](#645))
([e55927e](e55927e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: token-generator-app[bot] <82042599+token-generator-app[bot]@users.noreply.github.com>
Co-authored-by: token-generator-app[bot] <token-generator-app[bot]@users.noreply.github.com>
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