Skip to content

Bug Report: Helm Chart Helper Template Logic Error in reloader-namespaceSelector #1188

Description

@m-ammar

{{- if and .Values.reloader.watchGlobally .Values.reloader.namespaceSelector -}}

Bug Report: Helm Chart Helper Template Logic Error in reloader-namespaceSelector

Chart Version: 2.2.14
App Version: v1.4.19

Summary

The reloader-namespaceSelector helper template in templates/_helpers.tpl has contradictory logic between its comment and implementation, causing the --namespace-selector CLI flag to never be generated when watchGlobally: false.

Issue

File: templates/_helpers.tpl

Current Code:

{{/*
Create the namespace selector if it does not watch globally
*/}}
{{- define "reloader-namespaceSelector" -}}
{{- if and .Values.reloader.watchGlobally .Values.reloader.namespaceSelector -}}
    {{ .Values.reloader.namespaceSelector }}
{{- end -}}
{{- end -}}

Problem:

  • The comment states the function creates the namespace selector "if it does not watch globally"
  • The code implements the opposite: it requires watchGlobally: true
  • When watchGlobally: false and namespaceSelector is set, the CLI flag is not generated
  • When watchGlobally: true and namespaceSelector is set, the flag is correctly generated

Expected Behavior

One of the following should be true:

Option A (Restrict Mode):

if and (not .Values.reloader.watchGlobally) .Values.reloader.namespaceSelector
  • When watchGlobally: false, use namespaceSelector to limit to specific namespaces (restrictive by default)

Option B (Filter Mode):

  • Keep current implementation but fix the comment:
{{/*
Create the namespace selector when watching globally to filter namespaces
*/}}

Impact

Users cannot deploy Reloader with watchGlobally: false and namespace selectors as documented in values.yaml comments. The documented use case of "Comma separated list of k8s label selectors for namespaces selection" only works when watchGlobally: true, which contradicts intuitive user expectations.

Reproduction

# values-test.yaml
reloader:
  watchGlobally: false
  namespaceSelector: "app=myapp"
  deployment:
    replicas: 1
helm template reloader stakater/reloader --values values-test.yaml
# Expected: args contain "--namespace-selector="app=myapp""
# Actual: args do NOT contain the flag (empty)

Suggested Fix

Clarify intended behavior:

  1. Update comment to match code behavior, OR
  2. Update code to match comment: if and (not .Values.reloader.watchGlobally) .Values.reloader.namespaceSelector

The logical intent (based on parameter naming) suggests Option A is more correct: namespaceSelector should restrict scope when not watching globally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions