Skip to content

Commit 0a8bdb1

Browse files
committed
Allow nova_api_audit_map.conf in DefaultConfigOverride
Allow providing a nova_api_audit_map.conf file through the DefaultConfigOverride to NovaAPI. Conditionally configure the audit_middleware_notifications.use_oslo_messaging based on if notification_transport_url is defined or not. This is being tested in functional tests, kuttl tests and the nova-operator-tempest-multinode test job. Closes: https://redhat.atlassian.net/browse/OSPRH-29237
1 parent 444a265 commit 0a8bdb1

14 files changed

Lines changed: 384 additions & 15 deletions

File tree

api/bases/nova.openstack.org_nova.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ spec:
7575
additionalProperties:
7676
type: string
7777
description: DefaultConfigOverwrite - interface to overwrite default
78-
config files like e.g. api-paste.ini or policy.yaml.
78+
config files like e.g. api-paste.ini, policy.yaml or nova_api_audit_map.conf.
7979
type: object
8080
networkAttachments:
8181
description: NetworkAttachments is a list of NetworkAttachment

api/bases/nova.openstack.org_novaapis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ spec:
8989
additionalProperties:
9090
type: string
9191
description: DefaultConfigOverwrite - interface to overwrite default
92-
config files like e.g. api-paste.ini or policy.yaml.
92+
config files like e.g. api-paste.ini, policy.yaml or nova_api_audit_map.conf.
9393
type: object
9494
keystoneAuthURL:
9595
description: |-

