Skip to content

Conversation

kingdonb
Copy link
Member

@kingdonb kingdonb commented Aug 6, 2025

New Flux Operator from this morning

Changelogs:

Summary by CodeRabbit

  • New Features

    • Introduced a configurable healthcheck feature for post-install and post-upgrade verification, including a dedicated healthcheck job and service account options.
    • Added an optional size field to cluster configuration, allowing selection of vertical scaling profiles (small, medium, large).
  • Enhancements

    • Increased default CPU resource limits for the Flux Operator from 1 CPU to 2 CPUs.
    • Improved configuration schemas with explicit typing and validation for greater clarity and reliability.
  • Documentation

    • Updated documentation to reflect new configuration options, version numbers, and enhanced resource settings.
  • Bug Fixes

    • Template rendering now omits empty string values in cluster configuration, resulting in cleaner manifests.

Signed-off-by: Kingdon B <kingdon@urmanac.com>
Copy link
Contributor

coderabbitai bot commented Aug 6, 2025

Walkthrough

This change updates the Flux Operator and Flux Instance Helm charts to version 0.27.0, introduces a new size field to the FluxInstance CRD and configuration, and adds a comprehensive, configurable healthcheck job to the flux-instance chart. JSON schemas and documentation are updated for stricter validation and clarity.

Changes

Cohort / File(s) Change Summary
Flux Operator Chart Version Bump
packages/system/fluxcd-operator/charts/flux-operator/Chart.yaml
packages/system/fluxcd/charts/flux-instance/Chart.yaml
Updated appVersion and version fields from 0.24.1 to 0.27.0 in both Helm chart metadata files.
Flux Operator Resource Limits
packages/system/fluxcd-operator/charts/flux-operator/values.yaml
packages/system/fluxcd-operator/charts/flux-operator/README.md
Increased CPU limit from 1000m to 2000m in default values and documentation.
Flux Operator JSON Schema Strictness
packages/system/fluxcd-operator/charts/flux-operator/values.schema.json
Added explicit "type" declarations and required property annotations throughout the schema, improving validation precision and consistency.
FluxInstance CRD Schema Update
packages/system/fluxcd-operator/charts/flux-operator/templates/crds.yaml
Added new optional size property with enum (small, medium, large) to spec.cluster in the FluxInstance CRD.
Flux Instance Chart Version Bump
packages/system/fluxcd/charts/flux-instance/Chart.yaml
Updated appVersion and version fields from 0.24.1 to 0.27.0.
Flux Instance Documentation and Config
packages/system/fluxcd/charts/flux-instance/README.md
packages/system/fluxcd/charts/flux-instance/values.yaml
Documented new size field and healthcheck section; added size field to instance.cluster; introduced comprehensive healthcheck configuration with defaults and schema annotations.
Flux Instance JSON Schema Expansion
packages/system/fluxcd/charts/flux-instance/values.schema.json
Added new top-level healthcheck object with detailed nested schema; updated instance and cluster with explicit types and new size enum; improved schema strictness and added defaults for several properties.
Flux Instance Healthcheck Job
packages/system/fluxcd/charts/flux-instance/templates/healthcheck.yaml
Introduced a new conditional Kubernetes Job template for post-install and post-upgrade health checks, fully configurable via the new healthcheck section.
Flux Instance ServiceAccount Template
packages/system/fluxcd/charts/flux-instance/templates/serviceaccount.yaml
Added a new conditional ServiceAccount manifest template for the healthcheck job, configurable via the healthcheck.serviceAccount section.
Flux Instance CRD Template Filtering
packages/system/fluxcd/charts/flux-instance/templates/instance.yaml
Changed rendering logic for cluster fields to exclude keys with empty string values, improving manifest cleanliness.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Helm
    participant Kubernetes
    participant HealthcheckJob
    participant FluxInstance

    User->>Helm: Install/Upgrade flux-instance chart
    Helm->>Kubernetes: Apply manifests (FluxInstance, CRDs, ServiceAccount, Healthcheck Job)
    Note over Helm,Kubernetes: If .Values.healthcheck.enabled is true
    Kubernetes->>HealthcheckJob: Create Job (post-install/post-upgrade hook)
    HealthcheckJob->>FluxInstance: Wait for readiness (with timeout)
    HealthcheckJob->>Kubernetes: Report success/failure
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–25 minutes

