cosmo icon indicating copy to clipboard operation
cosmo copied to clipboard

Using `commonLabels` in helm charts breaks selectors and thus patch deployments

Open xSAVIKx opened this issue 10 months ago • 3 comments

Component(s)

helm

Component version

0.12.3

wgc version

0.71.4

controlplane version

0.118.1

router version

0.150.0

What happened?

Description

Adding commonLabels to already deployed components breaks deployment.

Steps to Reproduce

Add common labels to controlplane in the helm chart as:

controlplane:
  commonLabels:
    env: stage
    team: devops
    owner: test
    domain: infra

Expected Result

Deployment is successful

Actual Result

Error: UPGRADE FAILED: release cosmo failed, and has been rolled back due to atomic being set: cannot patch "cosmo-controlplane" with kind Deployment: Deployment.apps "cosmo-controlplane" is invalid: spec.selector: Invalid value: v1.LabelSelector***MatchLabels:map[string]string***"app.kubernetes.io/instance":"cosmo", "app.kubernetes.io/name":"controlplane", "domain":"infra", "env":"stage", "owner":"test", "team":"devops"***, MatchExpressions:[]v1.LabelSelectorRequirement(nil)***: field is immutable && cannot patch "cosmo-graphqlmetrics" with kind Deployment: Deployment.apps "cosmo-graphqlmetrics" is invalid: spec.selector: Invalid value: v1.LabelSelector***MatchLabels:map[string]string***"app.kubernetes.io/instance":"cosmo", "app.kubernetes.io/name":"graphqlmetrics", "domain":"infra", "env":"stage", "owner":"test", "team":"devops"***, MatchExpressions:[]v1.LabelSelectorRequirement(nil)***: field is immutable && cannot patch "cosmo-otelcollector" with kind Deployment: Deployment.apps "cosmo-otelcollector" is invalid: spec.selector: Invalid value: v1.LabelSelector***MatchLabels:map[string]string***"app.kubernetes.io/instance":"cosmo", "app.kubernetes.io/name":"otelcollector", "domain":"infra", "env":"stage", "owner":"test", "team":"devops"***, MatchExpressions:[]v1.LabelSelectorRequirement(nil)***: field is immutable && cannot patch "cosmo-router" with kind Deployment: Deployment.apps "cosmo-router" is invalid: spec.selector: Invalid value: v1.LabelSelector***MatchLabels:map[string]string***"app.kubernetes.io/instance":"cosmo", "app.kubernetes.io/name":"router", "domain":"infra", "env":"stage", "owner":"test", "team":"devops"***, MatchExpressions:[]v1.LabelSelectorRequirement(nil)***: field is immutable && cannot patch "cosmo-studio" with kind Deployment: Deployment.apps "cosmo-studio" is invalid: spec.selector: Invalid value: v1.LabelSelector***MatchLabels:map[string]string***"app.kubernetes.io/instance":"cosmo", "app.kubernetes.io/name":"studio", "domain":"infra", "env":"stage", "owner":"test", "team":"devops"***, MatchExpressions:[]v1.LabelSelectorRequirement(nil)***: field is immutable

I'd not be expecting these extra labels to be used in selectors at all.

Environment information

No response

Router configuration


Router execution config


Log output


Additional context

No response

xSAVIKx avatar Jan 22 '25 09:01 xSAVIKx

WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible. The roadmap is driven by our customers and we have to prioritize issues that are important to them. You can influence the priority by becoming a customer. Please contact us here.

github-actions[bot] avatar Jan 22 '25 09:01 github-actions[bot]

I guess moving these commonLabels from selector labels helper to common labels helper will do the trick. Also now it feels like the naming may be a bit confusing.

https://github.com/wundergraph/cosmo/blob/7c92c5576c3d713cc9c1349cf6f725f79ed75310/helm/cosmo/charts/controlplane/templates/_helpers.tpl#L46-L82

xSAVIKx avatar Jan 22 '25 09:01 xSAVIKx

Hi @xSAVIKx thanks for opening an issue. We'll take a look and come back.

StarpTech avatar Jan 28 '25 10:01 StarpTech