Skip to content

Commit

Permalink
[go.mod]Bump from v0.3.0 to pseudoversion
Browse files Browse the repository at this point in the history
Our intention is to track service operator and lib-common dependencies
via pseudoversions. However renovate does not automatically bump from a
tagged version (e.g. v0.3.0) to a newer but not tagged pseudoversion. So
this patch does the manual bump. After this renovate will bump the newer
pseduoversions.

Adapt to the new version by:
* adding RBAC rules for MariaDBAccount manipulation
* adding Own(MariaDBAccount) to detect status changes
* separating DB user name and schema name
* adapting test to simulate MariaDBAccount success
  • Loading branch information
gibizer committed Jan 31, 2024
1 parent 5de7de4 commit 226c8da
Show file tree
Hide file tree
Showing 15 changed files with 149 additions and 24 deletions.
47 changes: 47 additions & 0 deletions config/manifests/bases/nova-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,88 @@ spec:
displayName: Nova API
kind: NovaAPI
name: novaapis.nova.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: tls
version: v1beta1
- description: NovaCell is the Schema for the novacells API
displayName: Nova Cell
kind: NovaCell
name: novacells.nova.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: metadataServiceTemplate.tls
- description: TLS - Parameters related to the TLS
displayName: TLS
path: noVNCProxyServiceTemplate.tls
- description: TLS - Parameters related to the TLS
displayName: TLS
path: tls
version: v1beta1
- description: NovaCompute is the Schema for the NovaCompute
displayName: Nova Compute
kind: NovaCompute
name: novacomputes.nova.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: tls
version: v1beta1
- description: NovaConductor is the Schema for the novaconductors API
displayName: Nova Conductor
kind: NovaConductor
name: novaconductors.nova.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: tls
version: v1beta1
- description: NovaMetadata is the Schema for the novametadata API
displayName: Nova Metadata
kind: NovaMetadata
name: novametadata.nova.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: tls
version: v1beta1
- description: NovaNoVNCProxy is the Schema for the novanovncproxies API
displayName: Nova No VNCProxy
kind: NovaNoVNCProxy
name: novanovncproxies.nova.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: tls
version: v1beta1
- description: Nova is the Schema for the nova API
displayName: Nova
kind: Nova
name: novas.nova.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: apiServiceTemplate.tls
- description: TLS - Parameters related to the TLS
displayName: TLS
path: cellTemplates.metadataServiceTemplate.tls
- description: TLS - Parameters related to the TLS
displayName: TLS
path: cellTemplates.noVNCProxyServiceTemplate.tls
- description: TLS - Parameters related to the TLS
displayName: TLS
path: metadataServiceTemplate.tls
version: v1beta1
- description: NovaScheduler is the Schema for the novaschedulers API
displayName: Nova Scheduler
kind: NovaScheduler
name: novaschedulers.nova.openstack.org
specDescriptors:
- description: TLS - Parameters related to the TLS
displayName: TLS
path: tls
version: v1beta1
description: Nova Operator
displayName: Nova Operator
Expand Down
12 changes: 12 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ rules:
- patch
- update
- watch
- apiGroups:
- mariadb.openstack.org
resources:
- mariadbaccounts
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- mariadb.openstack.org
resources:
Expand Down
11 changes: 11 additions & 0 deletions controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ const (
tlsAPIPublicField = ".spec.tls.api.public.secretName"
tlsMetadataField = ".spec.tls.secretName"
tlsNoVNCProxyField = ".spec.tls.secretName"

// NovaAPIDatabaseName is the name of the DB schema created for the
// top level nova DB
NovaAPIDatabaseName = "nova_api"
// NovaCell0DatabaseName - the name of the DB to store the cell schema for
// cell0
NovaCell0DatabaseName = "nova_cell0"
)

type conditionsGetter interface {
Expand Down Expand Up @@ -532,3 +539,7 @@ func getNovaClient(
}
return computeClient.GetOSClient(), nil
}

func getCellDatabaseName(cellName string) string {
return "nova_" + cellName
}
16 changes: 9 additions & 7 deletions controllers/nova_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ func (r *NovaReconciler) GetLogger(ctx context.Context) logr.Logger {
return log.FromContext(ctx).WithName("Controllers").WithName("Nova")
}

