Skip to content

WPB-23896: Handle SonarQube yaml alerts#5160

Open
blackheaven wants to merge 8 commits intodevelopfrom
gdifolco/WPB-23896-sonarqube-blockers-high-helm
Open

WPB-23896: Handle SonarQube yaml alerts#5160
blackheaven wants to merge 8 commits intodevelopfrom
gdifolco/WPB-23896-sonarqube-blockers-high-helm

Conversation

@blackheaven
Copy link
Copy Markdown
Contributor

https://wearezeta.atlassian.net/browse/WPB-23896

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@blackheaven blackheaven requested review from a team as code owners March 31, 2026 06:59
@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Mar 31, 2026
data:
ca.pem: {{ include "tlsCaBrig" . | b64enc | quote }}
{{- end}}
ca.pem: {{ include "tlsCaBrig" . | b64enc | quote }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why is indentation increased from 2 to 3 spaces here?
(and also many other places)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My yaml formatter is a bit brittle, thanks, fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this file does not render correctly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What do you mean precisely?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I just mean that there was an error during rendering:

Error: parse error at (wire-server/charts/nginz/templates/configmap.yaml:6): undefined variable "$nginx_conf"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ah, thanks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It does not there's not $nginx_conf, how do you get this error?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I haven't done it for this branch, but you could helm template the chart with --set-string "foo=bar" for the missing values Helm will scream for.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I cannot find which arguments to give to evaluate this file :/

Copy link
Copy Markdown
Contributor

@supersven supersven Apr 2, 2026

Choose a reason for hiding this comment

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

helm template test charts/nginz \
    --set secrets.zAuth.publicKeys="test-key=test-value" \
    --set secrets.basicAuth="user:pass"

The values don't really matter. But, the keys need to be defined

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, no more parse error

memory: "128Mi"
cpu: "1"
limits:
memory: "512Mi"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are these values actually used?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think so. The resources are defined here:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

reverted

{{- include "outlook.labels" . | nindent 4 }}
spec:
replicas: 3
automountServiceAccountToken: false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is in the deployment spec but should be in the pod spec instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Moved.

Comment on lines +37 to +43
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these used?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we're still using restund (predecessor of coturn) at all 🤔

I'll try to figure that out.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's unused can will be deleted with https://wearezeta.atlassian.net/browse/WPB-24485 .

IMHO we can ignore it for now (and e.g. add an exclusion to Sonar).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dropped and ignored

Comment on lines +1 to +35
Fixed SonarQube Helm template formatting, variable naming, and resource/RBAC issues in charts/:

## Template Formatting (kubernetes:S6893) - 15 issues
- charts/wire-server/templates/background-worker/configmap.yaml: Added whitespace after "{{" on lines 107, 110
- charts/wire-server/templates/gundeck/configmap.yaml: Added whitespace after "{{" on lines 51, 62
- charts/wire-server/templates/galley/configmap.yaml: Added whitespace before "}}" on line 88
- charts/wire-server/templates/gundeck/deployment.yaml: Added whitespace before "}}" on line 52
- charts/wire-server/templates/brig/tests/brig-integration.yaml: Added whitespace before "}}" on lines 51, 56, 122
- charts/wire-server/templates/gundeck/tests/gundeck-integration.yaml: Added whitespace before "}}" on line 20
- charts/wire-server/templates/spar/tests/spar-integration.yaml: Added whitespace before "}}" on line 23
- charts/cassandra-migrations/templates/cassandra-certs.yaml: Added whitespace before "}}" on lines 18, 37, 56, 75
- charts/elasticsearch-index/templates/elasticsearch-ca-secret.yaml: Added whitespace after "{{" on line 5
- charts/nginx-ingress-services/templates/issuer.yaml: Added whitespace after "{{" and before "}}" on lines 6, 23, 32

## Variable Naming (kubernetes:S117) - 4 issues
- charts/nginz/templates/configmap.yaml: Renamed variables to match camelCase convention:
- $nginx_conf -> $nginxConf
- $external_env_domain -> $externalEnvDomain
- $deeplink_json -> $deeplinkJson
- $deeplink_html -> $deeplinkHtml
Updated all references accordingly

## Resource Limits/Requests - 6 issues
- charts/outlook-addin/templates/deployment.yaml: Added resources block with memory limit and memory/cpu requests
- charts/restund/values.yaml: Added resources block with memory/cpu limits and requests
- charts/k8ssandra-test-cluster/values.yaml: Added resources block with memory/cpu limits and requests
- charts/backoffice/templates/tests/stern-integration.yaml: Added memory limit to existing resources
- charts/wire-server/values.yaml: Added ephemeral-storage requests to background-worker and wire-server-enterprise resources

## Service Account RBAC (kubernetes:S6865) - 5 issues
- charts/wire-server/templates/cargohold/deployment.yaml: Added automountServiceAccountToken: false
- charts/restund/templates/statefulset.yaml: Added automountServiceAccountToken: false
- charts/outlook-addin/templates/deployment.yaml: Added automountServiceAccountToken: false
- charts/k8ssandra-test-cluster/templates/check-cluster-job.yaml: Added automountServiceAccountToken: false
- charts/backoffice/templates/tests/stern-integration.yaml: Added automountServiceAccountToken: false
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this was helpful for reviewing, but I think it is too much when added to the changelog.
I think it would be better if we put these in the PR description, make the changelog itself much shorter.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, I'm agreeing with @battermann . Operators probably don't care about renaming variables.

However, the Resource Limits/Requests might be interesting beyond internal. Maybe, add a sentence in another changelog category?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reworked!

requests:
memory: "200Mi"
cpu: "100m"
ephemeral-storage: "1Gi"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

wire-server-enterprise doesn't seem to use any storage. 🤔

What's the goal of this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dropped!

# NOTE: this secret doesnt need to be created, it only gets a name with this
privateKeySecretRef:
name: {{ include "nginx-ingress-services.getIssuerName" . -}}-account-key
name: {{ include "nginx-ingress-services.getIssuerName" . }}-account-key
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What was wrong with the -? I thought, this is killing whitespace to the right? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +49 to +54
resources:
requests:
memory: "128Mi"
cpu: "100m"
limits:
memory: "256Mi"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have to admit that I know almost nothing about the outlook-addin.

I'm wondering where these numbers come from / how they have been choosen?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Me neither, do we have monitoring on that, so I can have real-world values?

requests:
memory: "200Mi"
cpu: "100m"
ephemeral-storage: "1Gi"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the background-worker need storage? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Dropped!

"helm.sh/hook-delete-policy": hook-succeeded,hook-failed
type: Opaque
data:
data:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this indentation intended?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, this applies to most indentations in this file.

Comment on lines +28 to +30
{{- if and (hasKey .Values.nginx_conf "deeplink") (hasKey .Values.nginx_conf "external_env_domain") }}
{{- $backendURL := .Values.nginx_conf.deeplink.endpoints.backendURL }}
{{- $deeplink_json := $backendURL | replace "https://" "" | trimSuffix "/" | printf "%s-deeplink.json" }}
{{- $deeplink_html := $backendURL | replace "https://" "" | trimSuffix "/" | printf "%s-deeplink.html" }}
{{ $deeplink_json }}: |
{{- $deeplinkJson := .Values.nginx_conf.deeplink.endpoints.backendURL | replace "https://" "" | trimSuffix "/" | printf "%s-deeplink.json" }}
{{- $deeplinkHtml := .Values.nginx_conf.deeplink.endpoints.backendURL | replace "https://" "" | trimSuffix "/" | printf "%s-deeplink.html" }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can't we use the alias $nginxConf here?

<html>
<head></head>
<head>
<title>Deeplink for {{ .Values.nginx_conf.deeplink.endpoints.backendURL }}</title>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same here: There's an alias on .Values.nginx_conf ($nginxConf).

@blackheaven blackheaven requested a review from supersven April 2, 2026 15:52
Comment on lines +53 to +54
type: Opaque
data:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is YAML. We unfortunately have to be careful with indentation 😅

These two indents probably slipped through?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants