Skip to content

fix: refuse values that could never be deployed when a configuration is saved - #319

Merged
samuelmbabhazi merged 1 commit into
mainfrom
fix/314-refuse-undeployable-values
Nov 16, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
fix/314-refuse-undeployable-values

Conversation

@samuelmbabhazi

@samuelmbabhazi samuelmbabhazi commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #314. Second of two changes: #317 made a deployment that cannot be planned fail instead of staying stuck; this one refuses the values behind such deployments when the configuration is saved.

What changed

A value could pass the JSON Schema and still be impossible to deploy. The configuration was saved, and every deployment of it failed later, sometimes without a readable reason.

Both validators now refuse these values, after the schema, with the same paths and messages:

Value Refused when Why
resources.cpu above 256 CPUs, or too large to count the agent refuses more
resources.memory below 6Mi Docker refuses less
resources.memory above 1Ti, or too large to count the agent refuses more
run.healthcheck.interval, timeout, start_period, release.timeout, deploy.drain_timeout too long to be counted the pipeline reads them as milliseconds
  • TypeScript: valueIssues in packages/config-schema, called by validateShipkeepConfig, so the API, and the editor in the browser, report the problem at its field.
  • Go: valueIssues in lib/config, called by Validate, so shipkeep deploy refuses the same file before it is sent.
  • The API's planner now reads CPU, sizes and durations through the functions of packages/config-schema instead of its own copies.
  • SPEC 2.2 lists the rules, 3.3 states the agent's upper limits, and the open question about small limits is replaced by what remains.

A correction

Issue #314 and SPEC 16 said that Docker refuses a CPU limit under 0.01 CPU. I checked on Docker 29.1.3: it accepts --cpus 0.001, and refuses -m 5m with Minimum memory limit allowed is 6MB. So there is a memory minimum and no CPU minimum beyond "greater than zero", which the schema already enforces.

