provider-helm icon indicating copy to clipboard operation
provider-helm copied to clipboard

Update loop when chart version is increased through spec.forProvider.chart.url

Open Feggah opened this issue 2 years ago • 1 comments

What happened?

  • When you change the chart version of the Release through the field spec.forProvider.chart.url (not using spec.forProvider.chart.version), the Release controller tries to update the Release in every reconcile.

How can we reproduce it?

  1. Apply the ProviderConfig in examples/provider-config/provider-config-incluster.yaml
  2. Apply the Release below:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
metadata:
  name: sample
spec:
  forProvider:
    chart:
      name: sample
      url: https://github.com/Feggah/chart-sample/releases/download/sample-0.3.0/sample-0.3.0.tgz
    namespace: default
    values:
      name: sample
    wait: true
  providerConfigRef:
    name: helm-provider

  1. Then, update the Release manifest to the specified below and kubectl apply it:
apiVersion: helm.crossplane.io/v1beta1
kind: Release
metadata:
  name: sample
spec:
  forProvider:
    chart:
      name: sample
      url: https://github.com/Feggah/chart-sample/releases/download/sample-0.4.0/sample-0.4.0.tgz
    namespace: default
    values:
      name: test
    wait: true
  providerConfigRef:
    name: helm-provider

Error cause

The update-loop is triggered by the IsUpToDate function, which returns false in every reconcile. The offending lines are https://github.com/crossplane-contrib/provider-helm/blob/176aa6812860e95712ea7aecd541a564bc839b14/pkg/controller/release/observe.go#L82-L84

The .Version field is always different, because the in.Chart.Version is 0.3.0 and the ocm.Version is 0.4.0.

Probably, the in.Chart.Version is being "imported" just in the first reconcile loop, when its value is empty (""). When we updated the url in the manifest, the in.Chart.Version wasn't updated as well.

The offending lines possibly are https://github.com/crossplane-contrib/provider-helm/blob/176aa6812860e95712ea7aecd541a564bc839b14/pkg/controller/release/release.go#L316-L321

Hypothesis

The versions specified in the spec.forProvider.chart.url and spec.forProvider.chart.version should change together, because if they are different and not empty, this update loop behavior will happen again.

What environment did it happen in?

Crossplane version: 1.6.1 Provider-helm version: 0.10.0

Feggah avatar Jul 05 '22 13:07 Feggah

Currently, you can change the versions in the manifest at the same time, and then the controller will behave as expected.

So, based on the example above, in the step [3] you should apply this manifest:

apiVersion: helm.crossplane.io/v1beta1
kind: Release
metadata:
  name: sample
spec:
  forProvider:
    chart:
      name: sample
      url: https://github.com/Feggah/chart-sample/releases/download/sample-0.4.0/sample-0.4.0.tgz
      version: "0.4.0"
    namespace: default
    values:
      name: test
    wait: true
  providerConfigRef:
    name: helm-provider

Feggah avatar Jul 05 '22 13:07 Feggah