Skip to content

Commit 7c4dbd6

Browse files
committed
Set defaulth image for fernet key rotation
1 parent 68fce65 commit 7c4dbd6

File tree

6 files changed

+29
-1
lines changed

6 files changed

+29
-1
lines changed

api/bases/keystone.openstack.org_keystoneapis.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ spec:
9494
description: FernetMaxActiveKeys - Maximum number of fernet token
9595
keys after rotation
9696
type: string
97+
fernetRotationContainerImage:
98+
description: Keystone Fernet Rotation Container Image URL (will be
99+
set to environmental default if empty)
100+
type: string
97101
fernetRotationSchedule:
98102
default: 1 0 * * *
99103
description: FernetRotationSchedule - Schedule rotate fernet token
@@ -422,6 +426,7 @@ spec:
422426
required:
423427
- containerImage
424428
- databaseInstance
429+
- fernetRotationContainerImage
425430
- memcachedInstance
426431
- rabbitMqClusterName
427432
- secret

api/v1beta1/keystoneapi_types.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ const (
4545

4646
// KeystoneAPIContainerImage is the fall-back container image for KeystoneAPI
4747
KeystoneAPIContainerImage = "quay.io/podified-antelope-centos9/openstack-keystone:current-podified"
48+
49+
// KeystoneFernetRotationContainerImage is the fall-back container image for Keystone Fernet Rotation
50+
KeystoneFernetRotationContainerImage = "registry.redhat.io/openshift4/ose-cli"
4851
)
4952

5053
type KeystoneAPISpec struct {
@@ -53,6 +56,9 @@ type KeystoneAPISpec struct {
5356
// +kubebuilder:validation:Required
5457
// Keystone Container Image URL (will be set to environmental default if empty)
5558
ContainerImage string `json:"containerImage"`
59+
// +kubebuilder:validation:Required
60+
// Keystone Fernet Rotation Container Image URL (will be set to environmental default if empty)
61+
FernetRotationContainerImage string `json:"fernetRotationContainerImage"`
5662
}
5763

5864
// KeystoneAPISpec defines the desired state of KeystoneAPI
@@ -293,6 +299,7 @@ func SetupDefaults() {
293299
// Acquire environmental defaults and initialize Keystone defaults with them
294300
keystoneDefaults := KeystoneAPIDefaults{
295301
ContainerImageURL: util.GetEnvVar("RELATED_IMAGE_KEYSTONE_API_IMAGE_URL_DEFAULT", KeystoneAPIContainerImage),
302+
FernetRotationContainerImageURL: util.GetEnvVar("RELATED_IMAGE_KEYSTONE_FERNET_ROTATION_IMAGE_URL_DEFAULT", KeystoneFernetRotationContainerImage),
296303
}
297304

298305
SetupKeystoneAPIDefaults(keystoneDefaults)

api/v1beta1/keystoneapi_webhook.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
// KeystoneAPIDefaults -
3939
type KeystoneAPIDefaults struct {
4040
ContainerImageURL string
41+
FernetRotationContainerImageURL string
4142
}
4243

4344
var keystoneAPIDefaults KeystoneAPIDefaults
@@ -69,6 +70,9 @@ func (r *KeystoneAPI) Default() {
6970
if r.Spec.ContainerImage == "" {
7071
r.Spec.ContainerImage = keystoneAPIDefaults.ContainerImageURL
7172
}
73+
if r.Spec.FernetRotationContainerImage == "" {
74+
r.Spec.FernetRotationContainerImage = keystoneAPIDefaults.FernetRotationContainerImageURL
75+
}
7276
r.Spec.Default()
7377
}
7478

config/crd/bases/keystone.openstack.org_keystoneapis.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ spec:
9494
description: FernetMaxActiveKeys - Maximum number of fernet token
9595
keys after rotation
9696
type: string
97+
fernetRotationContainerImage:
98+
description: Keystone Fernet Rotation Container Image URL (will be
99+
set to environmental default if empty)
100+
type: string
97101
fernetRotationSchedule:
98102
default: 1 0 * * *
99103
description: FernetRotationSchedule - Schedule rotate fernet token
@@ -422,6 +426,7 @@ spec:
422426
required:
423427
- containerImage
424428
- databaseInstance
429+
- fernetRotationContainerImage
425430
- memcachedInstance
426431
- rabbitMqClusterName
427432
- secret

pkg/keystone/fernet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func FernetCronJob(
165165
Containers: []corev1.Container{
166166
{
167167
Name: ServiceName + "-fernet-job",
168-
Image: instance.Spec.ContainerImage,
168+
Image: instance.Spec.FernetRotationContainerImage,
169169
Command: []string{
170170
"/bin/bash",
171171
},

tests/functional/keystoneapi_webhook_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,17 @@ var _ = Describe("KeystoneAPI Webhook", func() {
9494
Expect(KeystoneAPI.Spec.ContainerImage).Should(Equal(
9595
keystonev1.KeystoneAPIContainerImage,
9696
))
97+
Expect(KeystoneAPI.Spec.FernetRotationContainerImage).Should(Equal(
98+
keystonev1.KeystoneFernetRotationContainerImage,
99+
))
97100
})
98101
})
99102

100103
When("A KeystoneAPI instance is created with container images", func() {
101104
BeforeEach(func() {
102105
spec := GetDefaultKeystoneAPISpec()
103106
spec["containerImage"] = "api-container-image"
107+
spec["fernetRotationContainerImage"] = "fernet-rotation-container-image"
104108
DeferCleanup(th.DeleteInstance, CreateKeystoneAPI(keystoneAPIName, spec))
105109
})
106110

@@ -109,6 +113,9 @@ var _ = Describe("KeystoneAPI Webhook", func() {
109113
Expect(KeystoneAPI.Spec.ContainerImage).Should(Equal(
110114
"api-container-image",
111115
))
116+
Expect(KeystoneAPI.Spec.FernetRotationContainerImage).Should(Equal(
117+
"fernet-rotation-container-image",
118+
))
112119
})
113120
})
114121

0 commit comments

Comments
 (0)