Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

values schema #811

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

values schema #811

wants to merge 29 commits into from

Conversation

wkloucek
Copy link
Contributor

@wkloucek wkloucek commented Nov 22, 2024

Description

Maintain a schema file to find misconfigurations.
There were already some misconfigurations found in the deployment examples (see the diff).

Related Issue

Motivation and Context

How Has This Been Tested?

  • tested in CI against CI values and deployment examples
  • tested against well known deployments outside of this Chart repo
    • the "B" project, see issue backref on this ticket
    • the "E" project, I ran a command like this helm lint charts/ocis -f ~/Projects/gitlab.xxx/exxx/ocis-infra/common/ocis/values.yaml -f ~/Projects/gitlab.xxx/exxx/ocis-infra/prod/apps/ocis/values.yaml

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation generated (make docs) and committed
  • Documentation ticket raised:
  • Documentation PR created:

@wkloucek wkloucek marked this pull request as draft November 22, 2024 10:27
@wkloucek wkloucek added the QA label Nov 25, 2024
@wkloucek wkloucek requested a review from d7oc November 25, 2024 14:23
@wkloucek
Copy link
Contributor Author

wkloucek commented Nov 25, 2024

@d7oc could you skim those changes to check if you agree with the principle of this change?

Most interesting from my side:

  • the effect on the values.yaml changes in the future (one needs to maintain the schema annotations)
  • the schema helps devs to put configuration in the right place and avoid configuration that does nothing (includes config that was removed)
  • the deployment examples stay up to date because their configuration is now linted, too
  • the schema forces us to have sane defaults / configuration methods

If we can agree on the schema beeing a good thing, I'll gonna do some polishing on this PR, especially on the configuration documentation that received a small fallout.

@wkloucek wkloucek marked this pull request as ready for review December 6, 2024 08:14
@wkloucek
Copy link
Contributor Author

wkloucek commented Dec 6, 2024

@d7oc I'd like to get this into the chart soonish or agree on a timeframe when this change does fits our risk analysis / schedule / ...

This week I had another occurence where this schema feature would have saved a college and my like 2 hours each because we had fine looking configuration on a wrong indention level.

Copy link
Contributor

@d7oc d7oc left a comment

Choose a reason for hiding this comment

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

Submitting first feedback. Check until line 800 in values.yaml

Comment on lines +67 to +71
sha:
# @schema
# type: [string, null]
# required: true
# @schema
Copy link
Contributor

Choose a reason for hiding this comment

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

We should somehow limit the allowed strings here, as per Kubernetes API this can only be Always, Never or IfNotPresent.

Suggested change
sha:
# @schema
# type: [string, null]
# required: true
# @schema
sha:
# @schema
# enum: ["Always", "Never", "IfNotPresent", null]
# required: true
# @schema

Copy link
Contributor Author

@wkloucek wkloucek Dec 9, 2024

Choose a reason for hiding this comment

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

adding null to to the enum field does actually not end up in the final schema.

This would be no blocker for .Values.image.pullPolicy, because it is never null.

But .Values.services.<service>.image.pullPolicy needs to be nullable to fallback to .Values.image.pullPolicy

With your changes, liniting fails:

DEBU[2024-12-09T08:01:38+01:00] Using template files [charts/ocis/docs/templates/values-desc-table.adoc.gotmpl] for chart charts/ocis 
/home/wkloucek/go/bin/gomplate-v3.11.8 --file=charts/ocis/docs/templates/values.adoc.yaml.gotmpl  --out=charts/ocis/docs/values.adoc.yaml
/home/wkloucek/go/bin/helm-v3.16.2 lint charts/ocis -f 'charts/ocis/ci/absolute-minimum-values.yaml'
==> Linting charts/ocis
[INFO] Chart.yaml: icon is recommended
[ERROR] values.yaml: - services.activitylog.image.pullPolicy: services.activitylog.image.pullPolicy must be one of the following: "Always", "Never", "IfNotPresent"

As said, this is because the schema doesn't inherit the null:

                 "pullPolicy": {
                   "default": "",
                   "description": "Image pull policy",
+                  "enum": [
+                    "Always",
+                    "Never",
+                    "IfNotPresent"
+                  ],
                   "required": [],
-                  "title": "pullPolicy",
-                  "type": [
-                    "string",
-                    "null"
-                  ]
+                  "title": "pullPolicy"
                 },

charts/ocis/values.yaml Show resolved Hide resolved
type: RollingUpdate
rollingUpdate:
# @schema
# type: string
Copy link
Contributor

Choose a reason for hiding this comment

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

This is defined as type IntOrString in Kubernetes API. Should we still restrict this to string only?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!

was applied in f793e61

# Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
maxSurge: 25%
# @schema
# type: string
Copy link
Contributor

Choose a reason for hiding this comment

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

IntOrString same as maxSurge

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point!

was applied in f793e61

# @schema
# type: array
# items:
# type: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these nodes always have an <host>:<portnummer> nomenclature? If so we could use pattern here. Also applies for all oder nodes secure further down below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the nats client library probably has a port default, so this might also be possible without specifying a port.

Also I don't know if a protocol prefix like tcp:// could be allowed.

I'd like to keep this vague as long as there is no strict specification from the oCIS product

# -- Create demo users on the first startup.
# Not recommended for production installations.
demoUsers: false
# Language related settings
language:
# @schema
# type: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we use an enum with available languages here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm unsure if a exhaustive list about available / supported languages exists.

Even if it exists, we'd need to adapt it with every oCIS release? I'd like to avoid that in the current situation.

# -- Enables email notifications.
enabled: false
smtp:
# @schema
# type: [string, null]
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 11d4e12

# type: boolean
# required: true
# uri:
# type: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 48be379

# type: string
# required: false
# iconURI:
# type: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 48be379

# hosts:
# type: array
# items:
# type: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 48be379

@d7oc
Copy link
Contributor

d7oc commented Dec 6, 2024

I'm missing the commend here to generate the schema from the values.yaml or is there some magic I've overlooked?

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.

Add values schema
2 participants