Skip to content

fix(shopware): omit initContainers, extraContainers, extraEnvs when not configured#266

Merged
Patrick Derks (TrayserCassa) merged 2 commits into
shopware:mainfrom
arvato-systems-cxm:fix/null-fields-when-empty
May 20, 2026
Merged

fix(shopware): omit initContainers, extraContainers, extraEnvs when not configured#266
Patrick Derks (TrayserCassa) merged 2 commits into
shopware:mainfrom
arvato-systems-cxm:fix/null-fields-when-empty

Conversation

@DeividsP-P
Copy link
Copy Markdown
Contributor

Problem

When initContainers, extraContainers, or extraEnvs are not set in values, these fields are rendered unconditionally as null in the Store CRD manifest:

initContainers:
extraContainers:
extraEnvs:

The Kubernetes API server rejects this because the Store CRD schema declares these fields as type: array, and null is not a valid array. This causes an error on apply:

Store.shop.shopware.com "shopware" is invalid: [
  spec.container.initContainers: Invalid value: "null": spec.container.initContainers in body must be of type array: "null",
  spec.container.extraContainers: Invalid value: "null": spec.container.extraContainers in body must be of type array: "null"
]

Fix

Wrap each field with a guard so it is only emitted when it has content:

  • initContainers: only rendered when container.initContainers is set or sidecarLogging is enabled
  • extraContainers: only rendered when container.extraContainers is set or fpm is configured with a non-dynamic process manager
  • extraEnvs: only rendered when container.extraEnvs is set

The fix is a minimal, idiomatic Helm change — no helpers or logic outside store.yaml are required. All existing behaviour when the fields are configured is preserved exactly.

@TrayserCassa
Copy link
Copy Markdown
Contributor

Hey, thanks for the PR
I thought this would be tested by the e2e pipeline, because it's just a limited one and run this install:

helm install test --namespace test charts/shopware \
            --set rustfs.storageclass.dataStorageSize=100Mi \
            --set rustfs.storageclass.logStorageSize=100Mi \
            --set valkeyapp.master.resources.requests.cpu=200m \
            --set valkeysession.master.resources.requests.cpu=200m \
            --set valkeyworker.master.resources.requests.cpu=200m

So this will also end in this result in the store:

    imagePullSecrets:
    topologySpreadConstraints:
    nodeSelector:
    affinity:
    labels:
    annotations:
    initContainers:
    extraContainers:

So in the kind cluster this was not an issue. How do you deploy this helm-chart? With argo or flux maybe? Then we need to make sure to double check this.

@DeividsP-P
Copy link
Copy Markdown
Contributor Author

Hey, thanks for the PR I thought this would be tested by the e2e pipeline, because it's just a limited one and run this install:

helm install test --namespace test charts/shopware \
            --set rustfs.storageclass.dataStorageSize=100Mi \
            --set rustfs.storageclass.logStorageSize=100Mi \
            --set valkeyapp.master.resources.requests.cpu=200m \
            --set valkeysession.master.resources.requests.cpu=200m \
            --set valkeyworker.master.resources.requests.cpu=200m

So this will also end in this result in the store:

    imagePullSecrets:
    topologySpreadConstraints:
    nodeSelector:
    affinity:
    labels:
    annotations:
    initContainers:
    extraContainers:

So in the kind cluster this was not an issue. How do you deploy this helm-chart? With argo or flux maybe? Then we need to make sure to double check this.

Yes, those values you provided will also end up causing issues if not set.
We're deploying with ArgoCD.

@DeividsP-P DeividsP-P force-pushed the fix/null-fields-when-empty branch from c13bcdd to c09eba2 Compare May 20, 2026 11:39
DeividsP-P and others added 2 commits May 20, 2026 13:59
When these fields are not configured they render as null in the Store
CRD manifest, which is rejected by the Kubernetes API server since the
CRD schema requires them to be arrays.

Wrap each field with a conditional guard so they are only emitted when
they have content:
- initContainers: omitted unless container.initContainers is set or
  sidecarLogging is enabled
- extraContainers: omitted unless container.extraContainers is set or
  fpm is non-dynamic
- extraEnvs: omitted unless container.extraEnvs is set

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
restartPolicy was incorrectly reading from .Values.store.container.imagePullPolicy
instead of .Values.store.container.restartPolicy, causing the restart
policy to reflect the image pull policy value rather than the intended
restart behaviour.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TrayserCassa
Copy link
Copy Markdown
Contributor

Bug which is related to our pipeline:
#268

So for me this is clear, our e2e pipeline should fail, because the generated helm-chart is not valid. It's valid for helm install but not for helm template | kubectl apply -f -

But nothing you should worry about for now, we will fix this later.

@TrayserCassa Patrick Derks (TrayserCassa) merged commit 17a279d into shopware:main May 20, 2026
2 of 3 checks passed
@TrayserCassa
Copy link
Copy Markdown
Contributor

Your changes are added to helm-chart version 0.0.59 and it's now live. Again thank you for the PR 💙

@DeividsP-P
Copy link
Copy Markdown
Contributor Author

Your changes are added to helm-chart version 0.0.59 and it's now live. Again thank you for the PR 💙

Thanks a lot for merging and deploying it
After removing the placeholder values, a few more issues showed up, so I fixed those as well in a follow-up PR: #270

@DeividsP-P DeividsP-P deleted the fix/null-fields-when-empty branch May 20, 2026 13:10
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.

2 participants