fluxcd-community / helm-charts

Community maintained Helm charts for Flux
Apache License 2.0
123 stars 76 forks source link

Helm release is deleted if the source of the Helm chart has changed. #234

Closed Subetov closed 2 hours ago

Subetov commented 2 hours ago

Describe the bug a clear and concise description of what the bug is.

Helm release is deleted if the source of the Helm chart has changed. (releaseName is set) Which in my opinion is a terrible bug (unexpected behavior). Because Helm itself behaves differently.

Let's imagine that I installed a chart with a database (a critical element of the system), but had to fork the upstream chart to urgently fix a critical bug. I change spec.chart.specюc.hart of HelmRelease and the operator completely deletes the previous Helm release and installs everything again (there will be revision 1).

{"level":"info","ts":"2024-10-27T14:10:16.521Z","msg":"release target configuration changed (chart name): running uninstall for current release","controller":"helmrelease","controllerGroup":"helm.toolkit.fluxcd.io","controllerKind":"HelmRelease","HelmRelease":{"name":"hello-world","namespace":"test"},"namespace":"test","name":"hello-world","reconcileID":"4140ba43-337c-430c-aa51-f7713d07b252"}

What's your helm version?

v3.15.3

What's your kubectl version?

v1.30.3

What's the chart version?

2.14.0

What happened?

When only the chart source name was changed, the Helm release was removed and reinstalled.

{"level":"info","ts":"2024-10-27T14:10:16.521Z","msg":"release target configuration changed (chart name): running uninstall for current release","controller":"helmrelease","controllerGroup":"helm.toolkit.fluxcd.io","controllerKind":"HelmRelease","HelmRelease":{"name":"hello-world","namespace":"test"},"namespace":"test","name":"hello-world","reconcileID":"4140ba43-337c-430c-aa51-f7713d07b252"}

It would be great if there was at least an option to disable uninstall in such scenario

What you expected to happen?

When the name of the chart source is changed or the chart name changed in the repository, the Helm release is updated, not re-installed. (the revision version of helm release is increased) (releaseName is set)

How to reproduce it?

1) Install Flux2

helm upgrade -i flux2-controller fluxcd-community/flux2 -f values.yaml

2) Apply HelmRepository

cat <<EOF | kubectl apply -f -

apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
  name: gitlab
spec:
  interval: 5m0s
  provider: generic
  suspend: false
  timeout: 60s
  type: oci
  url: oci://registry-1.docker.io/subetov/
status: {}

EOF

3) Apply HR

cat <<EOF | kubectl apply -f -

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: hello-world
spec:
  chart:
    spec:
      chart: hello-world-chart-forked
      interval: 3m
      reconcileStrategy: ChartVersion
      sourceRef:
        kind: HelmRepository
        name: gitlab
      version: 0.1.1
  install:
    createNamespace: true
    remediation:
      retries: -1
  interval: 5m0s
  releaseName: hello-world
  storageNamespace: test
  suspend: false
  targetNamespace: test
  test: {}
  timeout: 5m0s

EOF

4) Change spec.chart.specюc.hart in HR and Apply

cat <<EOF | kubectl apply -f -

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: hello-world
spec:
  chart:
    spec:
      chart: hello-world-chart-forked-2
      interval: 3m
      reconcileStrategy: ChartVersion
      sourceRef:
        kind: HelmRepository
        name: gitlab
      version: 0.1.2
  install:
    createNamespace: true
    remediation:
      retries: -1
  interval: 5m0s
  releaseName: hello-world
  storageNamespace: test
  suspend: false
  targetNamespace: test
  test: {}
  timeout: 5m0s

EOF

Enter the changed values of values.yaml?

imageAutomationController:
  create: false

imageReflectionController:
  create: false

kustomizeController:
  create: false

notificationController:
  create: false

Enter the command that you execute and failing/misfunctioning.

1) Install Flux2 helm upgrade -i flux2-controller fluxcd-community/flux2 -f values.yaml 2) Apply HelmRepository

cat <<EOF | kubectl apply -f -

apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
  name: gitlab
spec:
  interval: 5m0s
  provider: generic
  suspend: false
  timeout: 60s
  type: oci
  url: oci://registry-1.docker.io/subetov/
status: {}

EOF

3) Apply HR

cat <<EOF | kubectl apply -f -

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: hello-world
spec:
  chart:
    spec:
      chart: hello-world-chart-forked
      interval: 3m
      reconcileStrategy: ChartVersion
      sourceRef:
        kind: HelmRepository
        name: gitlab
      version: 0.1.1
  install:
    createNamespace: true
    remediation:
      retries: -1
  interval: 5m0s
  releaseName: hello-world
  storageNamespace: test
  suspend: false
  targetNamespace: test
  test: {}
  timeout: 5m0s

EOF

4) Change spec.chart.specюc.hart in HR and Apply

cat <<EOF | kubectl apply -f -

apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
  name: hello-world
spec:
  chart:
    spec:
      chart: hello-world-chart-forked-2
      interval: 3m
      reconcileStrategy: ChartVersion
      sourceRef:
        kind: HelmRepository
        name: gitlab
      version: 0.1.2
  install:
    createNamespace: true
    remediation:
      retries: -1
  interval: 5m0s
  releaseName: hello-world
  storageNamespace: test
  suspend: false
  targetNamespace: test
  test: {}
  timeout: 5m0s

EOF

Anything else we need to know?

No response

Subetov commented 2 hours ago

Sorry, wrong repo, I'll open it in https://github.com/fluxcd/helm-controller