Possibly related PRs

  • cozystack/cozystack#567: Updates the Flux Operator chart version; both PRs touch the same chart metadata files, but this PR also adds schema and healthcheck features.

Suggested labels

documentation, enhancement, size:M, lgtm

Suggested reviewers

  • lllamnyp
  • klinch0
  • kvaps

Poem

A bunny hopped through YAML fields,
With charts and CRDs to wield.
"Let's check our health!" the rabbit cheered,
As new jobs and sizes appeared.
With stricter schemas, all is right—
Flux hops forward, future bright! 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @kingdonb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've updated the Flux Operator and Flux Instance Helm charts to version 0.27.0. This update brings the latest features and fixes from the upstream Flux Operator project, including an increased default CPU limit for the operator and the introduction of a new size field for FluxInstance CRDs to define scaling profiles. Additionally, the Flux Instance chart now includes optional post-install/upgrade health checks.

Highlights

  • Flux Operator Version Bump: The flux-operator Helm chart has been updated from v0.24.1 to v0.27.0, aligning with the latest upstream releases.
  • Increased CPU Resource Limits: The default CPU limit for the Flux Operator has been increased from 1000m to 2000m to accommodate potentially higher resource demands.
  • FluxInstance CRD Enhancements: A new size field has been added to the FluxInstance Custom Resource Definition, allowing for the definition of vertical scaling profiles (small, medium, large) for Flux controllers.
  • New Health Check Feature for Flux Instance: The flux-instance Helm chart now includes an optional post-install and post-upgrade health check job, improving deployment reliability.
  • Schema and Configuration Updates: Various schema definitions (values.schema.json) and default values (values.yaml) have been refined across both charts to reflect the new features and improved configurations.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Flux Operator to version 0.27.0. The changes include version bumps in Chart.yaml files, documentation updates in README.md files, and significant updates to values.schema.json files to improve correctness and add new features. A new healthcheck feature is also introduced for flux-instance. While most changes are correct, the implementation of the new healthcheck feature has a critical flaw related to RBAC permissions. The default configuration will cause the healthcheck job to fail. I have provided detailed comments and suggestions to fix this by creating a dedicated, properly permissioned service account for the healthcheck job.

Comment on lines +1 to +17
{{- if .Values.healthcheck.serviceAccount.create }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Values.healthcheck.serviceAccount.name }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "flux-instance.labels" . | nindent 4 }}
{{- with .Values.commonLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.healthcheck.serviceAccount.automount }}
{{- end }}

Choose a reason for hiding this comment

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

critical

The newly created service account for the healthcheck job is missing the necessary RBAC permissions to read FluxInstance resources, and it doesn't handle the case where a name is not provided. This will cause the healthcheck job to fail when healthcheck.serviceAccount.create is true. A Role and RoleBinding should be created to grant these permissions, and a default name should be generated if one is not provided.

{{- if .Values.healthcheck.serviceAccount.create -}}
{{- $saName := .Values.healthcheck.serviceAccount.name | default (printf "%s-healthcheck" (include "flux-instance.fullname" .)) -}}
apiVersion: v1
kind: ServiceAccount
metadata:
  name: {{ $saName }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "flux-instance.labels" . | nindent 4 }}
    {{- with .Values.commonLabels }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
  {{- with .Values.commonAnnotations }}
  annotations:
    {{- toYaml . | nindent 4 }}
  {{- end }}
automountServiceAccountToken: {{ .Values.healthcheck.serviceAccount.automount }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: {{ $saName }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "flux-instance.labels" . | nindent 4 }}
rules:
  - apiGroups: ["fluxcd.controlplane.io"]
    resources: ["fluxinstances"]
    verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: {{ $saName }}
  namespace: {{ .Release.Namespace }}
  labels:
    {{- include "flux-instance.labels" . | nindent 4 }}
subjects:
  - kind: ServiceAccount
    name: {{ $saName }}
    namespace: {{ .Release.Namespace }}
roleRef:
  kind: Role
  name: {{ $saName }}
  apiGroup: rbac.authorization.k8s.io
{{- end }}

imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ .Values.healthcheck.serviceAccount.name }}

Choose a reason for hiding this comment

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

high

To align with the recommended changes for creating a dedicated service account for healthchecks, the serviceAccountName should also use the generated default name if one is not provided in values.yaml. This makes the healthcheck feature more robust and work out-of-the-box.

      serviceAccountName: {{ .Values.healthcheck.serviceAccount.name | default (printf "%s-healthcheck" (include "flux-instance.fullname" .)) }}

