Skip to content

Commit 7ecda9c

Browse files
committed
Adds notification transporturl
1 parent c073a6b commit 7ecda9c

5 files changed

Lines changed: 88 additions & 31 deletions

File tree

api/v1beta1/conditions.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ const (
5252
NovaComputeServiceConfigReady condition.Type = "NovaComputeServiceConfigReady"
5353
// NovaAllControlPlaneComputesReadyCondition indicates that every defined NovaCompute is ready but undiscovered
5454
NovaAllControlPlaneComputesReadyCondition condition.Type = "NovaAllControlPlaneComputesReady"
55+
56+
// notifications
57+
// NovaNotificationMQReadyCondition indicated that the top level notification message bus is ready
58+
NovaNotificationMQReadyCondition condition.Type = "NovaNotificationMQReady"
5559
)
5660

5761
// Common Messages used by API objects.
@@ -172,4 +176,14 @@ const (
172176

173177
//CellHostDiscoverErrorMessage
174178
CellHostDiscoverErrorMessage = "CellHostDiscover error occurred %s"
179+
180+
// notifications
181+
// NovaNotificationMQReadyErrorMessage
182+
NovaNotificationMQReadyErrorMessage = "Notification message bus creation failed: %s"
183+
184+
// NovaNotificationMQReadyCreatingMessage
185+
NovaNotificationMQReadyCreatingMessage = "Notification message bus creation ongoing"
186+
187+
// NovaNotificationMQReadyMessage
188+
NovaNotificationMQReadyMessage = "Notification message bus creation successfully"
175189
)

