minor: fix drift detection script parsing broken by Flux log format change

What does this MR do and why?

While looking at the nightly CI runs, I noticed that the helmrelease-identify-drift-corrections.sh script was broken by a Flux log format change (see https://gitlab.com/sylva-projects/sylva-core/-/jobs/14865677786 for reference). Newer Flux versions no longer include a "HelmRelease":{"name":"..."} field in "running 'correct cluster drift'" log lines, so the sed pattern used to extract HelmRelease names stopped matching. This caused entire raw log lines to be passed through and word-split, flooding the output with garbage entries and bad array subscript error.

This MR is fixing the sed pattern to use "name":"...","reconcileID": which is present in both old and new Flux log formats, and suppress non-matching lines with -n/p, while guarding ${ACTION_ARRAY[-1]} access against empty arrays.

Tested locally in my DEV environment.

Click to see the output

./tools/helmrelease-identify-drift-corrections.sh
📝 Checking Helm controller logs for drift...
🚨 Drift detected in the following components:
   🔹 keycloak-user-management
      🔄 [2026-06-16T06:18:18.216Z] Role/keycloak/grafanaadmin-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaeditor-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaviewer-role changed (0 additions, 1 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"keycloak-user-management","uid":"687dd905-9aae-48b3-b506-fa47afd3b6c7","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1202897"},"reason":"DriftDetected}
      🔄 [2026-06-16T06:21:14.799Z] Role/keycloak/grafanaadmin-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaeditor-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaviewer-role changed (0 additions, 1 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"keycloak-user-management","uid":"687dd905-9aae-48b3-b506-fa47afd3b6c7","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1212383"},"reason":"DriftDetected}
      🔄 [2026-06-16T06:21:15.697Z] Role/keycloak/grafanaadmin-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaeditor-role changed (0 additions, 1 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"keycloak-user-management","uid":"687dd905-9aae-48b3-b506-fa47afd3b6c7","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1212436"},"reason":"DriftDetected}
      🔄 [2026-06-16T06:21:16.070Z] Role/keycloak/grafanaviewer-role changed (0 additions, 1 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"keycloak-user-management","uid":"687dd905-9aae-48b3-b506-fa47afd3b6c7","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1212436"},"reason":"DriftDetected}
      🔄 [2026-06-16T06:22:17.828Z] Role/keycloak/grafanaadmin-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaeditor-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaviewer-role changed (0 additions, 1 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"keycloak-user-management","uid":"687dd905-9aae-48b3-b506-fa47afd3b6c7","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1212508"},"reason":"DriftDetected}
      🔧 Patches applied:
        - [2026-06-16T06:18:18.215Z] Role/keycloak/grafanaadmin-role ->
          [
            {
              "value": "sylva/grafanaadmin",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:18:18.215Z] Role/keycloak/grafanaeditor-role ->
          [
            {
              "value": "sylva/grafanaeditor",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:18:18.215Z] Role/keycloak/grafanaviewer-role ->
          [
            {
              "value": "sylva/grafanaviewer",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:21:14.798Z] Role/keycloak/grafanaadmin-role ->
          [
            {
              "value": "sylva/grafanaadmin",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:21:14.798Z] Role/keycloak/grafanaeditor-role ->
          [
            {
              "value": "sylva/grafanaeditor",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:21:14.798Z] Role/keycloak/grafanaviewer-role ->
          [
            {
              "value": "sylva/grafanaviewer",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:21:15.696Z] Role/keycloak/grafanaadmin-role ->
          [
            {
              "value": "sylva/grafanaadmin",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:21:15.696Z] Role/keycloak/grafanaeditor-role ->
          [
            {
              "value": "sylva/grafanaeditor",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:21:16.069Z] Role/keycloak/grafanaviewer-role ->
          [
            {
              "value": "sylva/grafanaviewer",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:22:17.827Z] Role/keycloak/grafanaadmin-role ->
          [
            {
              "value": "sylva/grafanaadmin",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:22:17.827Z] Role/keycloak/grafanaeditor-role ->
          [
            {
              "value": "sylva/grafanaeditor",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]
        - [2026-06-16T06:22:17.827Z] Role/keycloak/grafanaviewer-role ->
          [
            {
              "value": "sylva/grafanaviewer",
              "op": "replace",
              "path": "/metadata/annotations/crossplane.io~1external-name"
            }
          ]

   🔹 sylva-units
      🔄 [2026-06-16T06:15:21.734Z] Kustomization/sylva-system/flux-system changed (0 additions, 2 changes, 0 removals)\nKustomization/sylva-system/sylva-units-operator changed (0 additions, 2 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"sylva-units","uid":"978a8903-4223-40e2-a6e5-093f47efe8db","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1195945"},"reason":"DriftDetected}
      🔧 Patches applied:
        - [2026-06-16T06:15:21.733Z] Kustomization/sylva-system/flux-system ->
          [
            {
              "value": "24h",
              "op": "replace",
              "path": "/spec/interval"
            },
            {
              "value": "1m",
              "op": "replace",
              "path": "/spec/retryInterval"
            }
          ]
        - [2026-06-16T06:15:21.733Z] Kustomization/sylva-system/sylva-units-operator ->
          [
            {
              "value": "24h",
              "op": "replace",
              "path": "/spec/interval"
            },
            {
              "value": "1m",
              "op": "replace",
              "path": "/spec/retryInterval"
            }
          ]


❌ Unexpected drift detected in:
   🔹 keycloak-user-management
      - 5 drift events (latest: 2026-06-16T06:22:17.828Z)
        🔄 [2026-06-16T06:18:18.216Z] Role/keycloak/grafanaadmin-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaeditor-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaviewer-role changed (0 additions, 1 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"keycloak-user-management","uid":"687dd905-9aae-48b3-b506-fa47afd3b6c7","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1202897"},"reason":"DriftDetected}
        🔄 [2026-06-16T06:21:14.799Z] Role/keycloak/grafanaadmin-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaeditor-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaviewer-role changed (0 additions, 1 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"keycloak-user-management","uid":"687dd905-9aae-48b3-b506-fa47afd3b6c7","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1212383"},"reason":"DriftDetected}
        🔄 [2026-06-16T06:21:15.697Z] Role/keycloak/grafanaadmin-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaeditor-role changed (0 additions, 1 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"keycloak-user-management","uid":"687dd905-9aae-48b3-b506-fa47afd3b6c7","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1212436"},"reason":"DriftDetected}
        🔄 [2026-06-16T06:21:16.070Z] Role/keycloak/grafanaviewer-role changed (0 additions, 1 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"keycloak-user-management","uid":"687dd905-9aae-48b3-b506-fa47afd3b6c7","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1212436"},"reason":"DriftDetected}
        🔄 [2026-06-16T06:22:17.828Z] Role/keycloak/grafanaadmin-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaeditor-role changed (0 additions, 1 changes, 0 removals)\nRole/keycloak/grafanaviewer-role changed (0 additions, 1 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"keycloak-user-management","uid":"687dd905-9aae-48b3-b506-fa47afd3b6c7","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1212508"},"reason":"DriftDetected}
   🔹 sylva-units
      - 1 drift events (latest: 2026-06-16T06:15:21.734Z)
        🔄 [2026-06-16T06:15:21.734Z] Kustomization/sylva-system/flux-system changed (0 additions, 2 changes, 0 removals)\nKustomization/sylva-system/sylva-units-operator changed (0 additions, 2 changes, 0 removals)","type":"Warning","object":{"kind":"HelmRelease","namespace":"sylva-system","name":"sylva-units","uid":"978a8903-4223-40e2-a6e5-093f47efe8db","apiVersion":"helm.toolkit.fluxcd.io/v2","resourceVersion":"1195945"},"reason":"DriftDetected}

CI configuration

Below you can choose test deployment variants to run in this MR's CI.

Click to open to CI configuration

Legend:

Icon Meaning Available values
☁️ Infra Provider capd, capo, capm3
🚀 Bootstrap Provider kubeadm (alias kadm), rke2, okd, ck8s
🐧 Node OS ubuntu, suse, na, leapmicro
🛠️ Deployment Options Deployment option list and description
🎬 Pipeline Scenarios Available scenario list and description
🟢 Enabled units Any available units name, by default apply to management and workload cluster. Can be prefixed by mgmt: or wkld: to be applied only to a specific cluster type
🔴 Disabled units Any available units name, by default apply to management and workload cluster. Can be prefixed by mgmt: or wkld: to be applied only to a specific cluster type
🏗️ Target platform Can be used to select specific deployment environment Available platform list and description
Pipeline control autorun, manual or blocking. Can be used to override global config and start a deployment pipeline the required way
  • 🎬 preview ☁️ capd 🚀 kadm 🐧 ubuntu

  • 🎬 preview ☁️ capo 🚀 rke2 🐧 suse

  • 🎬 preview ☁️ capm3 🚀 rke2 🐧 ubuntu

  • ☁️ capd 🚀 kadm 🛠️ light-deploy 🐧 ubuntu

  • ☁️ capd 🚀 rke2 🛠️ light-deploy 🐧 suse

  • ☁️ capo 🚀 rke2 🐧 suse

  • ☁️ capo 🚀 rke2 🐧 leapmicro

  • ☁️ capo 🚀 kadm 🐧 ubuntu

  • ☁️ capo 🚀 kadm 🐧 ubuntu 🟢 neuvector,mgmt:harbor

  • ☁️ capo 🚀 rke2 🎬 rolling-update 🛠️ ha 🐧 ubuntu

  • ☁️ capo 🚀 kadm 🎬 wkld-k8s-upgrade 🐧 ubuntu

  • ☁️ capo 🚀 rke2 🎬 rolling-update-no-wkld 🛠️ ha 🐧 suse

  • ☁️ capo 🚀 rke2 🎬 sylva-upgrade 🛠️ ha 🐧 ubuntu

  • ☁️ capo 🚀 rke2 🎬 sylva-upgrade-from-1.6.x 🛠️ ha,misc 🐧 ubuntu

  • ☁️ capo 🚀 rke2 🛠️ ha,misc 🐧 ubuntu

  • ☁️ capo 🚀 rke2 🛠️ misc 🐧 ubuntu 🟢 mgmt:harbor 🔴 neuvector

  • ☁️ capo 🚀 rke2 🛠️ ha,misc,openbao🐧 suse

  • ☁️ capo 🚀 rke2 🐧 suse 🎬 upgrade-from-prev-tag

  • ☁️ capm3 🚀 rke2 🐧 suse

  • ☁️ capm3 🚀 kadm 🐧 ubuntu

  • ☁️ capm3 🚀 ck8s 🐧 ubuntu

  • ☁️ capm3 🚀 kadm 🎬 rolling-update-no-wkld 🛠️ ha,misc 🐧 ubuntu

  • ☁️ capm3 🚀 rke2 🎬 wkld-k8s-upgrade 🛠️ ha 🐧 suse

  • ☁️ capm3 🚀 kadm 🎬 rolling-update 🛠️ ha 🐧 ubuntu

  • ☁️ capm3 🚀 rke2 🎬 upgrade-from-prev-release-branch 🛠️ ha 🐧 suse

  • ☁️ capm3 🚀 rke2 🛠️ misc,ha 🐧 suse

  • ☁️ capm3 🚀 rke2 🎬 sylva-upgrade 🛠️ ha,misc 🐧 suse

  • ☁️ capm3 🚀 kadm 🎬 rolling-update 🛠️ ha 🐧 suse

  • ☁️ capm3 🚀 ck8s 🎬 rolling-update 🛠️ ha 🐧 ubuntu

  • ☁️ capm3 🚀 rke2|okd 🎬 no-update 🐧 ubuntu|na

  • ☁️ capm3 🚀 rke2 🐧 suse 🎬 upgrade-from-release-1.5

  • ☁️ capm3 🚀 rke2 🐧 suse 🎬 upgrade-to-main

Global config for deployment pipelines

  • autorun pipelines
  • allow failure on pipelines
  • record sylvactl events

Notes:

  • Enabling autorun will make deployment pipelines to be run automatically without human interaction
  • Disabling allow failure will make deployment pipelines mandatory for pipeline success.
  • if both autorun and allow failure are disabled, deployment pipelines will need manual triggering but will be blocking the pipeline

Be aware: after configuration change, pipeline is not triggered automatically. Please run it manually (by clicking the run pipeline button in Pipelines tab) or push new code.

Edited by Dragos Gerea

Merge request reports

Loading