Skip to content

PWX-50095 | Fix nil labels issue for helm4#867

Open
hitesh-wani-px wants to merge 1 commit intopre-release-portworx-8.2.0from
hwani/PWX-50095
Open

PWX-50095 | Fix nil labels issue for helm4#867
hitesh-wani-px wants to merge 1 commit intopre-release-portworx-8.2.0from
hwani/PWX-50095

Conversation

@hitesh-wani-px
Copy link
Collaborator

@hitesh-wani-px hitesh-wani-px commented Feb 20, 2026

What this PR does / why we need it:
Helm 4 introduced stricter template rendering behavior compared to Helm 3.
The existing logic was rendering the labels block unconditionally, which caused template rendering failures in Helm 4 when no labels were present.

This PR updates the template to conditionally render the labels section only when labels exist ($hasLabels). This ensures compatibility with Helm 4 while preserving existing Helm 3 behavior
Which issue(s) this PR fixes (optional)
Closes #

Special notes for your reviewer:

  • Helm upgrade is now passing if we passed only annotation in values.yaml
    pxOperatorImageVersion: 25.6.0-dev
    customMetadata:
       annotations:
         service:
           portworx-service: "key1=val1"
           portworx-kvdb-service: "key2=val2"
           portworx-api: "key3=val3"
    root@ip-10-13-188-155:~/go/src/portworx/helm# helm upgrade my-release ./charts/portworx --values values.yaml -n portworx --debug --create-namespace
    NOTES:
     Your Release is named "my-release"
     Portworx Pods should be running on each node in your cluster.
     
     Portworx would create a unified pool of the disks attached to your Kubernetes nodes. 
     No further action should be required and you are ready to consume Portworx Volumes as part of your application data requirements. 
     
     For further information on usage of the Portworx in creating Volumes please refer
         https://docs.portworx.com/portworx-enterprise/operations/operate-kubernetes/storage-operations/create-pvcs
     
     Explore the fundamental concepts of Portworx volumes refer
         https://docs.portworx.com/portworx-enterprise/concepts
     
     Want to use Storage Orchestration for hyperconvergence, Please look at Stork here. 
         https://docs.portworx.com/portworx-enterprise/operations/operate-kubernetes/storage-operations/stork
     
     Track the health and performance of your storage cluster using Portworx’s monitoring features.
         https://docs.portworx.com/portworx-enterprise/operations/operate-kubernetes/monitoring
     
     Refer to the install various stateful applications with Portworx. 
         https://docs.portworx.com/portworx-enterprise/operations/operate-kubernetes/application-install-with-kubernetes
     
         
     For options that you could provide while installing Portworx on your cluster head over to the README.md
     root@ip-10-13-188-155:~/go/src/portworx/helm# 
    • Generated stc has annotation which we passed in values.yaml
     apiVersion: core.libopenstorage.org/v1
     kind: StorageCluster
     metadata:
       annotations:
         meta.helm.sh/release-name: my-release
         meta.helm.sh/release-namespace: portworx
         portworx.io/health-check: passed
         portworx.io/preflight-check: skip
       creationTimestamp: "2026-02-20T04:52:53Z"
       finalizers:
       - operator.libopenstorage.org/delete
       generation: 4
       labels:
         app.kubernetes.io/instance: my-release
         app.kubernetes.io/managed-by: Helm
         chart: portworx-8.2.0
         heritage: Helm
         release: my-release
       name: mycluster
       namespace: portworx
       resourceVersion: "170347"
       uid: a7a2e6e1-8324-4810-abe9-782b96e94f8a
     spec:
       autopilot:
         enabled: true
         prometheusAlerts: true
         providers:
         - name: default
           params:
             url: ""
           type: prometheus
       csi:
         enabled: true
         installSnapshotController: true
       image: portworx/oci-monitor:3.5.2
       imagePullPolicy: Always
       kvdb:
         enableTLS: false
         internal: true
       metadata:
         annotations:
           service/portworx-api:
             key3: val3
           service/portworx-kvdb-service:
             key2: val2
           service/portworx-service:
             key1: val1
       monitoring:
         telemetry:
           enabled: true
           metricsCollector:
             enabled: true
    • Annotations are applied on portworx-api serive
    root@ip-10-13-188-155:~/go/src/portworx/helm# kubectl get svc -n portworx portworx-api -o jsonpath='{.metadata.annotations}'
    {"key3":"val3"}
  • Applying only labels
    pxOperatorImageVersion: 25.6.0-dev
    customMetadata:
      labels:
        service: 
          portworx-api: "key1=val1"
    apiVersion: core.libopenstorage.org/v1
    kind: StorageCluster
    metadata:
      annotations:
        meta.helm.sh/release-name: my-release
        meta.helm.sh/release-namespace: portworx
        portworx.io/health-check: passed
        portworx.io/preflight-check: skip
      creationTimestamp: "2026-02-20T04:52:53Z"
      finalizers:
      - operator.libopenstorage.org/delete
      generation: 5
      labels:
        app.kubernetes.io/instance: my-release
        app.kubernetes.io/managed-by: Helm
        chart: portworx-8.2.0
        heritage: Helm
        release: my-release
      name: mycluster
      namespace: portworx
      resourceVersion: "180805"
      uid: a7a2e6e1-8324-4810-abe9-782b96e94f8a
    spec:
      autopilot:
        enabled: true
        prometheusAlerts: true
        providers:
        - name: default
          params:
            url: ""
          type: prometheus
      csi:
        enabled: true
        installSnapshotController: true
      image: portworx/oci-monitor:3.5.2
      imagePullPolicy: Always
      kvdb:
        enableTLS: false
        internal: true
      metadata:
        labels:
          service/portworx-api:
            key1: val1
      monitoring:
        telemetry:
          enabled: true
          metricsCollector:
            enabled: true
     root@ip-10-13-188-155:~/go/src/portworx/helm# kubectl get svc -n portworx portworx-api -o jsonpath='{.metadata.labels}'
    {"key1":"val1","name":"portworx-api"}
    root@ip-10-13-188-155:~/go/src/portworx/helm# 

@hitesh-wani-px hitesh-wani-px marked this pull request as ready for review February 20, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant