Skip to content

Commit 49c7b9c

Browse files
committed
fixup! implement handling for customized storage bucket names
1 parent c002ca0 commit 49c7b9c

File tree

3 files changed

+85
-7
lines changed

3 files changed

+85
-7
lines changed

internal/controllers/common/resource_definitions/resource_definitions.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,6 +1466,12 @@ func NewCoreContainer(cr *model.CryostatInstance, specs *ServiceSpecs, imageTag
14661466
Value: *cr.Spec.ObjectStorageOptions.StorageBucketNameOptions.ArchivedRecordings,
14671467
})
14681468
}
1469+
if cr.Spec.ObjectStorageOptions.StorageBucketNameOptions.ArchivedReports != nil {
1470+
envs = append(envs, corev1.EnvVar{
1471+
Name: "CRYOSTAT_SERVICES_REPORTS_STORAGE_CACHE_NAME",
1472+
Value: *cr.Spec.ObjectStorageOptions.StorageBucketNameOptions.ArchivedReports,
1473+
})
1474+
}
14691475
if cr.Spec.ObjectStorageOptions.StorageBucketNameOptions.EventTemplates != nil {
14701476
envs = append(envs, corev1.EnvVar{
14711477
Name: "STORAGE_BUCKETS_EVENT_TEMPLATES_NAME",

internal/controllers/reconciler_test.go

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ func (c *controllerTest) commonTests() {
970970
It("Should update the core deployment", func() {
971971
secretOptional := false
972972
t.checkCoreHasEnvironmentVariables([]corev1.EnvVar{
973-
corev1.EnvVar{
973+
{
974974
Name: "QUARKUS_S3_AWS_CREDENTIALS_STATIC_PROVIDER_ACCESS_KEY_ID",
975975
ValueFrom: &corev1.EnvVarSource{
976976
FieldRef: nil,
@@ -985,7 +985,7 @@ func (c *controllerTest) commonTests() {
985985
},
986986
},
987987
},
988-
corev1.EnvVar{
988+
{
989989
Name: "QUARKUS_S3_AWS_CREDENTIALS_STATIC_PROVIDER_SECRET_ACCESS_KEY",
990990
ValueFrom: &corev1.EnvVarSource{
991991
FieldRef: nil,
@@ -1000,29 +1000,71 @@ func (c *controllerTest) commonTests() {
10001000
},
10011001
},
10021002
},
1003-
corev1.EnvVar{
1003+
{
10041004
Name: "QUARKUS_S3_ENDPOINT_OVERRIDE",
10051005
Value: "https://example.com:1234",
10061006
},
1007-
corev1.EnvVar{
1007+
{
10081008
Name: "QUARKUS_S3_PATH_STYLE_ACCESS",
10091009
Value: "true",
10101010
},
1011-
corev1.EnvVar{
1011+
{
10121012
Name: "QUARKUS_S3_AWS_REGION",
10131013
Value: "region-east-1",
10141014
},
1015-
corev1.EnvVar{
1015+
{
10161016
Name: "QUARKUS_S3_SYNC_CLIENT_TLS_TRUST_MANAGERS_PROVIDER_TYPE",
10171017
Value: "trust-all",
10181018
},
1019-
corev1.EnvVar{
1019+
{
10201020
Name: "STORAGE_METADATA_STORAGE_MODE",
10211021
Value: "tagging",
10221022
},
10231023
})
10241024
})
10251025
})
1026+
Context("with S3 storage bucket names configuration", func() {
1027+
BeforeEach(func() {
1028+
secretName := "external-s3-creds"
1029+
t.StorageSecret = t.NewExternalStorageSecret(secretName)
1030+
t.objs = append(t.objs, t.NewCryostatWithCustomizedStorageBucketNames().Object, t.StorageSecret)
1031+
})
1032+
JustBeforeEach(func() {
1033+
t.reconcileCryostatFully()
1034+
})
1035+
It("Should update the core deployment", func() {
1036+
t.checkCoreHasEnvironmentVariables([]corev1.EnvVar{
1037+
{
1038+
Name: "STORAGE_BUCKETS_ARCHIVES_NAME",
1039+
Value: "a",
1040+
},
1041+
{
1042+
Name: "CRYOSTAT_SERVICES_REPORTS_STORAGE_CACHE_NAME",
1043+
Value: "b",
1044+
},
1045+
{
1046+
Name: "STORAGE_BUCKETS_EVENT_TEMPLATES_NAME",
1047+
Value: "c",
1048+
},
1049+
{
1050+
Name: "STORAGE_BUCKETS_PROBE_TEMPLATES_NAME",
1051+
Value: "d",
1052+
},
1053+
{
1054+
Name: "STORAGE_BUCKETS_HEAP_DUMPS_NAME",
1055+
Value: "e",
1056+
},
1057+
{
1058+
Name: "STORAGE_BUCKETS_THREAD_DUMPS_NAME",
1059+
Value: "f",
1060+
},
1061+
{
1062+
Name: "STORAGE_BUCKETS_METADATA_NAME",
1063+
Value: "z",
1064+
},
1065+
})
1066+
})
1067+
})
10261068
Context("with custom PVC spec overriding all defaults", func() {
10271069
BeforeEach(func() {
10281070
t.objs = append(t.objs, t.NewCryostatWithPVCSpec().Object)

internal/test/resources.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,36 @@ func (r *TestResources) NewCryostatWithExternalS3(secretName string) *model.Cryo
244244
return cr
245245
}
246246

247+
func (r *TestResources) NewCryostatWithCustomizedStorageBucketNames() *model.CryostatInstance {
248+
cr := r.NewCryostat()
249+
providerUrl := "https://example.com:1234"
250+
region := "region-east-1"
251+
252+
archivedRecordings := "a"
253+
archivedReports := "b"
254+
eventTemplates := "c"
255+
probeTemplates := "d"
256+
heapDumps := "e"
257+
threadDumps := "f"
258+
metadata := "z"
259+
cr.Spec.ObjectStorageOptions = &operatorv1beta2.ObjectStorageOptions{
260+
Provider: &operatorv1beta2.ObjectStorageProviderOptions{
261+
URL: &providerUrl,
262+
Region: &region,
263+
},
264+
StorageBucketNameOptions: &operatorv1beta2.StorageBucketNameOptions{
265+
ArchivedRecordings: &archivedRecordings,
266+
ArchivedReports: &archivedReports,
267+
EventTemplates: &eventTemplates,
268+
JMCAgentProbeTemplates: &probeTemplates,
269+
HeapDumps: &heapDumps,
270+
ThreadDumps: &threadDumps,
271+
Metadata: &metadata,
272+
},
273+
}
274+
return cr
275+
}
276+
247277
func (r *TestResources) NewCryostatWithPVCSpecLegacy() *model.CryostatInstance {
248278
cr := r.NewCryostat()
249279
cr.Spec.StorageOptions = &operatorv1beta2.StorageConfigurations{

0 commit comments

Comments
 (0)