Skip to content

fix: align mongo/k8s/0.2 size schema with TF & make service enable_host_anti_affinity optional#555

Merged
anujhydrabadi merged 1 commit into
masterfrom
fix/mongo-k8s-0.2-size-and-service-host-anti-affinity-required
Jun 26, 2026
Merged

fix: align mongo/k8s/0.2 size schema with TF & make service enable_host_anti_affinity optional#555
anujhydrabadi merged 1 commit into
masterfrom
fix/mongo-k8s-0.2-size-and-service-host-anti-affinity-required

Conversation

@anujhydrabadi

@anujhydrabadi anujhydrabadi commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes two module-schema bugs that cause false-positive pre-flight validation errors in raptor create release, while the platform/Deployer accepts the same specs fine. Both were surfaced during a saas-cp / production release.

1. mongo/k8s/0.2 — size schema didn't match its own Terraform

  • The size schema declared cpu / memory (both required), but the v0.2 Terraform (facets-iac/.../modules/1_input_instance/mongodb/main.tf, which module.json declares as provides: mongo, flavors: [default, k8s], version: 0.2) reads cpu_requests / memory_requests behind a contains(keys(local.size), "cpu_requests") guard. The cpu/memory naming only belongs to the 0.3 TF (mongodb/0.3/main.tf).
  • Consequences of the drift:
    • A blueprint following the current 0.2 schema (cpu/memory) would silently get no resource requests — the TF guard is never satisfied.
    • A correct blueprint using cpu_requests/memory_requests (as prod does) fails validation: spec.size.memory: required field is missing.
  • Fix: rename the request fields to cpu_requests / memory_requests so the v0.2 schema matches the v0.2 module and real usage. Updated the required list, the cpu_limit/memory_limit x-ui-compare references, and the sample.

2. service/deployment/0.1enable_host_anti_affinity wrongly required

  • It was in the spec required list with no default, but the shared app-chart helm template guards it with {{- if and (hasKey .Values.spec "enable_host_anti_affinity") ... }} and treats absence as "no anti-affinity". The field is behaviorally optional.
  • Requiring it rejects otherwise-valid specs (e.g. service/control-plane-ui, flavor default, which resolves to this schema).
  • Fix: remove it from required (kept in properties and x-ui-order). Follows the precedent of fix: make health_checks optional in service deployment module #520 (make health_checks optional).

Notes / scope

  • service/statefulset/0.1 and service/vm/0.1 carry the same enable_host_anti_affinity in their required lists. Left untouched here to keep blast radius to the reported (deployment-lineage) failure — happy to extend if desired.
  • Both changes are schema relaxations / corrections: they only widen what validates; they cannot invalidate a previously-valid spec.

Test

  • Both files parse as valid YAML.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Updated MongoDB sizing fields to separate CPU and memory requests, with validation aligned to the new field names.
    • Improved service configuration requirements so runtime is now included in the required settings, and the form layout order has been refined for a clearer setup experience.

…ti-affinity optional

Two module-schema bugs that caused false-positive pre-flight validation
errors (raptor create release) while the platform/Deployer accepts the
specs fine.

mongo/k8s/0.2: the size schema declared `cpu`/`memory` (required), but the
v0.2 Terraform (facets-iac .../1_input_instance/mongodb/main.tf) reads
`cpu_requests`/`memory_requests` behind a `contains(keys, "cpu_requests")`
guard. The `cpu`/`memory` naming only belongs to the 0.3 TF. As a result a
blueprint following the 0.2 schema would silently get NO resource requests,
and a correct blueprint (using cpu_requests/memory_requests, as prod does)
fails validation with "spec.size.memory required field is missing". Rename
the request fields to cpu_requests/memory_requests so the schema matches the
v0.2 module and real usage; limit fields and their x-ui-compare refs updated
to match.

service/deployment/0.1: `enable_host_anti_affinity` was in the spec
`required` list with no default, but the shared app-chart helm template
guards it with `hasKey` and treats absence as "no anti-affinity". The field
is behaviorally optional, so requiring it rejects valid specs (e.g.
service/control-plane-ui). Remove it from `required` (kept in properties and
x-ui-order). Follows the precedent of #520 (health_checks made optional).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

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: ac11f1bd-c214-4c91-a06d-ea18d4acca36

📥 Commits

Reviewing files that changed from the base of the PR and between 212dd21 and ef759bd.

📒 Files selected for processing (2)
  • modules/mongo/k8s/0.2/facets.yaml
  • modules/service/deployment/0.1/facets.yaml
💤 Files with no reviewable changes (1)
  • modules/service/deployment/0.1/facets.yaml

Walkthrough

The PR updates MongoDB k8s size schema fields from cpu/memory to cpu_requests/memory_requests, including limit comparisons, required keys, and the sample object. It also updates the service deployment schema to require runtime and reorder the spec UI fields.

Changes

MongoDB k8s size schema

Layer / File(s) Summary
Field and limit updates
modules/mongo/k8s/0.2/facets.yaml
spec.size now defines cpu_requests and memory_requests, and both cpu_limit and memory_limit compare against those new fields.
Required keys and sample
modules/mongo/k8s/0.2/facets.yaml
The spec.size required list and sample object now use cpu_requests and memory_requests.

Service deployment spec

Layer / File(s) Summary
Required field and UI order
modules/service/deployment/0.1/facets.yaml
The spec schema requires runtime, and the UI order is updated for the spec fields.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes both schema fixes in mongo and service deployment.
Description check ✅ Passed The description covers summary, scope, and testing well, but omits the template's related issues, type of change, checklist, and reviewer instructions sections.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/mongo-k8s-0.2-size-and-service-host-anti-affinity-required

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

@anujhydrabadi anujhydrabadi merged commit c6a285c into master Jun 26, 2026
2 checks passed
@anujhydrabadi anujhydrabadi deleted the fix/mongo-k8s-0.2-size-and-service-host-anti-affinity-required branch June 26, 2026 10:17
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.

1 participant