How it was tested

  • Shared fixtures, read by both validators: seven new invalid documents and two valid ones at the limits (1m and 6Mi, 256 and 1Ti).
  • Unit tests on each side with the same cases and the exact paths and messages, including one byte under the memory minimum, decimal units (6M is under 6Mi), and values that overflow.
  • Eight mutations, four on each side (minimum dropped, maximum off by one, durations unchecked, checks not called): each is caught.
  • Integration test with PostgreSQL: the API answers 400 invalid_application_config with the issue at /resources/cpu, and a release stored with such a value before this check still fails its deployment cleanly (fix(api): fail a deployment that cannot be planned instead of retrying it #317).

Not run on the installation rig: no agent action and no installer changes.

Security considerations

  • Stricter input validation only. Messages name the rule, never the value.
  • Not covered: durations outside what the agent accepts for a step (a release timeout above one hour, for example) still pass validation and fail when that step runs. Recorded in SPEC 16.
  • A configuration saved before this change with one of these values keeps it until it is saved again; fix(api): fail a deployment that cannot be planned instead of retrying it #317 makes its deployments fail with a reason.

Summary by CodeRabbit

  • Bug Fixes
    • Configuration validation now rejects CPU allocations above 256 CPUs, memory below 6 MiB or above 1 TiB, and durations that cannot be safely counted.
    • Invalid resource settings are caught during deployment, preventing an allocation from being created for a deployment with an oversized CPU value.
  • Documentation
    • Updated configuration guidance to reflect supported resource limits and duration validation.

…is saved

A value could pass the schema and still be impossible to deploy: a CPU
or a duration too large to count, more CPU or memory than the agent
accepts, less memory than Docker accepts. The configuration was saved,
and every deployment of it failed later.

Both validators now refuse these values, with the same paths and
messages, and the API reads values through the same functions.

Closes #314

Signed-off-by: samuel mbabhazi <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Configuration validation now rejects resource values outside deployment limits and durations that cannot be counted. The deployment planner uses the config-schema parsing helpers. Tests and specification text cover these checks and their effects on deployments.

Changes: Configuration value validation

Layer / File(s) Summary
Shared value parsing and validation
packages/config-schema/src/lib/values.ts, packages/config-schema/src/lib/validate.ts, packages/config-schema/src/lib/values.spec.ts, packages/config-schema/src/index.ts, packages/config-schema/fixtures/{invalid,valid}/*
The config-schema package parses CPU, memory, and duration values. Validation reports issues for CPU above 256, memory outside 6 MiB–1 TiB, and durations that cannot be represented as safe integer milliseconds. Tests and fixtures cover invalid values and resource boundaries.
Go config validation and deployment limits
lib/config/values.go, lib/config/validate.go, lib/config/values_test.go, docs/SPEC.md
The Go config loader returns validation errors for out-of-range resources and uncountable durations. Tests check error paths and accepted boundary values. The specification documents the limits and validation rules.
Deployment planner parser reuse
apps/api/src/modules/deployments/domain/container-plan.ts, apps/api/src/modules/deployments/deployment-pipeline.integration.spec.ts
The deployment planner uses the config-schema parsers for CPU, memory, and duration values. The integration test checks that an oversized CPU value cannot be saved and that a deployment with that value fails after its stored configuration is changed.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

  • shipkeepdev/shipkeep#317: Handles deployment failures when planning rejects a deployment and skips nodes without capacity facts.

Suggested labels: track:control-plane

Merge Risk: Minimal · up to 104df

Saving a configuration now refuses CPU, memory, and duration values that could never be deployed, and both validators apply the same limits. No concrete merge-blocking risk was identified.

Security architecture risk: Minimal · up to 104df

The stricter rules reject invalid configurations before saving them. Rejected saves preserve existing configuration, and existing concurrency and container resource controls remain in place. No introduced security or failure-containment issue was established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • observed — The inspected configuration replacement remains scoped by organization and environment and guarded by configSha. The changed parsing helpers convert resource and duration text; they do not introduce tenant selectors, credentials or additional agent operations.

Trust Boundaries and Controls

  • observed — User-influenced configuration passes schema validation and the new value checks before becoming a persistable ApplicationConfig. Failure throws before either inspected save command reaches its store mutation, resolving the supplied uncertainty about enforcement before the database sink.
Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #314 has two coding areas and one save-time validation area.

(1) Save-time value validation (#314, Expected, third bullet): Implemented in this PR. valueIssues in `packages/config-schema/src/…
Confirm that a placement test exists at the reviewed head. It must place a replica in an organization with one node without CPU or memory facts and one ready node, and assert that the replica lands on the ready node. If the test is absent, …
Passed Passed checks: 3 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the primary change: value checks that refuse CPU, memory, and duration settings that a deployment can never accept, applied when a configuration is saved. The PR objectives and the cha…
Out of Scope Changes check Passed All changed areas connect to the linked issue or to the PR's stated purpose. The changes are:
- Save-time value checks in both validators (values.ts, values.go, validate.ts, validate.go) and t…
Full details: Title check

Explanation

The title names the primary change: value checks that refuse CPU, memory, and duration settings that a deployment can never accept, applied when a configuration is saved. The PR objectives and the changed validators (TypeScript and Go) match this. The title uses a conventional 'fix:' prefix and is specific enough for a teammate scanning history. At 77 characters it is slightly long but still a single clear sentence.

Full details: Out of Scope Changes check

Explanation

All changed areas connect to the linked issue or to the PR's stated purpose. The changes are:

  • Save-time value checks in both validators (values.ts, values.go, validate.ts, validate.go) and their tests. These implement #314's save-time requirement.
  • Shared fixtures in packages/config-schema/fixtures. These support both validators' tests.
  • The planner in container-plan.ts reading CPU, sizes, and durations through config-schema functions. This removes duplicated parsing that caused the #314 planner throw.
  • The integration test in deployment-pipeline.integration.spec.ts. It covers the #314 planner-failure case.
  • docs/SPEC.md changes. They document the new rules and correct the Docker CPU claim, which #314 and SPEC 16 both carry.
  • Re-export in packages/config-schema/src/index.ts. It makes the shared functions available to the API.

No change is unrelated to #314 or to the validation purpose. The node-placement logic in scheduler.ts is not changed by this PR.

Full details: Linked Issues check

Explanation

Issue #314 has two coding areas and one save-time validation area.

(1) Save-time value validation (#314, Expected, third bullet): Implemented in this PR. valueIssues in packages/config-schema/src/lib/values.ts and lib/config/values.go refuses CPU above 256 CPUs or uncountable, memory below 6Mi or above 1Ti, and uncountable durations at the five pipeline paths. Both validators call these checks after the schema, and shared fixtures and mirrored unit tests cover the cases. The issue asks that CPU below 0.01 be refused. The PR reports, from a Docker 29.1.3 check, that --cpus 0.001 is accepted, so no CPU minimum beyond greater than zero is applied. I did not verify this Docker behavior. The schema already enforces greater than zero. This part is met, subject to the author's Docker claim.

(2) Planner failure (#314, Done when, first test): The integration test in deployment-pipeline.integration.spec.ts sets an oversized CPU value on a stored release, runs the pipeline, and asserts the deployment fails with a readable message and releases the application slot. The PR description attributes the failure-behavior change to #317, which is not part of this diff. The planner now reads values through the shared config-schema functions in container-plan.ts. This covers the planner-failure case as far as this diff shows.

(3) Node without capacity facts (#314, Expected, second bullet; Done when, second test): At packages/domain/src/lib/scheduler.ts (unchanged by this PR, present at head), reject returns cpu or memory when a node capacity is zero, and assertNode no longer throws for zero capacity. The behavior is implemented. The PR does not add or change this code, and I found no placement test in the PR summary. I did not confirm that a test for a ready node beside a node without facts exists at head. That Done-when test remains unverified.

The linked-issue requirements are mostly met. The placement test requirement cannot be confirmed from the evidence available.

Resolution

Confirm that a placement test exists at the reviewed head. It must place a replica in an organization with one node without CPU or memory facts and one ready node, and assert that the replica lands on the ready node. If the test is absent, add it, or state that it belongs to another change and remove it from #314's completion criteria. Also confirm that the Docker 29.1.3 result for --cpus 0.001 and the -m 5m refusal is reproducible, or record it as an unverified author claim.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 65bb5de and 104df5f.

Files selected for processing: 19

  • apps/api/src/modules/deployments/deployment-pipeline.integration.spec.ts
  • apps/api/src/modules/deployments/domain/container-plan.ts
  • docs/SPEC.md
  • lib/config/validate.go
  • lib/config/values.go
  • lib/config/values_test.go
  • packages/config-schema/fixtures/invalid/cpu-above-agent-limit.yml
  • packages/config-schema/fixtures/invalid/cpu-overflow.yml
  • packages/config-schema/fixtures/invalid/drain-timeout-overflow.yml
  • packages/config-schema/fixtures/invalid/healthcheck-interval-overflow.yml
  • packages/config-schema/fixtures/invalid/memory-above-agent-limit.yml
  • packages/config-schema/fixtures/invalid/memory-below-docker-minimum.yml
  • packages/config-schema/fixtures/invalid/release-timeout-overflow.yml
  • packages/config-schema/fixtures/valid/resources-largest.yml
  • packages/config-schema/fixtures/valid/resources-smallest.yml
  • packages/config-schema/src/index.ts
  • packages/config-schema/src/lib/validate.ts
  • packages/config-schema/src/lib/values.spec.ts
  • packages/config-schema/src/lib/values.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@samuelmbabhazi
samuelmbabhazi merged commit c436e6d into main Nov 16, 2026
16 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/314-refuse-undeployable-values branch November 16, 2026 12:06
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.

A deployment whose plan throws stays stuck instead of failing

1 participant