Skip to content

Commit 8167b1b

Browse files
committed
followup DB enhancements for keystone
see notes at openstack-k8s-operators#371
1 parent 045b2ec commit 8167b1b

File tree

7 files changed

+36
-26
lines changed

7 files changed

+36
-26
lines changed

api/bases/keystone.openstack.org_keystoneapis.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ spec:
282282
passwordSelectors:
283283
default:
284284
admin: AdminPassword
285-
description: PasswordSelectors - Selectors to identify the DB and
286-
AdminUser password from the Secret
285+
description: PasswordSelectors - Selectors to identify the AdminUser
286+
password from the Secret
287287
properties:
288288
admin:
289289
default: AdminPassword

api/v1beta1/keystoneapi_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ type KeystoneAPISpecCore struct {
121121

122122
// +kubebuilder:validation:Optional
123123
// +kubebuilder:default={admin: AdminPassword}
124-
// PasswordSelectors - Selectors to identify the DB and AdminUser password from the Secret
124+
// PasswordSelectors - Selectors to identify the AdminUser password from the Secret
125125
PasswordSelectors PasswordSelector `json:"passwordSelectors"`
126126

127127
// +kubebuilder:validation:Optional

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ spec:
282282
passwordSelectors:
283283
default:
284284
admin: AdminPassword
285-
description: PasswordSelectors - Selectors to identify the DB and
286-
AdminUser password from the Secret
285+
description: PasswordSelectors - Selectors to identify the AdminUser
286+
password from the Secret
287287
properties:
288288
admin:
289289
default: AdminPassword

controllers/keystoneapi_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ func (r *KeystoneAPIReconciler) reconcileDelete(ctx context.Context, instance *k
411411
}
412412

413413
// remove db finalizer before the keystone one
414-
db, err := mariadbv1.GetDatabaseByNameAndAccount(ctx, helper, instance.Name, instance.Spec.DatabaseAccount, instance.Namespace)
414+
db, err := mariadbv1.GetDatabaseByNameAndAccount(ctx, helper, keystone.DatabaseCRName, instance.Spec.DatabaseAccount, instance.Namespace)
415415
if err != nil && !k8s_errors.IsNotFound(err) {
416416
return ctrl.Result{}, err
417417
}
@@ -1048,7 +1048,7 @@ func (r *KeystoneAPIReconciler) reconcileNormal(
10481048
}
10491049
// create Deployment - end
10501050

1051-
if instance.Status.ReadyCount > 0 {
1051+
if instance.Status.ReadyCount == *instance.Spec.Replicas {
10521052
// remove finalizers from unused MariaDBAccount records
10531053
err = mariadbv1.DeleteUnusedMariaDBAccountFinalizers(ctx, helper, keystone.DatabaseName, instance.Spec.DatabaseAccount, instance.Namespace)
10541054
if err != nil {
@@ -1396,7 +1396,7 @@ func (r *KeystoneAPIReconciler) ensureDB(
13961396
// yet associated with any MariaDBDatabase.
13971397
_, _, err := mariadbv1.EnsureMariaDBAccount(
13981398
ctx, h, instance.Spec.DatabaseAccount,
1399-
instance.Namespace, false, "keystone",
1399+
instance.Namespace, false, keystone.DatabaseUsernamePrefix,
14001400
)
14011401

14021402
if err != nil {
@@ -1418,8 +1418,8 @@ func (r *KeystoneAPIReconciler) ensureDB(
14181418
//
14191419
db := mariadbv1.NewDatabaseForAccount(
14201420
instance.Spec.DatabaseInstance, // mariadb/galera service to target
1421-
instance.Name, // name used in CREATE DATABASE in mariadb
1422-
instance.Name, // CR name for MariaDBDatabase
1421+
keystone.DatabaseName, // name used in CREATE DATABASE in mariadb
1422+
keystone.DatabaseCRName, // CR name for MariaDBDatabase
14231423
instance.Spec.DatabaseAccount, // CR name for MariaDBAccount
14241424
instance.Namespace, // namespace
14251425
)

pkg/keystone/const.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ const (
2020
ServiceName = "keystone"
2121
// DatabaseName -
2222
DatabaseName = "keystone"
23-
23+
// DatabaseCRName -
24+
DatabaseCRName = "keystone"
25+
// DatabaseUsernamePrefix -
26+
DatabaseUsernamePrefix = "keystone"
2427
// KeystonePublicPort -
2528
KeystonePublicPort int32 = 5000
2629
// KeystoneInternalPort -

tests/functional/keystoneapi_controller_test.go

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var _ = Describe("Keystone controller", func() {
3737

3838
var keystoneApiName types.NamespacedName
3939
var keystoneAccountName types.NamespacedName
40+
var keystoneDatabaseName types.NamespacedName
4041
var keystoneApiConfigDataName types.NamespacedName
4142
var dbSyncJobName types.NamespacedName
4243
var bootstrapJobName types.NamespacedName
@@ -56,6 +57,10 @@ var _ = Describe("Keystone controller", func() {
5657
Name: AccountName,
5758
Namespace: namespace,
5859
}
60+
keystoneDatabaseName = types.NamespacedName{
61+
Name: DatabaseCRName,
62+
Namespace: namespace,
63+
}
5964
dbSyncJobName = types.NamespacedName{
6065
Name: "keystone-db-sync",
6166
Namespace: namespace,
@@ -216,7 +221,7 @@ var _ = Describe("Keystone controller", func() {
216221
)
217222

218223
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
219-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
224+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
220225
})
221226

222227
It("should have db ready condition", func() {
@@ -265,7 +270,7 @@ var _ = Describe("Keystone controller", func() {
265270
),
266271
)
267272
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
268-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
273+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
269274
infra.SimulateTransportURLReady(types.NamespacedName{
270275
Name: fmt.Sprintf("%s-keystone-transport", keystoneApiName.Name),
271276
Namespace: namespace,
@@ -331,7 +336,7 @@ var _ = Describe("Keystone controller", func() {
331336
),
332337
)
333338
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
334-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
339+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
335340
infra.SimulateTransportURLReady(types.NamespacedName{
336341
Name: fmt.Sprintf("%s-keystone-transport", keystoneApiName.Name),
337342
Namespace: namespace,
@@ -424,7 +429,7 @@ var _ = Describe("Keystone controller", func() {
424429
),
425430
)
426431
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
427-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
432+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
428433
infra.SimulateTransportURLReady(types.NamespacedName{
429434
Name: fmt.Sprintf("%s-keystone-transport", keystoneApiName.Name),
430435
Namespace: namespace,
@@ -489,7 +494,7 @@ var _ = Describe("Keystone controller", func() {
489494
),
490495
)
491496
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
492-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
497+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
493498
infra.SimulateTransportURLReady(types.NamespacedName{
494499
Name: fmt.Sprintf("%s-keystone-transport", keystoneApiName.Name),
495500
Namespace: namespace,
@@ -555,7 +560,7 @@ var _ = Describe("Keystone controller", func() {
555560
),
556561
)
557562
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
558-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
563+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
559564
infra.SimulateTransportURLReady(types.NamespacedName{
560565
Name: fmt.Sprintf("%s-keystone-transport", keystoneApiName.Name),
561566
Namespace: namespace,
@@ -634,7 +639,7 @@ var _ = Describe("Keystone controller", func() {
634639
),
635640
)
636641
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
637-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
642+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
638643
infra.SimulateTransportURLReady(types.NamespacedName{
639644
Name: fmt.Sprintf("%s-keystone-transport", keystoneApiName.Name),
640645
Namespace: namespace,
@@ -709,7 +714,7 @@ var _ = Describe("Keystone controller", func() {
709714
),
710715
)
711716
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
712-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
717+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
713718
infra.SimulateTransportURLReady(types.NamespacedName{
714719
Name: fmt.Sprintf("%s-keystone-transport", keystoneApiName.Name),
715720
Namespace: namespace,
@@ -782,7 +787,7 @@ var _ = Describe("Keystone controller", func() {
782787
),
783788
)
784789
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
785-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
790+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
786791
infra.SimulateTransportURLReady(types.NamespacedName{
787792
Name: fmt.Sprintf("%s-keystone-transport", keystoneApiName.Name),
788793
Namespace: namespace,
@@ -1056,7 +1061,7 @@ var _ = Describe("Keystone controller", func() {
10561061
),
10571062
)
10581063
mariadb.SimulateMariaDBAccountCompleted(keystoneAccountName)
1059-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
1064+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
10601065
infra.SimulateTransportURLReady(types.NamespacedName{
10611066
Name: fmt.Sprintf("%s-keystone-transport", keystoneApiName.Name),
10621067
Namespace: namespace,
@@ -1127,7 +1132,7 @@ var _ = Describe("Keystone controller", func() {
11271132
)
11281133

11291134
mariadb.SimulateMariaDBAccountCompleted(accountName)
1130-
mariadb.SimulateMariaDBDatabaseCompleted(keystoneApiName)
1135+
mariadb.SimulateMariaDBDatabaseCompleted(keystoneDatabaseName)
11311136

11321137
infra.SimulateTransportURLReady(types.NamespacedName{
11331138
Name: fmt.Sprintf("%s-keystone-transport", keystoneApiName.Name),

tests/functional/suite_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ import (
2929

3030
memcachedv1 "github.com/openstack-k8s-operators/infra-operator/apis/memcached/v1beta1"
3131
rabbitmqv1 "github.com/openstack-k8s-operators/infra-operator/apis/rabbitmq/v1beta1"
32-
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
33-
test "github.com/openstack-k8s-operators/lib-common/modules/test"
34-
mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"
35-
3632
infra_test "github.com/openstack-k8s-operators/infra-operator/apis/test/helpers"
3733
keystone_test "github.com/openstack-k8s-operators/keystone-operator/api/test/helpers"
34+
keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
3835
"github.com/openstack-k8s-operators/keystone-operator/controllers"
36+
keystone_base "github.com/openstack-k8s-operators/keystone-operator/pkg/keystone"
3937
common_test "github.com/openstack-k8s-operators/lib-common/modules/common/test/helpers"
38+
test "github.com/openstack-k8s-operators/lib-common/modules/test"
4039
mariadb_test "github.com/openstack-k8s-operators/mariadb-operator/api/test/helpers"
40+
mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"
4141
//+kubebuilder:scaffold:imports
4242
)
4343

@@ -65,6 +65,8 @@ const (
6565

6666
AccountName = "test-keystone-account"
6767

68+
DatabaseCRName = keystone_base.DatabaseCRName
69+
6870
PublicCertSecretName = "public-tls-certs"
6971

7072
InternalCertSecretName = "internal-tls-certs"

0 commit comments

Comments
 (0)