From de0daa150bef26ab3684a715a294243c05d1d7e0 Mon Sep 17 00:00:00 2001 From: Yevhen Ivantsov Date: Mon, 11 Nov 2024 08:52:54 +1100 Subject: [PATCH 1/3] Add s3 backups to Helm values --- src/main/charts/jira/templates/_helpers.tpl | 10 ++++ src/main/charts/jira/values.yaml | 15 ++++++ src/test/java/test/JiraS3EnabledTest.java | 55 ++++++++++++--------- 3 files changed, 57 insertions(+), 23 deletions(-) diff --git a/src/main/charts/jira/templates/_helpers.tpl b/src/main/charts/jira/templates/_helpers.tpl index 732ff1f19..5da963072 100644 --- a/src/main/charts/jira/templates/_helpers.tpl +++ b/src/main/charts/jira/templates/_helpers.tpl @@ -411,6 +411,16 @@ volumeClaimTemplates: value: {{ .Values.jira.s3Storage.attachments.endpointOverride | quote }} {{- end }} {{- end }} +{{- if and .Values.jira.s3Storage.backups.bucketName .Values.jira.s3Storage.backups.bucketRegion }} +- name: ATL_S3BACKUPS_BUCKET_NAME + value: {{ .Values.jira.s3Storage.backups.bucketName | quote }} +- name: ATL_S3BACKUPS_REGION + value: {{ .Values.jira.s3Storage.backups.bucketRegion | quote }} +{{- if .Values.jira.s3Storage.backups.endpointOverride }} +- name: ATL_S3BACKUPS_ENDPOINT_OVERRIDE + value: {{ .Values.jira.s3Storage.backups.endpointOverride | quote }} +{{- end }} +{{- end }} {{- end }} {{- define "jira.databaseEnvVars" -}} diff --git a/src/main/charts/jira/values.yaml b/src/main/charts/jira/values.yaml index ed6798e2e..cf15d7077 100644 --- a/src/main/charts/jira/values.yaml +++ b/src/main/charts/jira/values.yaml @@ -682,6 +682,21 @@ jira: # endpointOverride: + backups: + # -- Bucket name to store backups. If a bucket name and region (see below) are defined, Jira will automatically + # use AWS S3 to store backups. Only bucket name is required, not the full arn. + # If you provide the same bucket name for both avatars and backups, they will be stored in the same bucket + # + bucketName: + + # -- AWS region where the S3 bucket is located. + # + bucketRegion: + + # -- Override the default AWS API endpoint with a custom one + # + endpointOverride: + # Data Center clustering # clustering: diff --git a/src/test/java/test/JiraS3EnabledTest.java b/src/test/java/test/JiraS3EnabledTest.java index 6acac8e41..d4fbb761d 100644 --- a/src/test/java/test/JiraS3EnabledTest.java +++ b/src/test/java/test/JiraS3EnabledTest.java @@ -3,11 +3,15 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.EnumSource; +import org.junit.jupiter.params.provider.MethodSource; import test.helm.Helm; import test.model.Product; +import java.util.List; import java.util.Map; +import java.util.stream.Stream; class JiraS3EnabledTest { private Helm helm; @@ -17,38 +21,43 @@ void initHelm(TestInfo testInfo) { helm = new Helm(testInfo); } + private static final List STORAGE_TYPES = List.of("avatars", "attachments", "backups"); @ParameterizedTest @EnumSource(value = Product.class, names = {"jira"}) - void jira_s3_avatars_storage_env_vars(Product product) throws Exception { - final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( - product + ".s3Storage.avatars.bucketName", "my-bucket", - product + ".s3Storage.avatars.bucketRegion", "my-region" - )); + void s3_storage_env_vars(Product product) throws Exception { + for (String storageType : STORAGE_TYPES) { + final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( + product + ".s3Storage." + storageType + ".bucketName", "my-bucket", + product + ".s3Storage." + storageType + ".bucketRegion", "my-region" + )); - resources.getStatefulSet(product.getHelmReleaseName()) - .getContainer() - .getEnv() - .assertHasValue("ATL_S3AVATARS_BUCKET_NAME", "my-bucket") - .assertHasValue("ATL_S3AVATARS_REGION", "my-region") - .assertDoesNotHaveAnyOf("ATL_S3AVATARS_ENDPOINT_OVERRIDE"); + resources.getStatefulSet(product.getHelmReleaseName()) + .getContainer() + .getEnv() + .assertHasValue("ATL_S3" + storageType.toUpperCase() + "_BUCKET_NAME", "my-bucket") + .assertHasValue("ATL_S3" + storageType.toUpperCase() + "_REGION", "my-region") + .assertDoesNotHaveAnyOf("ATL_S3" + storageType.toUpperCase() + "_ENDPOINT_OVERRIDE"); + } } @ParameterizedTest @EnumSource(value = Product.class, names = {"jira"}) - void jira_s3_avatars_storage_endpoint_override(Product product) throws Exception { - final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( - product + ".s3Storage.avatars.bucketName", "my-bucket", - product + ".s3Storage.avatars.bucketRegion", "my-region", - product + ".s3Storage.avatars.endpointOverride", "http://minio.svc.cluster.local" - )); + void s3_storage_endpoint_override(Product product) throws Exception { + for (String storageType : STORAGE_TYPES) { + final var resources = helm.captureKubeResourcesFromHelmChart(product, Map.of( + product + ".s3Storage." + storageType + ".bucketName", "my-bucket", + product + ".s3Storage." + storageType + ".bucketRegion", "my-region", + product + ".s3Storage." + storageType + ".endpointOverride", "http://minio.svc.cluster.local" + )); - resources.getStatefulSet(product.getHelmReleaseName()) - .getContainer() - .getEnv() - .assertHasValue("ATL_S3AVATARS_BUCKET_NAME", "my-bucket") - .assertHasValue("ATL_S3AVATARS_REGION", "my-region") - .assertHasValue("ATL_S3AVATARS_ENDPOINT_OVERRIDE", "http://minio.svc.cluster.local"); + resources.getStatefulSet(product.getHelmReleaseName()) + .getContainer() + .getEnv() + .assertHasValue("ATL_S3" + storageType.toUpperCase() + "_BUCKET_NAME", "my-bucket") + .assertHasValue("ATL_S3" + storageType.toUpperCase() + "_REGION", "my-region") + .assertHasValue("ATL_S3" + storageType.toUpperCase() + "_ENDPOINT_OVERRIDE", "http://minio.svc.cluster.local"); + } } @ParameterizedTest From 96fbcc988664f49bf179988cf15fa7cc2b7afd92 Mon Sep 17 00:00:00 2001 From: Yevhen Ivantsov Date: Mon, 11 Nov 2024 08:53:28 +1100 Subject: [PATCH 2/3] Add s3 backups to Helm values --- src/test/java/test/JiraS3EnabledTest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/test/java/test/JiraS3EnabledTest.java b/src/test/java/test/JiraS3EnabledTest.java index d4fbb761d..1d65dff3b 100644 --- a/src/test/java/test/JiraS3EnabledTest.java +++ b/src/test/java/test/JiraS3EnabledTest.java @@ -3,15 +3,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.EnumSource; -import org.junit.jupiter.params.provider.MethodSource; import test.helm.Helm; import test.model.Product; import java.util.List; import java.util.Map; -import java.util.stream.Stream; class JiraS3EnabledTest { private Helm helm; From a773a6c672d0492e244ff8a26f292549864aadf1 Mon Sep 17 00:00:00 2001 From: Yevhen Ivantsov Date: Mon, 11 Nov 2024 08:56:51 +1100 Subject: [PATCH 3/3] Add s3 backups to Helm values --- src/test/resources/expected_helm_output/jira/output.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/resources/expected_helm_output/jira/output.yaml b/src/test/resources/expected_helm_output/jira/output.yaml index 48e50ef6f..5765ebcc2 100644 --- a/src/test/resources/expected_helm_output/jira/output.yaml +++ b/src/test/resources/expected_helm_output/jira/output.yaml @@ -189,6 +189,10 @@ data: bucketName: null bucketRegion: null endpointOverride: null + backups: + bucketName: null + bucketRegion: null + endpointOverride: null securityContext: fsGroup: 2001 securityContextEnabled: true