From 5a9536abf5f53b2ab308ec36b0ce1a0c457e2553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joz=CC=8Ce=20Mlakar?= Date: Fri, 21 Feb 2025 11:53:35 +0100 Subject: [PATCH 1/2] Added synchrony.service.url option --- src/main/charts/confluence/README.md | 1 + .../charts/confluence/templates/_helpers.tpl | 7 +++-- .../templates/statefulset-synchrony.yaml | 14 ++++++---- src/main/charts/confluence/values.yaml | 3 +++ src/test/java/test/SynchronyTest.java | 27 +++++++++++++++++++ .../confluence/output.yaml | 1 + 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/main/charts/confluence/README.md b/src/main/charts/confluence/README.md index a30b1bdb3..5fe624fbd 100644 --- a/src/main/charts/confluence/README.md +++ b/src/main/charts/confluence/README.md @@ -240,6 +240,7 @@ Kubernetes: `>=1.21.x-0` | synchrony.service.nodePort | string | `nil` | Only applicable if service.type is NodePort. NodePort for Synchrony service | | synchrony.service.port | int | `80` | The port on which the Synchrony K8s Service will listen | | synchrony.service.type | string | `"ClusterIP"` | The type of K8s service to use for Synchrony | +| synchrony.service.url | string | `nil` | Complete URL of Synchrony Service (i.e. https://public.mydomain.com/synchrony). If left empty, it is calculated from ingress.https and ingress.host | | synchrony.setPermissions | bool | `true` | Boolean to define whether to set synchrony home directory permissions on startup of Synchrony container. Set to 'false' to disable this behaviour. | | synchrony.shutdown.terminationGracePeriodSeconds | int | `25` | The termination grace period for pods during shutdown. This should be set to the Synchrony internal grace period (default 20 seconds), plus a small buffer to allow the JVM to fully terminate. | | synchrony.tolerations | list | `[]` | Standard K8s tolerations that will be applied to all Synchrony pods | diff --git a/src/main/charts/confluence/templates/_helpers.tpl b/src/main/charts/confluence/templates/_helpers.tpl index c2ed57568..ae1216aa3 100644 --- a/src/main/charts/confluence/templates/_helpers.tpl +++ b/src/main/charts/confluence/templates/_helpers.tpl @@ -204,8 +204,11 @@ Pod labels {{- $synchronyIngressPath = regexReplaceAll $sanitizePathRegex .Values.synchrony.ingress.path "" }} {{- end }} {{- if .Values.synchrony.enabled -}} - {{- if .Values.ingress.https -}}-Dsynchrony.service.url=https://{{ .Values.ingress.host }}/{{ $synchronyIngressPath }}/v1 - {{- else }}-Dsynchrony.service.url=http://{{ .Values.ingress.host }}/{{ $synchronyIngressPath }}/v1 + {{- if .Values.synchrony.service.url -}}-Dsynchrony.service.url={{ .Values.synchrony.service.url }}/v1 + {{- else -}} + {{- if .Values.ingress.https -}}-Dsynchrony.service.url=https://{{ .Values.ingress.host }}/{{ $synchronyIngressPath }}/v1 + {{- else }}-Dsynchrony.service.url=http://{{ .Values.ingress.host }}/{{ $synchronyIngressPath }}/v1 + {{- end }} {{- end }} {{- else -}} -Dsynchrony.btf.disabled=true diff --git a/src/main/charts/confluence/templates/statefulset-synchrony.yaml b/src/main/charts/confluence/templates/statefulset-synchrony.yaml index 837442ea1..2fb6bdb80 100644 --- a/src/main/charts/confluence/templates/statefulset-synchrony.yaml +++ b/src/main/charts/confluence/templates/statefulset-synchrony.yaml @@ -127,12 +127,16 @@ spec: valueFrom: fieldRef: fieldPath: status.podIP - - name: SYNCHRONY_SERVICE_URL - {{ if .Values.ingress.https }} - value: "https://{{ .Values.ingress.host }}/synchrony" + - name: SYNCHRONY_SERVICE_URL + {{ if .Values.synchrony.service.url }} + value: "{{ .Values.synchrony.service.url }}" {{ else }} - value: "http://{{ .Values.ingress.host }}/synchrony" - {{- end }} + {{ if .Values.ingress.https }} + value: "https://{{ .Values.ingress.host }}/synchrony" + {{ else }} + value: "http://{{ .Values.ingress.host }}/synchrony" + {{- end }} + {{ end }} {{- include "synchrony.databaseEnvVars" . | nindent 12 }} {{- include "synchrony.clusteringEnvVars" . | nindent 12 }} {{- if .Values.synchrony.nodeSelector }} diff --git a/src/main/charts/confluence/values.yaml b/src/main/charts/confluence/values.yaml index 77b6a95e4..61ea2982c 100644 --- a/src/main/charts/confluence/values.yaml +++ b/src/main/charts/confluence/values.yaml @@ -1257,6 +1257,9 @@ synchrony: # annotations: {} + # -- Complete URL of Synchrony Service (i.e. https://public.mydomain.com/synchrony). If left empty, it is calculated from ingress.https and ingress.host + url: + # -- If 'synchrony.ingress.path' is defined, a dedicated Synchrony ingress object is created. # This is useful if you need to deploy multiple instances of Confluence with Synchrony enabled # using the same Ingress hostname and different synchrony paths diff --git a/src/test/java/test/SynchronyTest.java b/src/test/java/test/SynchronyTest.java index 0ae65292b..2ab2a0089 100644 --- a/src/test/java/test/SynchronyTest.java +++ b/src/test/java/test/SynchronyTest.java @@ -363,4 +363,31 @@ void synchrony_confluence_topology_constraints(Product product) throws Exception assertThat(topologySpreadConstraints.get(0).get("whenUnsatisfiable")).hasTextContaining("ScheduleAnyway"); assertThat(topologySpreadConstraints.get(0).get("labelSelector").get("matchLabels").get("myLabel")).hasTextContaining("mySelector"); } + + @ParameterizedTest + @EnumSource(value = Product.class, names = "confluence") + void synchrony_service_url(Product product) throws Exception { + final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( + "synchrony.enabled", "true", + "ingress.host", "atlassian.net", + "ingress.path", "confluence", + "ingress.https", "false", + "synchrony.service.url", "https://atlassian.net/synchrony", + )); + + resources.assertContains(Kind.StatefulSet, product.getHelmReleaseName() + "-synchrony"); + resources.assertContains(Kind.Service, product.getHelmReleaseName() + "-synchrony"); + + final var sysProps = resources.get(Kind.ConfigMap, product.getHelmReleaseName() + "-jvm-config") + .getNode("data", "additional_jvm_args"); + + assertThat(sysProps) + .hasTextContaining("-Dsynchrony.service.url=https://atlassian.net/synchrony/v1") + .hasTextNotContaining("-Dsynchrony.service.url=http://atlassian.net/synchrony/v1"); + + resources.getStatefulSet(product.getHelmReleaseName() + "-synchrony") + .getContainer() + .getEnv() + .assertHasValue("SYNCHRONY_SERVICE_URL", "https://atlassian.net/synchrony/v1"); + } } diff --git a/src/test/resources/expected_helm_output/confluence/output.yaml b/src/test/resources/expected_helm_output/confluence/output.yaml index 89352ef63..8415ec9b2 100644 --- a/src/test/resources/expected_helm_output/confluence/output.yaml +++ b/src/test/resources/expected_helm_output/confluence/output.yaml @@ -387,6 +387,7 @@ data: nodePort: null port: 80 type: ClusterIP + url: null setPermissions: true shutdown: terminationGracePeriodSeconds: 25 From d8c5f8d3c779367919e27b6313e74055c00ccbbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joz=CC=8Ce=20Mlakar?= Date: Mon, 24 Feb 2025 19:47:48 +0100 Subject: [PATCH 2/2] fix tests --- .../charts/confluence/templates/statefulset-synchrony.yaml | 6 +++--- src/test/java/test/SynchronyTest.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/charts/confluence/templates/statefulset-synchrony.yaml b/src/main/charts/confluence/templates/statefulset-synchrony.yaml index 2fb6bdb80..f2ec89137 100644 --- a/src/main/charts/confluence/templates/statefulset-synchrony.yaml +++ b/src/main/charts/confluence/templates/statefulset-synchrony.yaml @@ -127,14 +127,14 @@ spec: valueFrom: fieldRef: fieldPath: status.podIP - - name: SYNCHRONY_SERVICE_URL + - name: SYNCHRONY_SERVICE_URL {{ if .Values.synchrony.service.url }} value: "{{ .Values.synchrony.service.url }}" {{ else }} {{ if .Values.ingress.https }} - value: "https://{{ .Values.ingress.host }}/synchrony" + value: "https://{{ .Values.ingress.host }}/synchrony" {{ else }} - value: "http://{{ .Values.ingress.host }}/synchrony" + value: "http://{{ .Values.ingress.host }}/synchrony" {{- end }} {{ end }} {{- include "synchrony.databaseEnvVars" . | nindent 12 }} diff --git a/src/test/java/test/SynchronyTest.java b/src/test/java/test/SynchronyTest.java index 2ab2a0089..f98019ad1 100644 --- a/src/test/java/test/SynchronyTest.java +++ b/src/test/java/test/SynchronyTest.java @@ -372,7 +372,7 @@ void synchrony_service_url(Product product) throws Exception { "ingress.host", "atlassian.net", "ingress.path", "confluence", "ingress.https", "false", - "synchrony.service.url", "https://atlassian.net/synchrony", + "synchrony.service.url", "https://atlassian.net/synchrony" )); resources.assertContains(Kind.StatefulSet, product.getHelmReleaseName() + "-synchrony"); @@ -388,6 +388,6 @@ void synchrony_service_url(Product product) throws Exception { resources.getStatefulSet(product.getHelmReleaseName() + "-synchrony") .getContainer() .getEnv() - .assertHasValue("SYNCHRONY_SERVICE_URL", "https://atlassian.net/synchrony/v1"); + .assertHasValue("SYNCHRONY_SERVICE_URL", "https://atlassian.net/synchrony"); } }