Skip to content

docs(platform): document application defaults - #828

Open
myasnikovdaniil wants to merge 1 commit into
mainfrom
docs/application-defaults
Open

myasnikovdaniil wants to merge 1 commit into
mainfrom
docs/application-defaults

Conversation

@myasnikovdaniil

@myasnikovdaniil myasnikovdaniil commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Documents the applicationDefaults platform value from cozystack/cozystack#5107: a row in the platform package reference and a page under Operations, Configuration about when defaults apply, how an entry merges into a spec, the dashboard behaviour, how to check an entry with a dry-run and what happens when it can't be applied. The merge cases table is the same as in the proposal addendum, cozystack/community#146.

Built locally with Hugo 0.164.0 in the development environment, where docs/next is included: no errors, the reference link resolves.

@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a7ae13f7-051c-439b-8159-b93f3c762803
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@netlify

netlify Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cozystack ready!

Name Link
🔨 Latest commit 1a004b3
🔍 Latest deploy log https://app.netlify.com/projects/cozystack/deploys/6b0998791325cc73126dd8c2
😎 Deploy Preview https://deploy-preview-828--cozystack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Aleksei Sviridkin (lexfrei) added a commit to cozystack/cozystack that referenced this pull request Nov 27, 2026
## What this PR does

This PR adds installation defaults for applications: administrator sets
`applicationDefaults` in the platform values, and every application
created after that starts from them. Design is in [the proposal in
cozystack/community](cozystack/community#116),
related to [the worker defaults
issue](#3950).

The value is keyed by ApplicationDefinition plural (for example
`postgreses`) and the platform chart renders it into the
`cozystack-application-defaults` ConfigMap in `cozy-system`. The
aggregated API merges the entry for the kind under the submitted spec on
create, apply-create and dry-run create, and saves the result in
HelmRelease values. The order is user values, installation defaults,
then developer defaults from the chart schema. Update never applies
defaults, so changing the value leaves existing applications alone.

The merge goes into objects that declare `properties` and replaces
everything else whole: arrays, dictionaries with `additionalProperties`,
free-form objects, objects that also take arbitrary keys and objects
marked `x-kubernetes-map-type: atomic`. So a node pool that sets its own
`registryMirrors` gets no platform mirror entries. Explicit empty values
from the user (`{}`, `[]`, `false`, `0`, `""`) win over the installation
value.

An entry is checked against the application's OpenAPI schema before it
is merged. An object that the merge completes is checked as a partial
one, so `required` and `minProperties` are not enforced on it and its
`oneOf` is not evaluated (CEL rules are not evaluated at all). Whatever
is stored whole is checked whole: array rows, dictionary values,
free-form and atomic objects. Without that, an entry like a RabbitMQ
vhost without `roles` was accepted and stored, and the chart refused to
render it.

A missing ConfigMap means no defaults and gives no warning. An
unreadable ConfigMap, invalid JSON, a bad entry or an unreadable schema
does not block the create: defaults are skipped and the response carries
a Warning (dry-run too). The generic checks cover the whole map, so one
entry that is not an object, or a reserved top-level field in any entry,
turns defaults off for every application until it is fixed, while a bad
entry of one application only affects that application. The ConfigMap is
read through a cache limited to that one object, startup waits up to 30
s for it to sync and a create waits up to 5 s for the read, then both go
on without defaults.

Some objects take exactly one of their children and the chart refuses
two: the worker image of a node pool (`osImage.builtin` or
`osImage.factory`), a vm-disk `source`, the `oidc.customConfig` of a
kubernetes cluster and of a monitoring stack (`config` or `secretRef`).
A default for one child merged into an application that chose another
built that spec. These carry the atomic marker now, so the merge
replaces them whole, and `values.yaml` tells catalog authors to do the
same in their own schemas. The chart guide (`docs/agents/overview.md`)
says when the marker fits and when it does not. The `osImage` change is
the same hunk as in #5192.

The dashboard order page sends one dry-run create when it opens and
starts the form and YAML from the returned spec, so the browser reads no
ConfigMap and merges nothing. If the preview fails, or gets no answer in
8 s, the form opens with a notice and Retry, and Deploy still works.
After a failed preview a dropdown stays empty instead of selecting the
cluster default option, so the API applies the platform default to the
omitted field. A cleared text field leaves its key out, a dropdown None
and a sensitive field are written as `""`. While the server owns
defaults the form does not fill schema defaults on its own.

Not in this PR: defaults on update, re-rendering existing applications
when the value changes, defaults for HelmReleases that controllers
create directly, validation when the ConfigMap is saved, previews on
every edit in the dashboard.

### Merge order

#5190 and #5191 are merged and this branch is rebased on main. #5192 is
open and has the same `osImage` marker hunk, so whichever of the two
lands second needs one more `make generate` after a rebase.

### Known limits

- The dashboard does not show the API Warning.
- `null` for a field that has a developer default is saved as `null`
through kubectl or Terraform, but the dashboard form shows the developer
default.
- A number in an integer-or-string field is rejected by the form (same
on main), so quantities in an entry have to be quoted, `cpu: "2"`.
`values.yaml` says so.
- After a failed preview the form still requires a field that has no
schema default, even if an entry would supply it. Typing the value or
switching to YAML gets around it.
- The marker only fits a choice between alternatives that each stand
complete. I went through the application charts and rendered every
refusal I found that involves two or more fields, and most are not that.
A pair that has to be set together (`resources.cpu` with
`resources.memory`, `tls.enabled` with `tls.disableNonTLSListeners` in
rabbitmq) is completed field by field today, and an atomic object would
drop the default half. An object that also holds independent fields an
admin would default (`backup` in clickhouse, mariadb, mongodb and
postgres, `volume` in seaweedfs) would lose them. Relations between two
objects or two top-level fields (`cloudflareProxy` with `proxyProtocol`
in the ingress, most of postgres, the kubernetes addons) cannot carry a
marker. In all of these a default for one field plus the user's value
for another can make the chart refuse the render after the create went
through. Catching that needs the relations declared as rules in the
schema and the merged spec checked against them, and the API does not
evaluate such rules on a user spec yet (#2657), so it is a separate
change. A few relations depend on a lookup into the cluster and I could
not render them offline.
- Clearing an optional text or number field in the order form leaves its
key out, so the default comes back. A dropdown set to None, a sensitive
field and a dictionary value send an empty string and win. The form
keeps its old meaning of clearing a field, same as on main. To override
a default with an empty value, set it in the YAML tab (`""`, `0`).
Switching from the YAML tab back to the form fills an empty dropdown
with its default option again, a None included, so such a value has to
be deployed from the YAML tab
(#5473).
- An entry that cannot be parsed (invalid JSON, a reserved `_` key)
turns defaults off for every kind, not only its own, and the Warning on
each create names the problem. I did not split it per entry: the failure
is loud, the fix is in one place, and splitting touches the parse and
cache path for a case only a typo causes.
- An atomic object also drops a default for a field nested inside an
alternative when the user sets another field of that alternative. A
default for `osImage.factory.imageFactoryURL` does not survive a pool
that sets `osImage.factory.version`, and the boot disk then comes from
the public factory. `talos.imageFactoryURL` is the knob the chart falls
back to, it is not atomic, and defaults for it keep working.
- A schema that declares a typed property only inside an `allOf` or
`anyOf` branch, under a root that takes arbitrary keys, is checked as
partial. No schema in the tree looks like that.
- An object inside an `allOf`, `anyOf` or `oneOf` branch is closed to
unknown keys even when the property it constrains is declared as a
dictionary, so a valid entry for such a schema is refused and the create
goes on with a Warning
(#5474). No schema in the
tree looks like that either.
- The preview uses the placeholder name `preview`, so it fails when the
tenant already has an application of that kind with this name, and the
form opens with the notice.
- The cache wiring in `pkg/apiserver/apiserver.go` has no unit test, the
cache itself has.

### Verification

- `make unit-tests` on this head with `LC_ALL=C`, exit code 0 (a kafka
bats test on main depends on the locale).
- `tsc` and `eslint` in the console are clean.
- For the checks below I broke the code on purpose and saw the matching
test fail, except the `arrayMinItems` flag of the server form, I could
not make it matter.
- A run on a test cluster with v1.7.0 is in the comment below. It was on
an earlier revision, the stored-whole checks, the extra markers and the
cleared-field change came after and are covered by unit tests only.
- Not run: `make test-controllers`.
- The merge cases asked in review are fixtures of
`TestInstallationDefaultsMergeContract` now: a field set inside the
alternative a user chose of an atomic object, the same object without
the marker, an atomic object nested in one that merges, and an explicit
`null` over an installation object. The whole table is in the proposal
addendum, cozystack/community#146.

Checked cases:

- user values `{}`, `[]`, `false`, `0`, `""` are kept, and a node pool
with its own `registryMirrors` gets none from the platform
- an object with both `properties` and a dictionary, or with preserved
unknown fields, is replaced whole
- empty and `null` `spec` on create
- update after create, apply-update and a field removed on update keep
stored values
- a broken entry for another application, or an application with no
entry and no readable schema, does not touch this create
- missing ConfigMap gives no defaults and no warning, invalid JSON,
unreadable ConfigMap and a cache that did not sync give a Warning and
the create goes on
- partial entry: `required`, `minProperties` and object `oneOf` are
skipped on an object the merge completes, while unknown fields, wrong
types, scalar `oneOf` and array items are still checked
- array rows, dictionary values, free-form and atomic objects are
checked whole, also when the constraint sits in an `allOf` or `anyOf`
branch next to the property, and in these shapes an accepted entry
merges into a spec that the application's own schema accepts
- every ApplicationDefinition in the tree accepts an entry built from
its own developer defaults
- an object that lists properties without `type: object` is checked as
an object, so an unknown field in it is refused
- a pool with `osImage.factory`, a disk with another `source`, a cluster
with `oidc.customConfig.secretRef` and a monitoring stack with
`oidc.customConfig.config` do not get the other child from the platform,
on their real schemas
- a node pool that sets `resources.cpu` still gets `resources.memory`
from an entry, so the marker does not take away the field-by-field
completion of pairs
- dashboard: a user with no tenant does not wait on the spinner,
switching tenant keeps what was typed, a preview answer that arrives
after the tenant changed is dropped, a non-object answer counts as a
failed preview, Retry sends the current draft
- dashboard: after a failed preview dropdowns in a field, an array row
and a dictionary value stay empty, and edits made in YAML come back into
the form
- `required` inside array rows and dictionary values stays in force when
the server owns defaults, and an emptied sensitive field stays `""`

### Screenshots

Not captured yet.

### Downstream repositories

This PR changes `packages/core/platform/values.yaml`. The docs for the
new key are in cozystack/website#828, and the
proposal addendum with the merge cases and two decision records is in
cozystack/community#146. The Terraform provider
may be reached too: it has its own defaults for some sizing fields
(storage class, disk size), so installation defaults would not apply to
those, while the Talos block fields are left out when unset and do get
them. I read the schema, not the expand code.

- [ ] No downstream repository is affected by this change
- [x] [cozystack/website](https://github.com/cozystack/website) -
follow-up: cozystack/website#828
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up: to check, provider defaults vs installation defaults
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [x] [cozystack/community](https://github.com/cozystack/community) -
follow-up: cozystack/community#146

### Release note

```release-note
feat(api): add the `applicationDefaults` platform value, installation defaults are applied to new applications under user values, existing applications keep their saved settings, and the dashboard order form starts from the same defaults.
```

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.

I checked the page against the merged code on cozystack main: the create-only scope, the merge rules and all 23 rows of the table, the warning text, the failure scopes and the reference row match. Three sentences describe dashboard and admission behaviour differently from the code, see inline.


When the order page of an application opens, the dashboard asks the API for a dry-run create and starts the form and the YAML editor from the spec the API returns, so the form already shows the defaults. Deploy sends what the form shows, and the application stores those values.

Clearing a text or number field in the form leaves its key out of the request, so the default for that field comes back on Deploy. To store an empty value instead, set it in the YAML tab, for example `""` or `0`. Switching from the YAML tab back to the form fills an empty dropdown with its default option again, a dropdown set to None included, so deploy from the YAML tab when such a field has to stay empty. If the preview fails or takes longer than 8 seconds, the form opens without defaults and shows a notice with a Retry button, and Deploy still works: the API applies the defaults to every field the request leaves out.

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.

Two exceptions are missing here, and one gives the opposite result. Clearing the last field of a nested object makes the form send {} for that object, which turns off defaults for the whole object instead of bringing the default back. A cleared sensitive field is sent as "", so it stays empty (SchemaForm.server.test.tsx, "keeps an emptied sensitive field as an empty string"). Please name both cases after the first sentence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, named both after the first sentence: the last field of a nested object sends {} and turns off defaults for the whole object, a cleared sensitive field is sent as "".


## Dashboard

When the order page of an application opens, the dashboard asks the API for a dry-run create and starts the form and the YAML editor from the spec the API returns, so the form already shows the defaults. Deploy sends what the form shows, and the application stores those values.

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.

One case where Deploy does not store what kubectl would: if an entry sets null for a field that also has a chart default, kubectl and Terraform store null, but the form shows the chart default and stores that (comment above applicationDefaults in packages/core/platform/values.yaml). Please add a sentence about it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added after "Deploy sends what the form shows".


## Limits

Application defaults are a starting point, not a policy. Users can override every value, and updates never consult the entries. To require a value, use a ValidatingAdmissionPolicy or a webhook on the application resource: admission runs on the merged spec, so it sees the defaults too.

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.

Please make this "a validating webhook". A mutating webhook runs before the REST handler applies the defaults, so it does not see them (Create in pkg/registry/apps/application/rest.go, and the comment above applicationDefaults in packages/core/platform/values.yaml).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to a validating webhook, and the next sentence says a mutating one runs before the defaults and doesn't see them.

The platform Package gains an applicationDefaults value, and an
administrator who sets it needs to know more than its type: defaults
apply only when an application is created, a value the user sends
always wins, and some objects are taken whole rather than merged. A
broken entry does not block creation, it is skipped with a warning
that the dashboard does not show. None of that is visible from the
value itself.

The reference table gets the key, and a new page describes when
defaults apply, how an entry merges into a spec with the merge cases
the API is tested against, and how to check an entry with a dry-run.

Assisted-by: LLM
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
@myasnikovdaniil
myasnikovdaniil force-pushed the docs/application-defaults branch from c0dd8be to 1a004b3 Compare November 27, 2026 14:49

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.

All three points are fixed. I checked the new sentences against cozystack main: an emptied object is skipped by fillInstallationDefaults (len(obj) == 0), the create path in the order page sends the form data without pruning, and the Terraform sentence matches terraform-provider-cozystack#93. LGTM.

This branch has not been deployed

No deployments
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