Skip to content

Commit d5e074f

Browse files
committed
Replace hardcoded openstack config values
This PR will remove the hardcoded values around the openstack config - configmap, secret. It also adds a way to change these values for HorizonTest and Tobiko resources. It was already possible in AnsibleTest and Tempest, so it should also keep consistency between test-operator resource types.
1 parent f494ab1 commit d5e074f

15 files changed

Lines changed: 108 additions & 32 deletions

api/bases/test.openstack.org_horizontests.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,16 @@ spec:
12841284
This value contains a nodeSelector value that is applied to test pods
12851285
spawned by the test operator.
12861286
type: object
1287+
openStackConfigMap:
1288+
default: openstack-config
1289+
description: OpenStackConfigMap is the name of the ConfigMap containing
1290+
the clouds.yaml
1291+
type: string
1292+
openStackConfigSecret:
1293+
default: openstack-config-secret
1294+
description: OpenStackConfigSecret is the name of the Secret containing
1295+
the secure.yaml
1296+
type: string
12871297
parallel:
12881298
default: false
12891299
description: Parallel

api/bases/test.openstack.org_tobikoes.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,16 @@ spec:
12501250
description: Number of processes/workers used to run tobiko tests
12511251
- value 0 results in automatic decision
12521252
type: integer
1253+
openStackConfigMap:
1254+
default: openstack-config
1255+
description: OpenStackConfigMap is the name of the ConfigMap containing
1256+
the clouds.yaml
1257+
type: string
1258+
openStackConfigSecret:
1259+
default: openstack-config-secret
1260+
description: OpenStackConfigSecret is the name of the Secret containing
1261+
the secure.yaml
1262+
type: string
12531263
parallel:
12541264
default: false
12551265
description: |-
@@ -1498,6 +1508,16 @@ spec:
14981508
description: Number of processes/workers used to run tobiko
14991509
tests - value 0 results in automatic decision
15001510
type: integer
1511+
openStackConfigMap:
1512+
default: openstack-config
1513+
description: OpenStackConfigMap is the name of the ConfigMap
1514+
containing the clouds.yaml
1515+
type: string
1516+
openStackConfigSecret:
1517+
default: openstack-config-secret
1518+
description: OpenStackConfigSecret is the name of the Secret
1519+
containing the secure.yaml
1520+
type: string
15011521
patch:
15021522
description: Optional patch to apply to the Tobiko repository
15031523
for this step.