Comment on lines +89 to +92
serviceAccount: # @schema default: {"create":false,"automount":true,"name":"flux-operator"}
create: false
automount: true
name: "flux-operator"

Choose a reason for hiding this comment

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

high

The default values for the healthcheck service account are problematic. With create: false, the chart relies on a flux-operator service account being present in the release namespace, which is not guaranteed and can lead to deployment failures. It's better and more secure to create a dedicated service account for the healthcheck by default. This change, along with the suggested changes to serviceaccount.yaml and healthcheck.yaml, will make the feature work correctly by default.

  serviceAccount: # @schema default: {"create":true,"automount":true,"name":""}
    create: true
    automount: true
    name: ""

Copy link
Contributor

@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: 4

♻️ Duplicate comments (1)
packages/system/fluxcd/charts/flux-instance/values.schema.json (1)

219-223: Hard-coded ServiceAccount name leaks into schema defaults

The default block still pins name: "flux-operator", conflicting with the description that it defaults to the release name.
This should be left empty ("") or removed so that chart logic, not the schema, decides the actual default.

Aligning the schema with the proposed change in values.yaml will keep validation and rendered output consistent.

🧹 Nitpick comments (3)
packages/system/fluxcd-operator/charts/flux-operator/templates/crds.yaml (1)

88-97: Consider adding a defensive validation rule for empty strings
size is optional, but if a user sets it explicitly to an empty string the CRD will reject the object because the empty value is not part of the enum. In practice, Helm often injects "" when values are left unset. The accompanying instance.yaml template strips empty strings, but a user creating the CR directly (kubectl-apply) could hit this trap.

A tiny CEL validation such as rule: self == '' || ['small','medium','large'].contains(self) would allow the empty string while still constraining values, giving a smoother UX.

packages/system/fluxcd/charts/flux-instance/templates/instance.yaml (1)

27-32: cluster: block – safer indentation & less aggressive trimming

