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

Track changes in .spec.postRenderers #965

Merged
merged 4 commits into from
May 7, 2024
Merged

Track changes in .spec.postRenderers #965

merged 4 commits into from
May 7, 2024

Conversation

souleb
Copy link
Member

@souleb souleb commented May 5, 2024

fix #964

@souleb souleb marked this pull request as draft May 5, 2024 19:54
@souleb souleb marked this pull request as ready for review May 6, 2024 12:20
@souleb souleb force-pushed the fix-964 branch 2 times, most recently from c02e31e to c39ae31 Compare May 6, 2024 15:05
@souleb
Copy link
Member Author

souleb commented May 7, 2024

I have tested the last code on a kind cluster with an existing HR on v1beta2

Warning: v2beta2 HelmRelease is deprecated, upgrade to v2
Name:         podinfo-template
Namespace:    default
API Version:  helm.toolkit.fluxcd.io/v2beta2
Kind:         HelmRelease
Metadata:
  Generation:        1
Spec:
  Chart Ref:
    Kind:    HelmChart
    Name:    podinfo
  Interval:  5m
  Post Renderers:
    Kustomize:
      Patches:
        Patch:  - op: add
  path: /metadata/annotations/hello
  value: world2

        Target:
          Kind:     Deployment
          Name:     podinfo-template
          Version:  v1
  Test:
    Enable:  true
  Values:
    Replica Count:  2
Status:
  Conditions:
    Last Transition Time:  2024-05-07T08:23:07Z
    Message:               Helm test succeeded for release default/podinfo-template.v1 with chart [email protected]: 3 test hooks completed successfully
    Observed Generation:   1
    Reason:                TestSucceeded
    Status:                True
    Type:                  Ready
    Last Transition Time:  2024-05-07T08:22:59Z
    Message:               Helm install succeeded for release default/podinfo-template.v1 with chart [email protected]
    Observed Generation:   1
    Reason:                InstallSucceeded
    Status:                True
    Type:                  Released
    Last Transition Time:  2024-05-07T08:23:07Z
    Message:               Helm test succeeded for release default/podinfo-template.v1 with chart [email protected]: 3 test hooks completed successfully
    Observed Generation:   1
    Reason:                TestSucceeded
    Status:                True
    Type:                  TestSuccess
  History:
    Chart Name:      podinfo
    Chart Version:   6.6.2
    Config Digest:   sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
    Digest:          sha256:11006d53cba942b73d124414f755869565730d24a36480b3208948c60275597d
    First Deployed:  2024-05-07T08:22:55Z
    Last Deployed:   2024-05-07T08:22:55Z
    Name:            podinfo-template
    Namespace:       default
    Status:          deployed
    Test Hooks:
      podinfo-template-grpc-test-kj0hv:
        Last Completed:  2024-05-07T08:23:02Z
        Last Started:    2024-05-07T08:23:00Z
        Phase:           Succeeded
      Podinfo - Template - Jwt - Test - Gufwh:
        Last Completed:  2024-05-07T08:23:05Z
        Last Started:    2024-05-07T08:23:02Z
        Phase:           Succeeded
      podinfo-template-service-test-aumr6:
        Last Completed:           2024-05-07T08:23:07Z
        Last Started:             2024-05-07T08:23:05Z
        Phase:                    Succeeded
    Version:                      1
  Last Attempted Config Digest:   sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
  Last Attempted Generation:      1
  Last Attempted Release Action:  install
  Last Attempted Revision:        6.6.2
  Observed Generation:            1
  Storage Namespace:              default
Events:
  Type    Reason            Age   From             Message
  ----    ------            ----  ----             -------
  Normal  InstallSucceeded  102s  helm-controller  Helm install succeeded for release default/podinfo-template.v1 with chart [email protected]
  Normal  TestSucceeded     94s   helm-controller  Helm test succeeded for release default/podinfo-template.v1 with chart [email protected]: 3 test hooks completed successfully

Existing HelmRelease should adopt PostRenderers status without upgrade

Warning: v2beta2 HelmRelease is deprecated, upgrade to v2
Name:         podinfo-template
Namespace:    default
API Version:  helm.toolkit.fluxcd.io/v2beta2
Kind:         HelmRelease
Metadata:
  Generation:        1
Spec:
  Chart Ref:
    Kind:    HelmChart
    Name:    podinfo
  Interval:  5m
  Post Renderers:
    Kustomize:
      Patches:
        Patch:  - op: add
  path: /metadata/annotations/hello
  value: world2

        Target:
          Kind:     Deployment
          Name:     podinfo-template
          Version:  v1
  Test:
    Enable:  true
  Values:
    Replica Count:  2