api/v1beta1/horizontest_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import (
2424

2525
// HorizonTestSpec defines the desired state of HorizonTest
2626
type HorizonTestSpec struct {
27-
CommonOptions `json:",inline"`
27+
CommonOptions `json:",inline"`
28+
CommonOpenstackConfig `json:",inline"`
2829

2930
// +kubebuilder:default:={limits: {cpu: "2000m", memory: "4Gi"}, requests: {cpu: "1000m", memory: "2Gi"}}
3031
// The desired amount of resources that should be assigned to each test pod

api/v1beta1/tobiko_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ type PatchType struct {
3636

3737
// TobikoSpec defines the desired state of Tobiko
3838
type TobikoSpec struct {
39-
CommonOptions `json:",inline"`
39+
CommonOptions `json:",inline"`
40+
CommonOpenstackConfig `json:",inline"`
4041

4142
// +kubebuilder:default:={limits: {cpu: "8000m", memory: "8Gi"}, requests: {cpu: "4000m", memory: "4Gi"}}
4243
// The desired amount of resources that should be assigned to each test pod
@@ -134,6 +135,7 @@ type TobikoSpec struct {
134135

135136
type TobikoWorkflowSpec struct {
136137
WorkflowCommonOptions `json:",inline"`
138+
CommonOpenstackConfig `json:",inline"`
137139

138140
// The desired amount of resources that should be assigned to each test pod
139141
// spawned using the Tobiko CR. https://pkg.go.dev/k8s.io/api/core/v1#ResourceRequirements

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/test.openstack.org_horizontests.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,16 @@ spec:
12841284
This value contains a nodeSelector value that is applied to test pods
12851285
spawned by the test operator.
12861286
type: object
1287+
openStackConfigMap:
1288+
default: openstack-config
1289+
description: OpenStackConfigMap is the name of the ConfigMap containing
1290+
the clouds.yaml
1291+
type: string
1292+
openStackConfigSecret:
1293+
default: openstack-config-secret
1294+
description: OpenStackConfigSecret is the name of the Secret containing
1295+
the secure.yaml
1296+
type: string
12871297
parallel:
12881298
default: false
12891299
description: Parallel

config/crd/bases/test.openstack.org_tobikoes.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,16 @@ spec:
12501250
description: Number of processes/workers used to run tobiko tests
12511251
- value 0 results in automatic decision
12521252
type: integer
1253+
openStackConfigMap:
1254+
default: openstack-config
1255+
description: OpenStackConfigMap is the name of the ConfigMap containing
1256+
the clouds.yaml
1257+
type: string
1258+
openStackConfigSecret:
1259+
default: openstack-config-secret
1260+
description: OpenStackConfigSecret is the name of the Secret containing
1261+
the secure.yaml
1262+
type: string
12531263
parallel:
12541264
default: false
12551265
description: |-
@@ -1498,6 +1508,16 @@ spec:
14981508
description: Number of processes/workers used to run tobiko
14991509
tests - value 0 results in automatic decision
15001510
type: integer
1511+
openStackConfigMap:
1512+
default: openstack-config
1513+
description: OpenStackConfigMap is the name of the ConfigMap
1514+
containing the clouds.yaml
1515+
type: string
1516+
openStackConfigSecret:
1517+
default: openstack-config-secret
1518+
description: OpenStackConfigSecret is the name of the Secret
1519+
containing the secure.yaml
1520+
type: string
15011521
patch:
15021522
description: Optional patch to apply to the Tobiko repository
15031523
for this step.

internal/ansibletest/volumes.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ func GetVolumes(
2222
) []corev1.Volume {
2323

2424
volumes := []corev1.Volume{
25-
util.CreateOpenstackConfigMapVolume("openstack-config"),
26-
util.CreateOpenstackConfigSecretVolume(),
25+
util.CreateOpenstackConfigMapVolume(instance.Spec.OpenStackConfigMap),
26+
util.CreateOpenstackConfigSecretVolume(instance.Spec.OpenStackConfigSecret),
2727
util.CreateLogsPVCVolume(logsPVCName),
2828
util.CreateWorkdirVolume(),
2929
util.CreateTmpVolume(),
@@ -63,9 +63,9 @@ func GetVolumeMounts(
6363
util.CreateVolumeMount(util.TestOperatorEphemeralVolumeNameWorkdir, "/var/lib/ansible", false),
6464
util.CreateVolumeMount(util.TestOperatorEphemeralVolumeNameTmp, "/tmp", false),
6565
util.CreateVolumeMount(util.TestOperatorLogsVolumeName, "/var/lib/AnsibleTests/external_files", false),
66-
util.CreateOpenstackConfigVolumeMount("/etc/openstack/clouds.yaml"),
67-
util.CreateOpenstackConfigVolumeMount("/var/lib/ansible/.config/openstack/clouds.yaml"),
68-
util.CreateOpenstackConfigSecretVolumeMount("/var/lib/ansible/.config/openstack/secure.yaml"),
66+
util.CreateOpenstackConfigVolumeMount(instance.Spec.OpenStackConfigMap, "/etc/openstack/clouds.yaml"),
67+
util.CreateOpenstackConfigVolumeMount(instance.Spec.OpenStackConfigMap, "/var/lib/ansible/.config/openstack/clouds.yaml"),
68+
util.CreateOpenstackConfigSecretVolumeMount(instance.Spec.OpenStackConfigSecret, "/var/lib/ansible/.config/openstack/secure.yaml"),
6969
}
7070

7171
if mountCerts {

internal/controller/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,8 @@ func EnsureCloudsConfigMapExists(
647647
instance client.Object,
648648
helper *helper.Helper,
649649
labels map[string]string,
650+
openstackConfigMapName string,
650651
) (ctrl.Result, error) {
651-
const openstackConfigMapName = "openstack-config"
652652
const testOperatorCloudsConfigMapName = "test-operator-clouds-config"
653653

654654
cm, _, _ := configmap.GetConfigMap(

internal/controller/horizontest_controller.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,13 @@ func (r *HorizonTestReconciler) Reconcile(ctx context.Context, req ctrl.Request)
186186
workflowStepLabel: "0",
187187
}
188188

189-
yamlResult, err := EnsureCloudsConfigMapExists(ctx, instance, helper, serviceLabels)
189+
yamlResult, err := EnsureCloudsConfigMapExists(
190+
ctx,
191+
instance,
192+
helper,
193+
serviceLabels,
194+
instance.Spec.OpenStackConfigMap,
195+
)
190196

191197
if err != nil {
192198
return yamlResult, err

0 commit comments

Comments
 (0)