@@ -33,6 +33,7 @@ import (
3333 job "github.com/openstack-k8s-operators/lib-common/modules/common/job"
3434 nad "github.com/openstack-k8s-operators/lib-common/modules/common/networkattachment"
3535 common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac"
36+ "github.com/openstack-k8s-operators/lib-common/modules/common/secret"
3637 oko_secret "github.com/openstack-k8s-operators/lib-common/modules/common/secret"
3738 "github.com/openstack-k8s-operators/lib-common/modules/common/service"
3839 "github.com/openstack-k8s-operators/lib-common/modules/common/statefulset"
@@ -415,6 +416,25 @@ func (r *IronicInspectorReconciler) findObjectsForSrc(ctx context.Context, src c
415416 return requests
416417}
417418
419+ func (r * IronicInspectorReconciler ) getTransportURL (
420+ ctx context.Context ,
421+ h * helper.Helper ,
422+ instance * ironicv1.IronicInspector ,
423+ ) (string , error ) {
424+ if instance .Spec .RPCTransport != "oslo" {
425+ return "fake://" , nil
426+ }
427+ transportURLSecret , _ , err := secret .GetSecret (ctx , h , instance .Status .TransportURLSecret , instance .Namespace )
428+ if err != nil {
429+ return "" , err
430+ }
431+ transportURL , ok := transportURLSecret .Data ["transport_url" ]
432+ if ! ok {
433+ return "" , fmt .Errorf ("transport_url %w Transport Secret" , util .ErrNotFound )
434+ }
435+ return string (transportURL ), nil
436+ }
437+
418438func (r * IronicInspectorReconciler ) reconcileTransportURL (
419439 ctx context.Context ,
420440 instance * ironicv1.IronicInspector ,
@@ -589,15 +609,9 @@ func (r *IronicInspectorReconciler) reconcileConfigMapsAndSecrets(
589609 // calculate an overall hash of hashes
590610 //
591611
592- //
593- // create Configmap required for ironic input
594- // - %-scripts configmap holding scripts to e.g. bootstrap the service
595- // - %-config configmap holding minimal ironic config required to get the
596- // service up, user can add additional files to be added to the service
597- // - parameters which has passwords gets added from the OpenStack secret
598- // via the init container
599- //
600- err = r .generateServiceConfigMaps (
612+ // create Secret required for ironicInspector input. It contains minimal ironicinspector config required
613+ // to get the service up, user can add additional files to be added to the service.
614+ err = r .generateServiceSecrets (
601615 ctx ,
602616 instance ,
603617 helper ,
@@ -1411,24 +1425,16 @@ func (r *IronicInspectorReconciler) reconcileUpgrade(
14111425 return ctrl.Result {}, nil
14121426}
14131427
1414- // generateServiceConfigMaps - create create configmaps which hold scripts and service configuration
1428+ // generateServiceSecrets - create secrets which hold service configuration
14151429// TODO add DefaultConfigOverwrite
1416- func (r * IronicInspectorReconciler ) generateServiceConfigMaps (
1430+ func (r * IronicInspectorReconciler ) generateServiceSecrets (
14171431 ctx context.Context ,
14181432 instance * ironicv1.IronicInspector ,
14191433 h * helper.Helper ,
14201434 envVars * map [string ]env.Setter ,
14211435 db * mariadbv1.Database ,
14221436) error {
1423- //
1424- // create Configmap/Secret required for ironic-inspector input
1425- // - %-scripts configmap holding scripts to e.g. bootstrap the service
1426- // - %-config configmap holding minimal ironic-inspector config required
1427- // to get the service up, user can add additional files to be added to
1428- // the service
1429- // - parameters which has passwords gets added from the ospSecret via the
1430- // init container
1431- //
1437+ // Create/update secrets from templates
14321438 cmLabels := labels .GetLabels (
14331439 instance ,
14341440 labels .GetGroupLabel (ironic .ServiceName ),
@@ -1439,20 +1445,24 @@ func (r *IronicInspectorReconciler) generateServiceConfigMaps(
14391445 tlsCfg = & tls.Service {}
14401446 }
14411447 // customData hold any customization for the service.
1442- // custom.conf is going to /etc/ironic-inspector/inspector.conf.d
1443- // all other files get placed into /etc/ironic-inspector to allow
1444- // overwrite of e.g. policy.json.
1445- // TODO: make sure custom.conf can not be overwritten
1448+ // 02-inspector-custom.conf is going to /etc/ironic-inspector/inspector.conf.d
1449+ // 01-inspector.conf is going to /etc/ironic-inspector/inspector such that it gets loaded before custom one
14461450 customData := map [string ]string {
1447- common . CustomServiceConfigFileName : instance .Spec .CustomServiceConfig ,
1448- "my.cnf" : db .GetDatabaseClientConfig (tlsCfg ), //(mschuppert) for now just get the default my.cnf
1451+ "02-inspector-custom.conf" : instance .Spec .CustomServiceConfig ,
1452+ "my.cnf" : db .GetDatabaseClientConfig (tlsCfg ), //(mschuppert) for now just get the default my.cnf
14491453 }
14501454 for key , data := range instance .Spec .DefaultConfigOverwrite {
14511455 customData [key ] = data
14521456 }
14531457 templateParameters := make (map [string ]interface {})
1454- if ! instance .Spec .Standalone {
14551458
1459+ transportURL , err := r .getTransportURL (ctx , h , instance )
1460+ if err != nil {
1461+ return err
1462+ }
1463+ templateParameters ["TransportURL" ] = transportURL
1464+
1465+ if ! instance .Spec .Standalone {
14561466 keystoneAPI , err := keystonev1 .GetKeystoneAPI (
14571467 ctx , h , instance .Namespace , map [string ]string {})
14581468 if err != nil {
@@ -1466,10 +1476,24 @@ func (r *IronicInspectorReconciler) generateServiceConfigMaps(
14661476 if err != nil {
14671477 return err
14681478 }
1479+ ospSecret , _ , err := secret .GetSecret (ctx , h , instance .Spec .Secret , instance .Namespace )
1480+ if err != nil {
1481+ return err
1482+ }
1483+
1484+ servicePassword := string (ospSecret .Data [instance .Spec .PasswordSelectors .Service ])
14691485
14701486 templateParameters ["ServiceUser" ] = instance .Spec .ServiceUser
1487+ templateParameters ["ServicePassword" ] = servicePassword
14711488 templateParameters ["KeystoneInternalURL" ] = keystoneInternalURL
14721489 templateParameters ["KeystonePublicURL" ] = keystonePublicURL
1490+
1491+ // Other OpenStack services
1492+ templateParameters ["ServicePassword" ] = servicePassword
1493+ templateParameters ["keystone_authtoken" ] = servicePassword
1494+ templateParameters ["service_catalog" ] = servicePassword
1495+ templateParameters ["ironic" ] = servicePassword
1496+ templateParameters ["swift" ] = servicePassword
14731497 } else {
14741498 ironicAPI , err := ironicv1 .GetIronicAPI (
14751499 ctx , h , instance .Namespace , map [string ]string {})
0 commit comments