//+kubebuilder:rbac:groups=nova.openstack.org,resources=nova,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=nova.openstack.org,resources=nova/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=nova.openstack.org,resources=nova/finalizers,verbs=update
//+kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbdatabases,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=nova.openstack.org,resources=nova,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=nova.openstack.org,resources=nova/status,verbs=get;update;patch
// +kubebuilder:rbac:groups=nova.openstack.org,resources=nova/finalizers,verbs=update
// +kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbdatabases,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=mariadb.openstack.org,resources=mariadbaccounts,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=keystone.openstack.org,resources=keystoneapis,verbs=get;list;watch;
// +kubebuilder:rbac:groups=keystone.openstack.org,resources=keystoneservices,verbs=get;list;watch;create;update;patch;delete;
// +kubebuilder:rbac:groups=keystone.openstack.org,resources=keystoneendpoints,verbs=get;list;watch;create;update;patch;delete;
Expand Down Expand Up @@ -676,13 +677,13 @@ func (r *NovaReconciler) ensureNovaManageJobSecret(
"nova_keystone_user": cell.Spec.ServiceUser,
"nova_keystone_password": string(ospSecret.Data[instance.Spec.PasswordSelectors.Service]),
// cell.Spec.APIDatabaseUser is empty for cells without APIDB access
"api_db_name": instance.Spec.APIDatabaseUser, // fixme
"api_db_name": NovaAPIDatabaseName,
"api_db_user": instance.Spec.APIDatabaseUser,
"api_db_password": string(ospSecret.Data[instance.Spec.PasswordSelectors.APIDatabase]),
// cell.Spec.APIDatabaseHostname is empty for cells without APIDB access
"api_db_address": apiDBHostname,
"api_db_port": 3306,
"cell_db_name": cell.Spec.CellDatabaseUser, // fixme
"cell_db_name": getCellDatabaseName(cell.Spec.CellName),
"cell_db_user": cell.Spec.CellDatabaseUser,
"cell_db_password": string(ospSecret.Data[cellTemplate.PasswordSelectors.Database]),
"cell_db_address": cell.Spec.CellDatabaseHostname,
Expand Down Expand Up @@ -767,7 +768,7 @@ func (r *NovaReconciler) ensureAPIDB(
instance *novav1.Nova,
) (*mariadbv1.Database, nova.DatabaseStatus, error) {
apiDB := mariadbv1.NewDatabaseWithNamespace(
nova.NovaAPIDatabaseName,
NovaAPIDatabaseName,
instance.Spec.APIDatabaseUser,
instance.Spec.Secret,
map[string]string{
Expand Down Expand Up @@ -1702,6 +1703,7 @@ func (r *NovaReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&novav1.Nova{}).
Owns(&mariadbv1.MariaDBDatabase{}).
Owns(&mariadbv1.MariaDBAccount{}).
Owns(&keystonev1.KeystoneService{}).
Owns(&novav1.NovaAPI{}).
Owns(&novav1.NovaScheduler{}).
Expand Down
4 changes: 2 additions & 2 deletions controllers/novaapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,12 @@ func (r *NovaAPIReconciler) generateConfigs(
"www_authenticate_uri": instance.Spec.KeystonePublicAuthURL,
"nova_keystone_user": instance.Spec.ServiceUser,
"nova_keystone_password": string(secret.Data[ServicePasswordSelector]),
"api_db_name": instance.Spec.APIDatabaseUser, // fixme
"api_db_name": NovaAPIDatabaseName,
"api_db_user": instance.Spec.APIDatabaseUser,
"api_db_password": string(secret.Data[APIDatabasePasswordSelector]),
"api_db_address": instance.Spec.APIDatabaseHostname,
"api_db_port": 3306,
"cell_db_name": instance.Spec.Cell0DatabaseUser, // fixme
"cell_db_name": NovaCell0DatabaseName,
"cell_db_user": instance.Spec.Cell0DatabaseUser,
"cell_db_password": string(secret.Data[CellDatabasePasswordSelector]),
"cell_db_address": instance.Spec.Cell0DatabaseHostname,
Expand Down
4 changes: 2 additions & 2 deletions controllers/novaconductor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (r *NovaConductorReconciler) generateConfigs(
"keystone_internal_url": instance.Spec.KeystoneAuthURL,
"nova_keystone_user": instance.Spec.ServiceUser,
"nova_keystone_password": string(secret.Data[ServicePasswordSelector]),
"cell_db_name": instance.Spec.CellDatabaseUser, // fixme
"cell_db_name": getCellDatabaseName(instance.Spec.CellName),
"cell_db_user": instance.Spec.CellDatabaseUser,
"cell_db_password": string(secret.Data[CellDatabasePasswordSelector]),
"cell_db_address": instance.Spec.CellDatabaseHostname,
Expand All @@ -352,7 +352,7 @@ func (r *NovaConductorReconciler) generateConfigs(
"transport_url": string(secret.Data[TransportURLSelector]),
}
if len(instance.Spec.APIDatabaseHostname) > 0 && len(instance.Spec.APIDatabaseUser) > 0 {
templateParameters["api_db_name"] = instance.Spec.APIDatabaseUser // fixme
templateParameters["api_db_name"] = NovaAPIDatabaseName
templateParameters["api_db_user"] = instance.Spec.APIDatabaseUser
templateParameters["api_db_password"] = string(secret.Data[APIDatabasePasswordSelector])
templateParameters["api_db_address"] = instance.Spec.APIDatabaseHostname
Expand Down
5 changes: 3 additions & 2 deletions controllers/novametadata_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ func (r *NovaMetadataReconciler) generateConfigs(
"keystone_internal_url": instance.Spec.KeystoneAuthURL,
"nova_keystone_user": instance.Spec.ServiceUser,
"nova_keystone_password": string(secret.Data[ServicePasswordSelector]),
"cell_db_name": instance.Spec.CellDatabaseUser, // fixme
"cell_db_name": NovaCell0DatabaseName,
"cell_db_user": instance.Spec.CellDatabaseUser,
"cell_db_password": string(secret.Data[CellDatabasePasswordSelector]),
"cell_db_address": instance.Spec.CellDatabaseHostname,
Expand All @@ -396,14 +396,15 @@ func (r *NovaMetadataReconciler) generateConfigs(
}

if instance.Spec.CellName == "" {
templateParameters["api_db_name"] = instance.Spec.APIDatabaseUser // fixme
templateParameters["api_db_name"] = NovaAPIDatabaseName
templateParameters["api_db_user"] = instance.Spec.APIDatabaseUser // fixme
templateParameters["api_db_password"] = string(secret.Data[APIDatabasePasswordSelector])
templateParameters["api_db_address"] = instance.Spec.APIDatabaseHostname
templateParameters["api_db_port"] = 3306
templateParameters["local_metadata_per_cell"] = false
} else {
templateParameters["local_metadata_per_cell"] = true
templateParameters["cell_db_name"] = getCellDatabaseName(instance.Spec.CellName)
}

// create httpd tls template parameters
Expand Down
2 changes: 1 addition & 1 deletion controllers/novanovncproxy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func (r *NovaNoVNCProxyReconciler) generateConfigs(
"keystone_internal_url": instance.Spec.KeystoneAuthURL,
"nova_keystone_user": instance.Spec.ServiceUser,
"nova_keystone_password": string(secret.Data[ServicePasswordSelector]),
"cell_db_name": instance.Spec.CellDatabaseUser, // fixme
"cell_db_name": getCellDatabaseName(instance.Spec.CellName),
"cell_db_user": instance.Spec.CellDatabaseUser,
"cell_db_password": string(secret.Data[CellDatabasePasswordSelector]),
"cell_db_address": instance.Spec.CellDatabaseHostname,
Expand Down
4 changes: 2 additions & 2 deletions controllers/novascheduler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,12 @@ func (r *NovaSchedulerReconciler) generateConfigs(
"keystone_internal_url": instance.Spec.KeystoneAuthURL,
"nova_keystone_user": instance.Spec.ServiceUser,
"nova_keystone_password": string(secret.Data[ServicePasswordSelector]),
"api_db_name": instance.Spec.APIDatabaseUser, // fixme
"api_db_name": NovaAPIDatabaseName,
"api_db_user": instance.Spec.APIDatabaseUser,
"api_db_password": string(secret.Data[APIDatabasePasswordSelector]),
"api_db_address": instance.Spec.APIDatabaseHostname,
"api_db_port": 3306,
"cell_db_name": instance.Spec.Cell0DatabaseUser, // fixme
"cell_db_name": NovaCell0DatabaseName,
"cell_db_user": instance.Spec.Cell0DatabaseUser,
"cell_db_password": string(secret.Data[CellDatabasePasswordSelector]),
"cell_db_address": instance.Spec.Cell0DatabaseHostname,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240122121228-01dfaafeef46
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240122121228-01dfaafeef46
github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20240122121228-01dfaafeef46
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.0
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240131125539-dd95ba886c6c
github.com/openstack-k8s-operators/nova-operator/api v0.0.0-20221209164002-f9e6b9363961
go.uber.org/zap v1.26.0
gopkg.in/yaml.v3 v3.0.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.2024012
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240122121228-01dfaafeef46/go.mod h1:GammFyM5i2OY0lBEAcyEi9Gk46jXFIlD+z+JqBikfoY=
github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20240122121228-01dfaafeef46 h1:7L/STiEV9rcC0uhnPU6FRVox8J3L2d24/z8yK7rQ5Dc=
github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20240122121228-01dfaafeef46/go.mod h1:ni4mvKeubWsTjKmcToJ+hIo7pJipM9hwiUv8qhm1R6Y=
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.0 h1:FB0xB6whYM6W4XIncYo2mPiOJWkFsIOWtCT+UOtvOaQ=
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.0/go.mod h1:xhiz5wFdKWwVM7BF/VYon4TT3NuUPXp/Pyn2hWcp0CE=
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240131125539-dd95ba886c6c h1:7Au1vBMTIvsoRZSUinMkLhJvvxjFy6gj928JOgoQkuw=
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240131125539-dd95ba886c6c/go.mod h1:gAIo5SMvTTgUomxGC51T3PHIyremhe8xUvz2xpbuCsI=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
5 changes: 0 additions & 5 deletions pkg/nova/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ import (
const (
// KollaServiceCommand - the command to start the service binary in the kolla container
KollaServiceCommand = "/usr/local/bin/kolla_start"
// NovaAPIDatabaseName - the name of the DB to store tha API schema
NovaAPIDatabaseName = "nova_api"
// NovaCell0DatabaseName - the name of the DB to store the cell schema for
// cell0
NovaCell0DatabaseName = "nova_cell0"
// NovaUserID is the linux user ID used by Kolla for the nova user
// in the service containers
NovaUserID int64 = 42436
Expand Down
Loading

0 comments on commit 226c8da

Please sign in to comment.