controllers/common.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ const (
9494
MetadataSecretSelector = "MetadataSecret"
9595
// TransportURLSelector is the name of key in the internal cell
9696
// Secret for the cell message bus transport URL
97-
TransportURLSelector = "transport_url"
97+
TransportURLSelector = "transport_url"
98+
NotificationTransportURLSelector = "notificaton_transport_url"
9899

99100
// fields to index to reconcile when change
100101
passwordSecretField = ".spec.secret"

controllers/nova_controller.go

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,39 @@ func (r *NovaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
384384
return ctrl.Result{}, fmt.Errorf("%w from for the API MQ: %d", util.ErrInvalidStatus, apiMQStatus)
385385
}
386386

387+
// nova broadcaster rabbit
388+
notificationBusName := ""
389+
if instance.Spec.NotificationsBusInstance != nil {
390+
notificationBusName = *instance.Spec.NotificationsBusInstance
391+
}
392+
393+
notificationTransportURL, notificationMQStatus, notificationMQError := r.ensureMQ(
394+
ctx, h, instance, instance.Name+"-notification-transport", notificationBusName)
395+
396+
switch notificationMQStatus {
397+
case nova.MQFailed:
398+
instance.Status.Conditions.Set(condition.FalseCondition(
399+
novav1.NovaNotificationMQReadyCondition,
400+
condition.ErrorReason,
401+
condition.SeverityError,
402+
novav1.NovaNotificationMQReadyErrorMessage,
403+
notificationMQError.Error(),
404+
))
405+
case nova.MQCreating:
406+
instance.Status.Conditions.Set(condition.FalseCondition(
407+
novav1.NovaNotificationMQReadyCondition,
408+
condition.ErrorReason,
409+
condition.SeverityError,
410+
novav1.NovaNotificationMQReadyCreatingMessage,
411+
))
412+
case nova.MQCompleted:
413+
instance.Status.Conditions.MarkTrue(
414+
novav1.NovaNotificationMQReadyCondition, novav1.NovaNotificationMQReadyMessage)
415+
default:
416+
return ctrl.Result{}, fmt.Errorf("%w from for the Notification MQ: %d",
417+
util.ErrInvalidStatus, notificationMQStatus)
418+
}
419+
387420
cellMQs := map[string]*nova.MessageBus{}
388421
var failedMQs []string
389422
var creatingMQs []string
@@ -539,7 +572,11 @@ func (r *NovaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
539572
return ctrl.Result{}, nil
540573
}
541574

542-
topLevelSecretName, err := r.ensureTopLevelSecret(ctx, h, instance, apiTransportURL, secret)
575+
topLevelSecretName, err := r.ensureTopLevelSecret(
576+
ctx, h, instance,
577+
apiTransportURL,
578+
notificationTransportURL,
579+
secret)
543580
if err != nil {
544581
return ctrl.Result{}, err
545582
}
@@ -1639,6 +1676,7 @@ func (r *NovaReconciler) ensureMQ(
16391676

16401677
err = r.Client.Get(ctx, types.NamespacedName{Namespace: instance.Namespace, Name: transportName}, transportURL)
16411678
if err != nil && !k8s_errors.IsNotFound(err) {
1679+
Log.Info("", ":", "t-url-3")
16421680
return "", nova.MQFailed, util.WrapErrorForObject(
16431681
fmt.Sprintf("Error reading TransportURL object %s", transportName),
16441682
transportURL,
@@ -1651,6 +1689,7 @@ func (r *NovaReconciler) ensureMQ(
16511689
}
16521690

16531691
secretName := types.NamespacedName{Namespace: instance.Namespace, Name: transportURL.Status.SecretName}
1692+
16541693
secret := &corev1.Secret{}
16551694
err = h.GetClient().Get(ctx, secretName, secret)
16561695
if err != nil {
@@ -1665,7 +1704,6 @@ func (r *NovaReconciler) ensureMQ(
16651704
return "", nova.MQFailed, fmt.Errorf(
16661705
"%w: the TransportURL secret %s does not have 'transport_url' field", util.ErrFieldNotFound, transportURL.Status.SecretName)
16671706
}
1668-
16691707
return string(url), nova.MQCompleted, nil
16701708
}
16711709

@@ -1919,14 +1957,16 @@ func (r *NovaReconciler) ensureTopLevelSecret(
19191957
h *helper.Helper,
19201958
instance *novav1.Nova,
19211959
apiTransportURL string,
1960+
notificationTransportURL string,
19221961
externalSecret corev1.Secret,
19231962
) (string, error) {
19241963
// NOTE(gibi): We can move other sensitive data to the internal Secret from
19251964
// the subCR fields, possibly hostnames or usernames.
19261965
data := map[string]string{
1927-
ServicePasswordSelector: string(externalSecret.Data[instance.Spec.PasswordSelectors.Service]),
1928-
MetadataSecretSelector: string(externalSecret.Data[instance.Spec.PasswordSelectors.MetadataSecret]),
1929-
TransportURLSelector: apiTransportURL,
1966+
ServicePasswordSelector: string(externalSecret.Data[instance.Spec.PasswordSelectors.Service]),
1967+
MetadataSecretSelector: string(externalSecret.Data[instance.Spec.PasswordSelectors.MetadataSecret]),
1968+
TransportURLSelector: apiTransportURL,
1969+
NotificationTransportURLSelector: notificationTransportURL,
19301970
}
19311971

19321972
// NOTE(gibi): When we switch to immutable secrets then we need to include

controllers/novaapi_controller.go

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ func (r *NovaAPIReconciler) generateConfigs(
455455
if err != nil {
456456
return err
457457
}
458+
458459
apiDatabaseAccount := apiDB.GetAccount()
459460
apiDbSecret := apiDB.GetSecret()
460461

@@ -468,28 +469,29 @@ func (r *NovaAPIReconciler) generateConfigs(
468469
"keystone_internal_url": instance.Spec.KeystoneAuthURL,
469470
// NOTE(gibi): As per the definition of www_authenticate_uri this
470471
// always needs to point to the public keystone endpoint.
471-
"www_authenticate_uri": instance.Spec.KeystonePublicAuthURL,
472-
"nova_keystone_user": instance.Spec.ServiceUser,
473-
"nova_keystone_password": string(secret.Data[ServicePasswordSelector]),
474-
"api_db_name": NovaAPIDatabaseName,
475-
"api_db_user": apiDatabaseAccount.Spec.UserName,
476-
"api_db_password": string(apiDbSecret.Data[mariadbv1.DatabasePasswordSelector]),
477-
"api_db_address": instance.Spec.APIDatabaseHostname,
478-
"api_db_port": 3306,
479-
"cell_db_name": NovaCell0DatabaseName,
480-
"cell_db_user": cellDatabaseAccount.Spec.UserName,
481-
"cell_db_password": string(cellDbSecret.Data[mariadbv1.DatabasePasswordSelector]),
482-
"cell_db_address": instance.Spec.Cell0DatabaseHostname,
483-
"cell_db_port": 3306,
484-
"openstack_region_name": "regionOne", // fixme
485-
"default_project_domain": "Default", // fixme
486-
"default_user_domain": "Default", // fixme
487-
"transport_url": string(secret.Data[TransportURLSelector]),
488-
"log_file": "/var/log/nova/nova-api.log",
489-
"tls": false,
490-
"MemcachedServers": memcachedInstance.GetMemcachedServerListString(),
491-
"MemcachedServersWithInet": memcachedInstance.GetMemcachedServerListWithInetString(),
492-
"MemcachedTLS": memcachedInstance.GetMemcachedTLSSupport(),
472+
"www_authenticate_uri": instance.Spec.KeystonePublicAuthURL,
473+
"nova_keystone_user": instance.Spec.ServiceUser,
474+
"nova_keystone_password": string(secret.Data[ServicePasswordSelector]),
475+
"api_db_name": NovaAPIDatabaseName,
476+
"api_db_user": apiDatabaseAccount.Spec.UserName,
477+
"api_db_password": string(apiDbSecret.Data[mariadbv1.DatabasePasswordSelector]),
478+
"api_db_address": instance.Spec.APIDatabaseHostname,
479+
"api_db_port": 3306,
480+
"cell_db_name": NovaCell0DatabaseName,
481+
"cell_db_user": cellDatabaseAccount.Spec.UserName,
482+
"cell_db_password": string(cellDbSecret.Data[mariadbv1.DatabasePasswordSelector]),
483+
"cell_db_address": instance.Spec.Cell0DatabaseHostname,
484+
"cell_db_port": 3306,
485+
"openstack_region_name": "regionOne", // fixme
486+
"default_project_domain": "Default", // fixme
487+
"default_user_domain": "Default", // fixme
488+
"transport_url": string(secret.Data[TransportURLSelector]),
489+
"notification_transport_url": string(secret.Data[NotificationTransportURLSelector]),
490+
"log_file": "/var/log/nova/nova-api.log",
491+
"tls": false,
492+
"MemcachedServers": memcachedInstance.GetMemcachedServerListString(),
493+
"MemcachedServersWithInet": memcachedInstance.GetMemcachedServerListWithInetString(),
494+
"MemcachedTLS": memcachedInstance.GetMemcachedTLSSupport(),
493495
}
494496
// create httpd vhost template parameters
495497
httpdVhostConfig := map[string]interface{}{}

templates/nova.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ api_paste_config = /etc/nova/api-paste.ini
126126
{{end}}
127127

128128
[oslo_messaging_notifications]
129-
{{ if (index . "nova_enabled_notification") }}
130-
transport_url = {{ .nova_cell_notify_transport_url }}
129+
{{ if (index . "notification_transport_url") }}
130+
transport_url = {{ .notification_transport_url }}
131131
driver = messagingv2
132-
notification_format=versioned
132+
notification_format=both
133133
{{ else }}
134134
driver = noop
135135
{{end}}

0 commit comments

Comments
 (0)