Status:
  Conditions:
    Last Transition Time:  2024-05-07T08:23:07Z
    Message:               Helm test succeeded for release default/podinfo-template.v1 with chart [email protected]: 3 test hooks completed successfully
    Observed Generation:   1
    Reason:                TestSucceeded
    Status:                True
    Type:                  Ready
    Last Transition Time:  2024-05-07T08:22:59Z
    Message:               Helm install succeeded for release default/podinfo-template.v1 with chart [email protected]
 1 hr.yaml +                                                                                                                                                                                              X
    Observed Generation:   1
    Reason:                InstallSucceeded
    Status:                True
    Type:                  Released
    Last Transition Time:  2024-05-07T08:23:07Z
    Message:               Helm test succeeded for release default/podinfo-template.v1 with chart [email protected]: 3 test hooks completed successfully
    Observed Generation:   1
    Reason:                TestSucceeded
    Status:                True
    Type:                  TestSuccess
  History:
    Chart Name:      podinfo
    Chart Version:   6.6.2
    Config Digest:   sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
    Digest:          sha256:11006d53cba942b73d124414f755869565730d24a36480b3208948c60275597d
    First Deployed:  2024-05-07T08:22:55Z
    Last Deployed:   2024-05-07T08:22:55Z
    Name:            podinfo-template
    Namespace:       default
    Status:          deployed
...
    Version:                             1
  Last Attempted Config Digest:          sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
  Last Attempted Generation:             1
  Last Attempted Post Renderers Digest:  sha256:0801f4f2fec3b08c5c25664bbcba357334dfae9aa6f4d59813079749d3acc154
  Last Attempted Release Action:         install
  Last Attempted Revision:               6.6.2
  Last Handled Reconcile At:             2024-05-07T10:24:53.300426+02:00
  Observed Generation:                   1
  Storage Namespace:                     default

Change to PostRenderers should trigger an upgrade

Warning: v2beta2 HelmRelease is deprecated, upgrade to v2
Name:         podinfo-template
Namespace:    default
API Version:  helm.toolkit.fluxcd.io/v2beta2
Kind:         HelmRelease
Metadata:
  Generation:        2
Spec:
  Chart Ref:
    Kind:    HelmChart
    Name:    podinfo
  Interval:  5m
  Post Renderers:
    Kustomize:
      Patches:
        Patch:  - op: add
  path: /metadata/annotations/hello
  value: world

        Target:
          Kind:     Deployment
          Name:     podinfo-template
          Version:  v1
  Test:
    Enable:  true
  Values:
    Replica Count:  2
Status:
  Conditions:
    Last Transition Time:  2024-05-07T08:26:38Z
    Message:               Helm test succeeded for release default/podinfo-template.v2 with chart [email protected]: 3 test hooks completed successfully
    Observed Generation:   2
    Reason:                TestSucceeded
    Status:                True
    Type:                  Ready
    Last Transition Time:  2024-05-07T08:26:20Z
    Message:               Helm upgrade succeeded for release default/podinfo-template.v2 with chart [email protected]
    Observed Generation:   2
    Reason:                UpgradeSucceeded
    Status:                True
    Type:                  Released
    Last Transition Time:  2024-05-07T08:26:38Z
    Message:               Helm test succeeded for release default/podinfo-template.v2 with chart [email protected]: 3 test hooks completed successfully
    Observed Generation:   2
    Reason:                TestSucceeded
    Status:                True
    Type:                  TestSuccess
  ...
  Last Attempted Config Digest:          sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
  Last Attempted Generation:             2
  Last Attempted Post Renderers Digest:  sha256:fd5c051933da29da53f8f5d34c5b89247b88899153b84807cda11b1b9a58f44f
  Last Attempted Release Action:         upgrade
  Last Attempted Revision:               6.6.2
  Last Handled Reconcile At:             2024-05-07T10:26:23.760449+02:00
  Observed Generation:                   2
  Storage Namespace:                     default
Events:
  Type    Reason            Age    From             Message
  ----    ------            ----   ----             -------
  Normal  InstallSucceeded  3m44s  helm-controller  Helm install succeeded for release default/podinfo-template.v1 with chart [email protected]
  Normal  TestSucceeded     3m36s  helm-controller  Helm test succeeded for release default/podinfo-template.v1 with chart [email protected]: 3 test hooks completed successfully
  Normal  UpgradeSucceeded  23s    helm-controller  Helm upgrade succeeded for release default/podinfo-template.v2 with chart [email protected]
  Normal  TestSucceeded     5s     helm-controller  Helm test succeeded for release default/podinfo-template.v2 with chart [email protected]: 3 test hooks completed successfully

