Skip to content

Commit 1840975

Browse files
committed
SonarQube maintenance (#1343)
1 parent ebac80d commit 1840975

28 files changed

Lines changed: 698 additions & 146 deletions

.github/workflows/continuous-integration-workflow.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
runs-on: ubuntu-22.04
5252
strategy:
5353
matrix:
54-
version: ['10.8.0'] # 9.9 = LTS
54+
version: ['2025.5.0']
5555
edition: ['developer', 'enterprise']
5656
steps:
5757
-
@@ -66,6 +66,21 @@ jobs:
6666
run: |
6767
cd sonarqube && ./test.sh --sq-version=${{ matrix.version }} --sq-edition=${{ matrix.edition }}
6868
69+
sonarqube-postgresql:
70+
name: SonarQube PostgreSQL tests
71+
runs-on: ubuntu-22.04
72+
steps:
73+
-
74+
name: Checkout repository
75+
uses: actions/checkout@v4.2.2
76+
-
77+
name: Build docker image
78+
run: |
79+
./.github/workflows/build-docker-image.sh \
80+
--imagename ods-sonarqube-postgresql \
81+
--dockerdir sonarqube/docker \
82+
--dockerfile Dockerfile.database
83+
6984
nexus:
7085
name: Nexus tests
7186
runs-on: ubuntu-22.04

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Change Cnes report to custom SonarQube report ([#1354](https://github.com/opendevstack/ods-core/pull/1354))
99
- Adapted Sonarqube server configuration to make projects private and have custom gate ([#1347](https://github.com/opendevstack/ods-core/pull/1347))
1010
- Update Aqua cli to 2022.4.829 ([#1353](https://github.com/opendevstack/ods-core/pull/1353))
11+
- Update SonarQube and use local image for database ([#1343](https://github.com/opendevstack/ods-core/pull/1343))
1112

1213
### Fixed
1314

Makefile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ apply-sonarqube-chart:
131131

132132
## Start build of BuildConfig "sonarqube".
133133
start-sonarqube-build:
134-
ocp-scripts/start-and-follow-build.sh --namespace $(ODS_NAMESPACE) --build-config sonarqube
134+
ocp-scripts/start-and-follow-build.sh --namespace $(ODS_NAMESPACE) --build-config sonarqube && ocp-scripts/start-and-follow-build.sh --namespace $(ODS_NAMESPACE) --build-config sonarqube-postgresql
135135
@echo "Visit $(SONARQUBE_URL)/setup to see if any update actions need to be taken."
136136
.PHONY: start-sonarqube-build
137137

138138
## Configure SonarQube service.
139139
configure-sonarqube:
140-
cd sonarqube && ./configure.sh --sonarqube=$(SONARQUBE_URL) $(INSECURE_FLAG)
140+
cd sonarqube && ./configure.sh --sonarqube=$(SONARQUBE_URL) --database-config=true $(INSECURE_FLAG)
141141
.PHONY: configure-sonarqube
142142

143143

@@ -181,20 +181,14 @@ start-opentelemetry-collector-build:
181181

182182
# BACKUP
183183
## Create a backup of the current state.
184-
backup: backup-sonarqube backup-ocp-config
184+
backup: backup-ocp-config
185185
.PHONY: backup
186186

187187
## Create a backup of OpenShift resources in "ods" namespace.
188188
backup-ocp-config:
189189
tailor export --namespace $(ODS_NAMESPACE) > backup_ods.yml
190190
.PHONY: backup-ocp-config
191191

192-
## Create a backup of the SonarQube database in backup storage and in the current directory.
193-
backup-sonarqube:
194-
cd sonarqube && ./backup.sh --namespace $(ODS_NAMESPACE) --local-copy=true --backup-dir `pwd`
195-
.PHONY: backup-sonarqube
196-
197-
198192
# PVC MIGRATION
199193
## Migrate data from one PVC to another. Options: SOURCE_PVC, TARGET_PVC, THREADS (default: 5), CPU_REQUEST (default: 1), MEMORY (default: 2)
200194
migrate-pvc-data:

configuration-sample/ods-core.env.sample

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ NEXUS_STORAGE_PROVISIONER="ebs.csi.aws.com"
8989
# Storage class for Nexus data, for AWS this should be "gp3-csi"
9090
NEXUS_STORAGE_CLASS_DATA="gp3-csi"
9191

92-
# Storage class for Nexus backup, for AWS this should be "gp2-encrypted"
92+
# Storage class for Nexus backup, for AWS this should be "csi-aws-vsc"
9393
NEXUS_STORAGE_CLASS_BACKUP="csi-aws-vsc"
9494

9595
# Nexus snapshot configuration, default to run daily at 2 AM
@@ -124,6 +124,8 @@ SONAR_ADMIN_PASSWORD_B64=changeme
124124
# Authentication token used by sonar-scanner-cli from Jenkins pipelines.
125125
# Do not change the value manually - the token is created and set automatically during "make configure-sonarqube".
126126
SONAR_AUTH_TOKEN_B64=changeme
127+
# Web authetification code, needed for liveness Probe
128+
SONAR_WEB_SYSTEMPASSCODE_B64=changeme
127129

128130
# Toggle authentication via SAML
129131
SONAR_AUTH_SAML='true'
@@ -138,14 +140,17 @@ SONAR_SAML_CERTIFICATE_B64=changeme
138140
# Image to use for the PostgreSQL database. This needs to be compatible with
139141
# your SonarQube version, see https://docs.sonarqube.org/latest/requirements/requirements/.
140142
# Take care when upgrading either database or SQ version.
141-
# E.g. registry.redhat.io/rhel9/postgresql-15
142-
SONAR_DATABASE_IMAGE=docker-registry.default.svc:5000/openshift/postgresql:15
143+
# E.g. registry.redhat.io/rhel10/postgresql-16
144+
SONAR_DATABASE_IMAGE=registry.redhat.io/rhel10/postgresql-16
143145
# Connection string for JDBC. Typically this does not need to be changed.
144146
SONAR_DATABASE_JDBC_URL=jdbc:postgresql://sonarqube-postgresql:5432/sonarqube
145147
# Database name for SonarQube. Typically this does not need to be changed.
146148
SONAR_DATABASE_NAME=sonarqube
147149
# Password of SonarQube database - should be set to a secure password.
148150
SONAR_DATABASE_PASSWORD_B64=changeme
151+
SONAR_DATABASE_SUPER_NAME=super_sonarqube
152+
# Super Password of SonarQube database - should be set to a secure password.
153+
SONAR_DATABASE_SUPER_PASSWORD_B64=changeme
149154
# User of SonarQube database. Typically this does not need to be changed.
150155
SONAR_DATABASE_USER=sonarqube
151156

@@ -157,29 +162,62 @@ SONAR_EDITION=developer
157162
# SonarQube version.
158163
# See Dockerhub https://hub.docker.com/_/sonarqube/tags
159164
# Officially supported is:
160-
# - 10.8.0
161-
SONAR_VERSION=10.8.0
165+
# - 2025.5.0
166+
SONAR_VERSION=2025.5.0
162167

163168
# SonarQube memory and CPU resources
164-
SONARQUBE_CPU_REQUEST=200m
165-
SONARQUBE_MEMORY_REQUEST=2Gi
166-
SONARQUBE_CPU_LIMIT=1
167-
SONARQUBE_MEMORY_LIMIT=4Gi
169+
SONARQUBE_CPU_REQUEST=300m
170+
SONARQUBE_MEMORY_REQUEST=5Gi
171+
SONARQUBE_CPU_LIMIT=2
172+
SONARQUBE_MEMORY_LIMIT=5Gi
168173

169174
# SonarQube data and backup capacity
170175
SONARQUBE_DATA_CAPACITY=2Gi
171176
SONARQUBE_EXTENSIONS_CAPACITY=1Gi
172177

173178
# SonarQube database memory and CPU resources
174-
SONARQUBE_DB_CPU_REQUEST=100m
175-
SONARQUBE_DB_MEMORY_REQUEST=256Mi
176-
SONARQUBE_DB_CPU_LIMIT=1
179+
SONARQUBE_DB_CPU_REQUEST=200m
180+
SONARQUBE_DB_MEMORY_REQUEST=512Mi
181+
SONARQUBE_DB_CPU_LIMIT=2
177182
SONARQUBE_DB_MEMORY_LIMIT=512Mi
178183

179184
# SonarQube database and backup capacity
180185
SONARQUBE_DB_CAPACITY=2Gi
181186
SONARQUBE_DB_BACKUP_CAPACITY=1Gi
182187

188+
# SonarQube data storage name
189+
SONARQUBE_DATA_STORAGE_NAME="sonarqube-data-storage"
190+
191+
# Storage class provisioner for SonarQube data, for AWS this should be "ebs.csi.aws.com"
192+
SONARQUBE_STORAGE_PROVISIONER=""
193+
194+
# Storage class for SonarQube data, for AWS this should be "gp3-csi"
195+
SONARQUBE_STORAGE_CLASS_DATA=""
196+
197+
# Storage class provisioner for fast SonarQube storage, for AWS this should be "ebs.csi.aws.com"
198+
SONARQUBE_FAST_STORAGE_PROVISIONER="ebs.csi.aws.com"
199+
200+
# Storage class for fast SonarQube data, for AWS this should be "gp3-csi"
201+
SONARQUBE_FAST_STORAGE_CLASS_DATA="gp3-csi"
202+
203+
# Storage class for fast SonarQube backup, for AWS this should be "csi-aws-vsc"
204+
SONARQUBE_FAST_STORAGE_CLASS_BACKUP="csi-aws-vsc"
205+
206+
# SonarQube backup configuration, default to run daily at 2 AM
207+
SONARQUBE_BACKUP_SCHEDULE="0 2 * * *"
208+
209+
# SonarQube DB backup TTL in days (default: 30 days)
210+
SONARQUBE_DB_BACKUP_TTL=30
211+
212+
# SonarQube scan configuration
213+
SONAR_SCAN_ENABLED="true"
214+
SONAR_SCAN_EXCLUSIONS=".json,.xml,**/__pycache__/**,**/*.pyc,/venv/,/.venv/,/site-packages/,/node_modules/,/dist/,/build/,/out/,/coverage/,/.next/,/.parcel-cache/,/target/,/.gradle/,/.mvn/,/vendor/,/bin/,/obj/,/build/libs/,/.terraform/,/pkg/,/android/,/ios/,/www/,/target/**,/Cargo.lock,/target/,/**/*.class,/**/*.jar,/**/*.war"
215+
SONAR_SCAN_NEXUS_REPOSITORY=leva-documentation
216+
SONAR_SCAN_ALERT_EMAILS=
217+
SONAR_SCAN_PROJECTS_PRIVATE="false"
218+
SONAR_SCAN_ACCOUNT=cd-user-with-password
219+
220+
183221
#########
184222
# Jira #
185223
#########

jenkins/agent-base/Dockerfile.ubi8

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ FROM quay.io/openshift/origin-jenkins-agent-base
22

33
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
44

5-
ENV SONAR_SCANNER_VERSION=6.2.1.4610 \
6-
SONAR_REPORT_VERSION=1.1 \
5+
ENV SONAR_SCANNER_VERSION=7.3.0.5189 \
6+
SONAR_REPORT_VERSION=1.2 \
77
COSIGN_VERSION=2.4.3 \
88
TAILOR_VERSION=1.3.4 \
99
SOPS_VERSION=3.9.0 \
Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
apiVersion: batch/v1
22
kind: CronJob
33
metadata:
4-
name: nexus-volume-snapshot
4+
name: {{ .Values.global.appName }}-volume-snapshot
55
labels:
6-
app: nexus
6+
app: {{ .Values.global.appName }}
77
spec:
88
schedule: "{{ .Values.global.nexusSnapshotSchedule }}"
99
concurrencyPolicy: Forbid
10+
startingDeadlineSeconds: 3600
1011
suspend: false
1112
jobTemplate:
1213
spec:
13-
ttlSecondsAfterFinished: {{ .Values.global.nexusSnapshotTTL }}
14+
backoffLimit: 0
15+
ttlSecondsAfterFinished: 604800
1416
template:
1517
spec:
16-
backoffLimit: 0
1718
serviceAccountName: ods-edit
1819
containers:
1920
- name: snapshot-creator
@@ -35,27 +36,6 @@ spec:
3536
source:
3637
persistentVolumeClaimName: {{ .Values.global.nexusStorageName }}
3738
EOF
38-
39-
# Wait for the VolumeSnapshot to become Ready (configurable timeout)
40-
TIMEOUT={{ .Values.global.nexusSnapshotCheckTimeout }}
41-
INTERVAL=30
42-
elapsed=0
43-
TIMED_OUT=0
44-
echo "Waiting for VolumeSnapshot $SNAP_NAME to be ready (timeout: $TIMEOUT seconds)..."
45-
until [ $elapsed -ge $TIMEOUT ]; do
46-
ready=$(oc get volumesnapshot "$SNAP_NAME" -n {{ .Values.global.odsNamespace }} -o jsonpath='{.status.readyToUse}' 2>/dev/null || echo "false")
47-
if [ "$ready" = "true" ]; then
48-
echo "VolumeSnapshot $SNAP_NAME is ready"
49-
break
50-
fi
51-
sleep $INTERVAL
52-
elapsed=$((elapsed + INTERVAL))
53-
echo " ... waited $elapsed seconds out of $TIMEOUT seconds"
54-
done
55-
if [ $elapsed -ge $TIMEOUT ]; then
56-
echo "Timeout waiting for VolumeSnapshot $SNAP_NAME to be ready" >&2
57-
exit 1
58-
fi
5939
resources:
6040
limits:
6141
cpu: '1'
@@ -65,5 +45,6 @@ spec:
6545
memory: 256Mi
6646
imagePullPolicy: IfNotPresent
6747
restartPolicy: Never
48+
terminationGracePeriodSeconds: 30
6849
successfulJobsHistoryLimit: 30
6950
failedJobsHistoryLimit: 30

nexus/chart/templates/snapshot-cleanup-cronjob.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ metadata:
77
spec:
88
schedule: "{{ .Values.global.nexusSnapshotCleanupSchedule }}"
99
concurrencyPolicy: Forbid
10+
startingDeadlineSeconds: 3600
1011
suspend: false
1112
jobTemplate:
1213
spec:
13-
ttlSecondsAfterFinished: {{ int .Values.global.nexusSnapshotTTL }}
14+
backoffLimit: 0
15+
ttlSecondsAfterFinished: 604800
1416
template:
1517
spec:
16-
backoffLimit: 0
1718
serviceAccountName: ods-edit
1819
containers:
1920
- name: snapshot-cleaner

sonarqube/chart/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 1.1.1
18+
version: 1.2.0
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
2323
# It is recommended to use it with quotes.
24-
appVersion: "10.8.0"
24+
appVersion: "2025.5.0"
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
apiVersion: build.openshift.io/v1
2+
kind: BuildConfig
3+
metadata:
4+
labels:
5+
app: {{ .Values.global.appName }}
6+
name: {{ .Values.global.appName }}-postgresql
7+
spec:
8+
failedBuildsHistoryLimit: 5
9+
nodeSelector: null
10+
output:
11+
to:
12+
kind: ImageStreamTag
13+
name: {{ printf "%s-postgresql:%s" .Values.global.appName .Values.global.odsImageTag }}
14+
postCommit: {}
15+
resources:
16+
limits:
17+
cpu: {{ .Values.buildConfig.cpuLimit }}
18+
memory: {{ .Values.buildConfig.memLimit }}
19+
requests:
20+
cpu: {{ .Values.buildConfig.cpuRequest }}
21+
memory: {{ .Values.buildConfig.memRequest }}
22+
runPolicy: Serial
23+
source:
24+
contextDir: sonarqube/docker
25+
git:
26+
uri: {{ .Values.global.repoBase }}/{{ .Values.global.odsBitBucketProject }}/ods-core.git
27+
ref: {{ .Values.global.odsGitRef }}
28+
sourceSecret:
29+
name: cd-user-token
30+
type: Git
31+
strategy:
32+
type: Docker
33+
dockerStrategy:
34+
dockerfilePath: Dockerfile.database
35+
from:
36+
kind: DockerImage
37+
name: {{ .Values.global.sonarDatabaseImage}}
38+
forcePull: true
39+
noCache: true
40+
successfulBuildsHistoryLimit: 5

0 commit comments

Comments
 (0)