Using {{- on both range and if removes all leading whitespace and the newline after cluster:.
When at least one key is rendered the YAML is still valid, but if the list is empty the output becomes cluster: without a trailing space or newline – technically valid but untidy and easy to miss during reviews.
A more idiomatic Helm pattern is to leave the newline in place and indent the rendered keys with nindent.

-  {{- range $key, $value := .Values.instance.cluster }}
-  {{- if not (and (kindIs "string" $value) (eq $value "")) }}
-  {{ $key }}: {{ $value }}
-  {{- end }}
-  {{- end }}
+  {{- range $key, $value := .Values.instance.cluster }}
+  {{- if not (and (kindIs "string" $value) (eq $value "")) }}
+{{ printf "%s: %v" $key $value | nindent 4 }}
+  {{- end }}
+  {{- end }}

This keeps the template readable, avoids blank-line trimming surprises and guarantees correct indentation.

packages/system/fluxcd/charts/flux-instance/README.md (1)

40-42: Table rows contain bare URLs – markdown-lint MD034

markdownlint flagged a bare URL in this block.
Wrapping URLs in angle brackets or link syntax suppresses the warning and renders consistently.

-| instance.cluster | object | `{"domain":"cluster.local", ... }` | Cluster https://fluxcd.control-plane.io/operator/fluxinstance/#cluster-configuration |
+| instance.cluster | object | `{"domain":"cluster.local", ... }` | Cluster <https://fluxcd.control-plane.io/operator/fluxinstance/#cluster-configuration> |

Minor, but it keeps docs lint-clean.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cd80a73 and 6e119ba.

📒 Files selected for processing (12)
  • packages/system/fluxcd-operator/charts/flux-operator/Chart.yaml (2 hunks)
  • packages/system/fluxcd-operator/charts/flux-operator/README.md (2 hunks)
  • packages/system/fluxcd-operator/charts/flux-operator/templates/crds.yaml (1 hunks)
  • packages/system/fluxcd-operator/charts/flux-operator/values.schema.json (12 hunks)
  • packages/system/fluxcd-operator/charts/flux-operator/values.yaml (1 hunks)
  • packages/system/fluxcd/charts/flux-instance/Chart.yaml (2 hunks)
  • packages/system/fluxcd/charts/flux-instance/README.md (2 hunks)
  • packages/system/fluxcd/charts/flux-instance/templates/healthcheck.yaml (1 hunks)
  • packages/system/fluxcd/charts/flux-instance/templates/instance.yaml (1 hunks)
  • packages/system/fluxcd/charts/flux-instance/templates/serviceaccount.yaml (1 hunks)
  • packages/system/fluxcd/charts/flux-instance/values.schema.json (4 hunks)
  • packages/system/fluxcd/charts/flux-instance/values.yaml (3 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: the `./charts/robotlb/` directory in the hetzner-robotlb package contains vendored code, and the tea...
Learnt from: lllamnyp
PR: cozystack/cozystack#1233
File: packages/system/hetzner-robotlb/charts/robotlb/templates/deployment.yaml:33-35
Timestamp: 2025-07-23T09:15:09.658Z
Learning: The `./charts/robotlb/` directory in the hetzner-robotlb package contains vendored code, and the team generally avoids modifying vendored code to maintain clean separation from upstream dependencies.

Applied to files:

  • packages/system/fluxcd/charts/flux-instance/Chart.yaml
  • packages/system/fluxcd-operator/charts/flux-operator/Chart.yaml
📚 Learning: in helm templates, the `{{-` directive chomps all leading whitespace including newlines back to the ...
Learnt from: lllamnyp
PR: cozystack/cozystack#1160
File: packages/system/hetzner-robotlb/charts/robotlb/templates/role.yaml:6-8
Timestamp: 2025-07-11T06:28:13.696Z
Learning: In Helm templates, the `{{-` directive chomps all leading whitespace including newlines back to the previous content, so `{{- toYaml .Values.something | nindent 2 }}` will render correctly even with apparent indentation issues. However, for better style, it's cleaner to put the template directive on the same line as the parent key (e.g., `rules: {{- toYaml .Values.serviceAccount.permissions | nindent 2 }}`).

Applied to files:

  • packages/system/fluxcd/charts/flux-instance/templates/instance.yaml
📚 Learning: in cosi (container object storage interface), bucketaccessclass resources have fields like drivernam...
Learnt from: lllamnyp
PR: cozystack/cozystack#1239
File: packages/extra/seaweedfs/templates/external/cosi-bucket-class.yaml:3-15
Timestamp: 2025-07-24T13:21:17.388Z
Learning: In COSI (Container Object Storage Interface), BucketAccessClass resources have fields like driverName and authenticationType at the top level, not under a spec block. Only BucketClass resources require a spec block for fields like driverName and deletionPolicy.

Applied to files:

  • packages/system/fluxcd/charts/flux-instance/values.schema.json
📚 Learning: in the cozystack repository, the `readme-generator` tool removes enum contents from values.schema.js...
Learnt from: NickVolynkin
PR: cozystack/cozystack#1196
File: packages/apps/http-cache/Makefile:24-27
Timestamp: 2025-07-14T16:23:12.803Z
Learning: In the cozystack repository, the `readme-generator` tool removes enum contents from values.schema.json files during its operation. Therefore, when using readme-generator in Makefiles, any enum values need to be injected back into the schema using yq commands after readme-generator has run, not before.

Applied to files:

  • packages/system/fluxcd-operator/charts/flux-operator/values.schema.json
🪛 markdownlint-cli2 (0.17.2)
packages/system/fluxcd/charts/flux-instance/README.md

42-42: Bare URL used

(MD034, no-bare-urls)

🪛 YAMLlint (1.37.1)
packages/system/fluxcd/charts/flux-instance/templates/serviceaccount.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)


[warning] 10-10: wrong indentation: expected 2 but found 4

(indentation)


[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)

packages/system/fluxcd/charts/flux-instance/templates/healthcheck.yaml

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

🔇 Additional comments (10)
packages/system/fluxcd-operator/charts/flux-operator/templates/crds.yaml (1)

88-97: LGTM on schema addition
The size field is clearly documented, strongly typed with an enum, and does not alter existing required sets. Nice, non-breaking enhancement.

packages/system/fluxcd-operator/charts/flux-operator/values.yaml (1)

48-50: Double-check cluster capacity before raising CPU limits
Raising the default limit from 1000m to 2000m is fine for most production clusters but may evict existing deployments on small dev clusters. Please verify that your target environments can tolerate a 2-CPU limit, or consider exposing the change more prominently in the release notes.

packages/system/fluxcd-operator/charts/flux-operator/README.md (2)

3-3: README version badge updated correctly
The badge matches the chart and app versions (0.27.0).


59-60: Resource table stays in sync with values.yaml
CPU limit reflects the new 2000m default. Good catch keeping docs and code aligned.

packages/system/fluxcd/charts/flux-instance/Chart.yaml (1)

11-12: Version bump looks consistent across charts
Chart and appVersion are updated to 0.27.0, mirroring the operator chart. No other metadata drift detected.

Also applies to: 28-28

packages/system/fluxcd-operator/charts/flux-operator/Chart.yaml (1)

11-12: Consistent version alignment
appVersion and chart version now point to 0.27.0, matching the packaged binaries and README.

Also applies to: 28-28

packages/system/fluxcd/charts/flux-instance/templates/serviceaccount.yaml (1)

1-17: ServiceAccount name may be empty – double-check default value

metadata.name relies solely on .Values.healthcheck.serviceAccount.name.
If users enable create: true but omit a name the template will render an empty string, yielding an invalid manifest.

Consider falling back to a deterministic name:

-  name: {{ .Values.healthcheck.serviceAccount.name }}
+  name: {{ default (printf "%s-healthcheck" .Release.Name) .Values.healthcheck.serviceAccount.name }}

This guarantees a valid object and remains override-able.

packages/system/fluxcd/charts/flux-instance/templates/healthcheck.yaml (1)

25-33: podSecurityContext block – nil-safe rendering

with renders nothing when the map is empty, but .Values.healthcheck.podSecurityContext defaults to {} which is truthy, resulting in an empty securityContext: stanza (invalid YAML).

Guard with if instead:

-      {{- with .Values.healthcheck.podSecurityContext }}
+      {{- if .Values.healthcheck.podSecurityContext }}
+      {{- with .Values.healthcheck.podSecurityContext }}
         securityContext:
           {{- toYaml . | nindent 8 }}
       {{- end }}
+      {{- end }}

Prevents empty keys when users do not set fields.

⛔ Skipped due to learnings
Learnt from: lllamnyp
PR: cozystack/cozystack#1160
File: packages/system/hetzner-robotlb/charts/robotlb/templates/role.yaml:6-8
Timestamp: 2025-07-11T06:28:13.696Z
Learning: In Helm templates, the `{{-` directive chomps all leading whitespace including newlines back to the previous content, so `{{- toYaml .Values.something | nindent 2 }}` will render correctly even with apparent indentation issues. However, for better style, it's cleaner to put the template directive on the same line as the parent key (e.g., `rules: {{- toYaml .Values.serviceAccount.permissions | nindent 2 }}`).
packages/system/fluxcd-operator/charts/flux-operator/values.schema.json (1)

3-7: New top-level required keys – verify backward compatibility

Declaring resources and securityContext as required will break any existing consumer values files that relied on the chart defaults and omitted these keys. Please confirm that:

  1. values.yaml still defines both keys with sensible defaults, and
  2. Downstream charts that override a subset continue to render successfully.

If not, consider dropping them from required and rely on defaults instead.

packages/system/fluxcd/charts/flux-instance/values.yaml (1)

71-75: Empty image.tag may not resolve as intended

tag defaults to the empty string; the templates need to explicitly fall back to .Chart.AppVersion (or similar) or the rendered Job will reference :<empty> and fail to pull.

Please verify the template logic or provide a non-empty default here.

Comment on lines +29 to +33
serviceAccountName: {{ .Values.healthcheck.serviceAccount.name }}
{{- with .Values.healthcheck.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

ServiceAccount coupling – ensure name mirrors SA template fallback

serviceAccountName is hard-wired to .Values.healthcheck.serviceAccount.name.
If the earlier advice to default the name is applied, mirror the same logic here to avoid dangling references.

-      serviceAccountName: {{ .Values.healthcheck.serviceAccount.name }}
+      serviceAccountName: {{ default (printf "%s-healthcheck" .Release.Name) .Values.healthcheck.serviceAccount.name }}
📝 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
serviceAccountName: {{ .Values.healthcheck.serviceAccount.name }}
{{- with .Values.healthcheck.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ default (printf "%s-healthcheck" .Release.Name) .Values.healthcheck.serviceAccount.name }}
{{- with .Values.healthcheck.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
🤖 Prompt for AI Agents
In packages/system/fluxcd/charts/flux-instance/templates/healthcheck.yaml around
lines 29 to 33, the serviceAccountName is directly set to
.Values.healthcheck.serviceAccount.name without fallback logic. Update this to
use the same defaulting logic as the service account template to ensure the name
always resolves correctly and avoid dangling references by applying a
conditional or default value expression.

Comment on lines +118 to +124
"pullSecrets": {
"type": "array",
"uniqueItems": true,
"items": {
"type": "object"
}
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

pullSecrets item type is too vague

image.pullSecrets.items is declared as a generic object, but Kubernetes expects objects with a mandatory name field:

image:
  pullSecrets:
    - name: my-regcred

Tightening the schema helps catch user errors:

 "pullSecrets": {
   "type": "array",
   "uniqueItems": true,
   "items": {
-    "type": "object"
+    "type": "object",
+    "required": ["name"],
+    "properties": {
+      "name": { "type": "string" }
+    },
+    "additionalProperties": false
   }
 }
🤖 Prompt for AI Agents
In packages/system/fluxcd/charts/flux-instance/values.schema.json around lines
118 to 124, the pullSecrets array items are currently typed as generic objects,
but Kubernetes requires each item to have a mandatory name field. Update the
schema to specify that each item is an object with a required string property
"name" to enforce this constraint and improve validation accuracy.

Comment on lines +60 to +66
# Healthcheck job settings.
healthcheck:
# -- Enable post-install and post-upgrade health checks.
enabled: false
# -- Health check timeout in Go duration format.
timeout: 5m # @schema default: "5m"

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Timeout value could benefit from stronger validation

timeout is documented as a Go duration but validated only as a free-form string.
A malformed value (e.g., "5" or "5minutes") would pass schema validation yet make the Job crash at runtime.

Consider adding a simple RegExp (e.g., ^([0-9]+(ns|us|ms|s|m|h))+$) to the JSON-schema to fail early:

timeout: 5m # @schema pattern: "^([0-9]+(ns|us|ms|s|m|h))+$"
🤖 Prompt for AI Agents
In packages/system/fluxcd/charts/flux-instance/values.yaml around lines 60 to
66, the timeout field under healthcheck is currently validated only as a
free-form string, which can allow invalid Go duration formats that cause runtime
failures. To fix this, add a JSON-schema pattern annotation using a regular
expression like ^([0-9]+(ns|us|ms|s|m|h))+$ to the timeout field comment to
enforce proper Go duration format validation and catch errors early during
schema validation.

Comment on lines +88 to +93
# @ignore
serviceAccount: # @schema default: {"create":false,"automount":true,"name":"flux-operator"}
create: false
automount: true
name: "flux-operator"

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

ServiceAccount defaults are inconsistent with the documentation and may break the Job

The inline comment says the ServiceAccount name defaults to the release name, yet the default object hard-codes
name: "flux-operator" and create: false.
If the release is installed under a different name and no cluster-wide flux-operator ServiceAccount exists, the health-check Job will fail to start.

 serviceAccount:
-  create: false
-  automount: true
-  name: "flux-operator"
+# Either create one, or default to the Helm release name for backwards-compat
+  create: true             # safer default
+  automount: true
+  # name will default to .Release.Name in the template when empty
+  name: ""

Tagging create: true and leaving name empty delegates the actual name decision to the template logic while guaranteeing the SA is present.
Please align the defaults here with the template behaviour (or vice-versa) to avoid runtime failures.

📝 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
# @ignore
serviceAccount: # @schema default: {"create":false,"automount":true,"name":"flux-operator"}
create: false
automount: true
name: "flux-operator"
# @ignore
serviceAccount: # @schema default: {"create":false,"automount":true,"name":"flux-operator"}
# Either create one, or default to the Helm release name for backwards-compat
create: true # safer default
automount: true
# name will default to .Release.Name in the template when empty
name: ""
🤖 Prompt for AI Agents
In packages/system/fluxcd/charts/flux-instance/values.yaml around lines 88 to
93, the serviceAccount defaults hard-code the name as "flux-operator" and set
create to false, which conflicts with the documentation stating the name
defaults to the release name. To fix this, set create to true and leave the name
field empty so the template logic can assign the correct ServiceAccount name
based on the release, ensuring the ServiceAccount is created and preventing
runtime failures of the health-check Job.

Copy link
Member

@kvaps kvaps left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@kvaps kvaps merged commit a91e829 into cozystack:main Aug 7, 2025
9 of 11 checks passed
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