api/nova/v1beta1/novaapi_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type NovaAPITemplate struct {
5454
CustomServiceConfig string `json:"customServiceConfig"`
5555

5656
// +kubebuilder:validation:Optional
57-
// DefaultConfigOverwrite - interface to overwrite default config files like e.g. api-paste.ini or policy.yaml.
57+
// DefaultConfigOverwrite - interface to overwrite default config files like e.g. api-paste.ini, policy.yaml or nova_api_audit_map.conf.
5858
DefaultConfigOverwrite map[string]string `json:"defaultConfigOverwrite,omitempty"`
5959

6060
// +kubebuilder:validation:Optional
@@ -171,7 +171,7 @@ type NovaAPISpec struct {
171171
TLS tls.API `json:"tls,omitempty"`
172172

173173
// +kubebuilder:validation:Optional
174-
// DefaultConfigOverwrite - interface to overwrite default config files like e.g. api-paste.ini or policy.yaml.
174+
// DefaultConfigOverwrite - interface to overwrite default config files like e.g. api-paste.ini, policy.yaml or nova_api_audit_map.conf.
175175
DefaultConfigOverwrite map[string]string `json:"defaultConfigOverwrite,omitempty"`
176176

177177
// +kubebuilder:validation:Required

api/nova/v1beta1/novaapi_webhook.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func ValidateAPIDefaultConfigOverwrite(
148148
return ValidateDefaultConfigOverwrite(
149149
basePath,
150150
defaultConfigOverwrite,
151-
[]string{"policy.yaml", "api-paste.ini"})
151+
[]string{"policy.yaml", "api-paste.ini", "nova_api_audit_map.conf"})
152152
}
153153

154154
// ValidateTopology validates the referenced TopoRef.Namespace.

ci/nova-operator-tempest-multinode/control_plane_hook.yaml

Lines changed: 175 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
- target:
2121
kind: OpenStackControlPlane
2222
patch: |-
23-
- op: replace
24-
path: /spec/nova/template/apiServiceTemplate/replicas
25-
value: 2
26-
2723
- op: add
2824
path: /spec/nova/template/apiMessageBusInstance
2925
value: ""
@@ -82,3 +78,178 @@
8278
- op: add
8379
path: /spec/nova/template/metadataServiceTemplate/enabled
8480
value: false
81+
82+
- op: add
83+
path: /spec/nova/template/apiServiceTemplate
84+
value:
85+
defaultConfigOverwrite:
86+
api-paste.ini: |
87+
############
88+
# Metadata #
89+
############
90+
[composite:metadata]
91+
use = egg:Paste#urlmap
92+
/: meta
93+
94+
[pipeline:meta]
95+
pipeline = cors http_proxy_to_wsgi metaapp
96+
97+
[app:metaapp]
98+
paste.app_factory = nova.api.metadata.handler:MetadataRequestHandler.factory
99+
100+
#############
101+
# OpenStack #
102+
#############
103+
104+
[composite:osapi_compute]
105+
use = call:nova.api.openstack.urlmap:urlmap_factory
106+
/: oscomputeversions
107+
/v2: oscomputeversion_legacy_v2
108+
/v2.1: oscomputeversion_v2
109+
/v2/+: openstack_compute_api_v21_legacy_v2_compatible
110+
/v2.1/+: openstack_compute_api_v21
111+
112+
[composite:openstack_compute_api_v21]
113+
use = call:nova.api.auth:pipeline_factory_v21
114+
keystone = cors http_proxy_to_wsgi compute_req_id faultwrap request_log sizelimit osprofiler authtoken keystonecontext audit osapi_compute_app_v21
115+
noauth2 = cors http_proxy_to_wsgi compute_req_id faultwrap request_log sizelimit osprofiler noauth2 audit osapi_compute_app_v21
116+
117+
[composite:openstack_compute_api_v21_legacy_v2_compatible]
118+
use = call:nova.api.auth:pipeline_factory_v21
119+
keystone = cors http_proxy_to_wsgi compute_req_id faultwrap request_log sizelimit osprofiler authtoken keystonecontext legacy_v2_compatible audit osapi_compute_app_v21
120+
noauth2 = cors http_proxy_to_wsgi compute_req_id faultwrap request_log sizelimit osprofiler noauth2 legacy_v2_compatible audit osapi_compute_app_v21
121+
122+
[filter:request_log]
123+
paste.filter_factory = nova.api.openstack.requestlog:RequestLog.factory
124+
125+
[filter:compute_req_id]
126+
paste.filter_factory = nova.api.compute_req_id:ComputeReqIdMiddleware.factory
127+
128+
[filter:faultwrap]
129+
paste.filter_factory = nova.api.openstack:FaultWrapper.factory
130+
131+
[filter:noauth2]
132+
paste.filter_factory = nova.api.openstack.auth:NoAuthMiddleware.factory
133+
134+
[filter:osprofiler]
135+
paste.filter_factory = nova.profiler:WsgiMiddleware.factory
136+
137+
[filter:sizelimit]
138+
paste.filter_factory = oslo_middleware:RequestBodySizeLimiter.factory
139+
140+
[filter:http_proxy_to_wsgi]
141+
paste.filter_factory = oslo_middleware.http_proxy_to_wsgi:HTTPProxyToWSGI.factory
142+
143+
[filter:legacy_v2_compatible]
144+
paste.filter_factory = nova.api.openstack:LegacyV2CompatibleWrapper.factory
145+
146+
[app:osapi_compute_app_v21]
147+
paste.app_factory = nova.api.openstack.compute:APIRouterV21.factory
148+
149+
[pipeline:oscomputeversions]
150+
pipeline = cors faultwrap request_log http_proxy_to_wsgi oscomputeversionapp
151+
152+
[pipeline:oscomputeversion_v2]
153+
pipeline = cors compute_req_id faultwrap request_log http_proxy_to_wsgi oscomputeversionapp_v2
154+
155+
[pipeline:oscomputeversion_legacy_v2]
156+
pipeline = cors compute_req_id faultwrap request_log http_proxy_to_wsgi legacy_v2_compatible oscomputeversionapp_v2
157+
158+
[app:oscomputeversionapp]
159+
paste.app_factory = nova.api.openstack.compute.versions:Versions.factory
160+
161+
[app:oscomputeversionapp_v2]
162+
paste.app_factory = nova.api.openstack.compute.versions:VersionsV2.factory
163+
164+
##########
165+
# Shared #
166+
##########
167+
168+
[filter:cors]
169+
paste.filter_factory = oslo_middleware.cors:filter_factory
170+
oslo_config_project = nova
171+
172+
[filter:keystonecontext]
173+
paste.filter_factory = nova.api.auth:NovaKeystoneContext.factory
174+
175+
[filter:authtoken]
176+
paste.filter_factory = keystonemiddleware.auth_token:filter_factory
177+
178+
[filter:audit]
179+
paste.filter_factory = keystonemiddleware.audit:filter_factory
180+
audit_map_file = /etc/nova/nova_api_audit_map.conf
181+
use_oslo_messaging = false
182+
log_name = nova.audit
183+
nova_api_audit_map.conf: |
184+
[DEFAULT]
185+
target_endpoint_type = None
186+
187+
[custom_actions]
188+
enable = enable
189+
disable = disable
190+
delete = delete
191+
startup = start/startup
192+
shutdown = stop/shutdown
193+
reboot = start/reboot
194+
os-migrations/get = read
195+
os-server-password/post = update
196+
197+
[path_keywords]
198+
add = None
199+
action = None
200+
enable = None
201+
disable = None
202+
configure-project = None
203+
defaults = None
204+
delete = None
205+
detail = None
206+
diagnostics = None
207+
entries = entry
208+
extensions = alias
209+
flavors = flavor
210+
images = image
211+
ips = label
212+
limits = None
213+
metadata = key
214+
os-agents = os-agent
215+
os-aggregates = os-aggregate
216+
os-availability-zone = None
217+
os-certificates = None
218+
os-cloudpipe = None
219+
os-fixed-ips = ip
220+
os-extra_specs = key
221+
os-flavor-access = None
222+
os-floating-ip-dns = domain
223+
os-floating-ips-bulk = host
224+
os-floating-ip-pools = None
225+
os-floating-ips = floating-ip
226+
os-hosts = host
227+
os-hypervisors = hypervisor
228+
os-instance-actions = instance-action
229+
os-keypairs = keypair
230+
os-migrations = None
231+
os-networks = network
232+
os-quota-sets = tenant
233+
os-security-groups = security_group
234+
os-security-group-rules = rule
235+
os-server-password = None
236+
os-services = None
237+
os-simple-tenant-usage = tenant
238+
os-virtual-interfaces = None
239+
os-volume_attachments = attachment
240+
os-volumes_boot = None
241+
os-volumes = volume
242+
os-volume-types = volume-type
243+
os-snapshots = snapshot
244+
reboot = None
245+
servers = server
246+
shutdown = None
247+
startup = None
248+
statistics = None
249+
250+
[service_endpoints]
251+
compute = service/compute
252+
253+
- op: replace
254+
path: /spec/nova/template/apiServiceTemplate/replicas
255+
value: 2

config/crd/bases/nova.openstack.org_nova.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ spec:
7575
additionalProperties:
7676
type: string
7777
description: DefaultConfigOverwrite - interface to overwrite default
78-
config files like e.g. api-paste.ini or policy.yaml.
78+
config files like e.g. api-paste.ini, policy.yaml or nova_api_audit_map.conf.
7979
type: object
8080
networkAttachments:
8181
description: NetworkAttachments is a list of NetworkAttachment

config/crd/bases/nova.openstack.org_novaapis.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ spec:
8989
additionalProperties:
9090
type: string
9191
description: DefaultConfigOverwrite - interface to overwrite default
92-
config files like e.g. api-paste.ini or policy.yaml.
92+
config files like e.g. api-paste.ini, policy.yaml or nova_api_audit_map.conf.
9393
type: object
9494
keystoneAuthURL:
9595
description: |-

templates/nova/api/config/nova-api-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@
8383
"dest": "/etc/my.cnf",
8484
"owner": "nova",
8585
"perm": "0644"
86+
},
87+
{
88+
"source": "/var/lib/openstack/config/nova_api_audit_map.conf",
89+
"dest": "/etc/nova/nova_api_audit_map.conf",
90+
"owner": "nova",
91+
"perm": "0600",
92+
"optional": true
8693
}
8794
],
8895
"permissions": [

templates/nova/nova.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,16 @@ compute = auto
433433
[oslo_reports]
434434
# api services need file based GMR trigger as apache disables signal handling
435435
file_event_handler=/var/lib/nova
436+
437+
{{ if eq .service_name "nova-api" }}
438+
[audit_middleware_notifications]
439+
{{ if (index . "notification_transport_url") }}
440+
use_oslo_messaging = true
441+
{{ else }}
442+
use_oslo_messaging = false
443+
{{ end }}
444+
{{ end }}
445+
436446
{{end}}
437447
{{- $var := execTempl "nova-template" . | removeNewLinesInSections -}}
438448
{{$var -}}

test/functional/nova/nova_controller_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ var _ = Describe("Nova controller - notifications", func() {
6666
Expect(configDataMap.Data).Should(HaveKey("01-nova.conf"))
6767
configData := string(configDataMap.Data["01-nova.conf"])
6868
AssertNotHaveNotificationTransportURL(configData)
69+
Expect(configData).Should(
70+
ContainSubstring(`[audit_middleware_notifications]
71+
use_oslo_messaging = false`))
6972

7073
// assert in sch conf
7174
configDataMap = th.GetSecret(novaNames.SchedulerConfigDataName)
@@ -118,6 +121,9 @@ var _ = Describe("Nova controller - notifications", func() {
118121
Expect(configDataMap.Data).Should(HaveKey("01-nova.conf"))
119122
configData := string(configDataMap.Data["01-nova.conf"])
120123
AssertHaveNotificationTransportURL(notificationsBus.TransportURLName.Name, configData)
124+
Expect(configData).Should(
125+
ContainSubstring(`[audit_middleware_notifications]
126+
use_oslo_messaging = true`))
121127

122128
// assert in sch conf
123129
configDataMap = th.GetSecret(novaNames.SchedulerConfigDataName)

0 commit comments

Comments
 (0)