Removing PostRenderers should trigger an update and unset `Last Attempted Post Renderers Digest``

Warning: v2beta2 HelmRelease is deprecated, upgrade to v2
Name:         podinfo-template
Namespace:    default
API Version:  helm.toolkit.fluxcd.io/v2beta2
Kind:         HelmRelease
Metadata:
  Generation:        3
Spec:
  Chart Ref:
    Kind:    HelmChart
    Name:    podinfo
  Interval:  5m
  Test:
    Enable:  true
  Values:
    Replica Count:  2
Status:
  Conditions:
    Last Transition Time:  2024-05-07T08:28:04Z
    Message:               Helm test succeeded for release default/podinfo-template.v3 with chart [email protected]: 3 test hooks completed successfully
    Observed Generation:   3
    Reason:                TestSucceeded
    Status:                True
    Type:                  Ready
    Last Transition Time:  2024-05-07T08:27:47Z
    Message:               Helm upgrade succeeded for release default/podinfo-template.v3 with chart [email protected]
    Observed Generation:   3
    Reason:                UpgradeSucceeded
    Status:                True
    Type:                  Released
    Last Transition Time:  2024-05-07T08:28:04Z
    Message:               Helm test succeeded for release default/podinfo-template.v3 with chart [email protected]: 3 test hooks completed successfully
    Observed Generation:   3
    Reason:                TestSucceeded
    Status:                True
    Type:                  TestSuccess
...
  Last Attempted Config Digest:   sha256:e15c415d62760896bd8bec192a44c5716dc224db9e0fc609b9ac14718f8f9e56
  Last Attempted Generation:      3
  Last Attempted Release Action:  upgrade
  Last Attempted Revision:        6.6.2
  Last Handled Reconcile At:      2024-05-07T10:27:52.283029+02:00
  Observed Generation:            3
  Storage Namespace:              default
Events:
  Type    Reason            Age    From             Message
  ----    ------            ----   ----             -------
  Normal  InstallSucceeded  5m13s  helm-controller  Helm install succeeded for release default/podinfo-template.v1 with chart [email protected]
  Normal  TestSucceeded     5m5s   helm-controller  Helm test succeeded for release default/podinfo-template.v1 with chart [email protected]: 3 test hooks completed successfully
  Normal  UpgradeSucceeded  112s   helm-controller  Helm upgrade succeeded for release default/podinfo-template.v2 with chart [email protected]
  Normal  TestSucceeded     94s    helm-controller  Helm test succeeded for release default/podinfo-template.v2 with chart [email protected]: 3 test hooks completed successfully
  Normal  UpgradeSucceeded  25s    helm-controller  Helm upgrade succeeded for release default/podinfo-template.v3 with chart [email protected]
  Normal  TestSucceeded     8s     helm-controller  Helm test succeeded for release default/podinfo-template.v3 with chart [email protected]: 3 test hooks completed successfully

Copy link
Member

@stefanprodan stefanprodan 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 @souleb 🏅

@stefanprodan stefanprodan changed the title fix: detect changes in spec.postRenderers Track changes in .spec. postRenderers May 7, 2024
@stefanprodan stefanprodan changed the title Track changes in .spec. postRenderers Track changes in .spec.postRenderers May 7, 2024
@stefanprodan stefanprodan added the area/kustomize Kustomize (post-rendering) related issues and pull requests label May 7, 2024
internal/controller/helmrelease_controller.go Outdated Show resolved Hide resolved
internal/postrender/build.go Outdated Show resolved Hide resolved
internal/reconcile/reconcile.go Outdated Show resolved Hide resolved
This implementation update `.status.ObervedPostRenderersDigest` after a
successful reconciliation if `spec.postRenderers` is not nil.

Changes to `spec.postRenderers` are detected for `deployed` releases.
`Failed` and `Uninstalled` releases are detected earlier in the
reconciliation process.

Signed-off-by: Soule BA <[email protected]>
internal/controller/helmrelease_controller_test.go Outdated Show resolved Hide resolved
internal/reconcile/release.go Outdated Show resolved Hide resolved
internal/reconcile/state.go Show resolved Hide resolved
docs/spec/v2/helmreleases.md Outdated Show resolved Hide resolved
@souleb souleb force-pushed the fix-964 branch 2 times, most recently from 24c87aa to 837a592 Compare May 7, 2024 13:35
@souleb souleb force-pushed the fix-964 branch 2 times, most recently from 6ac9479 to f47ddad Compare May 7, 2024 14:31
Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

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

LGTM!

@souleb souleb merged commit 9da5599 into main May 7, 2024
6 checks passed
@souleb souleb deleted the fix-964 branch May 7, 2024 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kustomize Kustomize (post-rendering) related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changes in postRenderers are ingored
4 participants