Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes whitespaces and newline in nova conf template #842

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 81 additions & 77 deletions templates/nova.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,52 @@
# overall then serializing live migrations so set this to 1 explictly
max_concurrent_live_migrations=1
state_path = /var/lib/nova
{{if eq .service_name "nova-api"}}
{{ if eq .service_name "nova-api" -}}
allow_resize_to_same_host = true
{{end}}
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can work and it's what i originally tried and abandoned last year but I'm not sure we want to commit to doing this.

the other option that we briefly discussed was post-processing the template and removing any instance of multiple newlines with a single new line.

if we make this change using the template timing feature then i want an env test tests for this to assert we do not have multiple consecutive new lines to catch any template changes that may miss the trimming and reintroduce this issue.

Copy link
Contributor Author

@auniyal61 auniyal61 Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

he other option that we briefly discussed was post-processing the template and removing any instance of multiple newlines with a single new line.

yeah I tried that earlier, replaice "\n\n\n+" with "\n".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I tried it in inside a test,
@SeanMooney can you please suggest if we go with this approach, at what place should we make final changes .

i.e once we are sure, final nova.conf(s) are ready to format.
I think the foratting is dones here, but not sure at what point/place nova-operator can update this.
https://github.com/openstack-k8s-operators/lib-common/blob/bd202c880706adfbcc64ee4a57e877503a274a69/modules/common/util/template_util.go#L138

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the current output still has plenty of whitespace even after the template tunining I would suggest to try to reduce that as a post processing step as discussed here.

The utils.Template type we use to pass the template to lib-common already has optional flags like https://github.com/openstack-k8s-operators/lib-common/blob/0ae9f7f9e059a903b1c47119ed05aa509f8afb77/modules/common/util/template_util.go#L58 So I think it would be OK to add an optional postProcessing function callback to that type that gets the rendered text and return a new text. The default can be a simple identity that returns the text unchanged. Then nova-operator can hook into the lib-common code and do the whitespace reduction on the rendered text. (It would be even better to split up the monolithic secret.EnsureSecrets lib-common function that the template rendering and the secret creation can be composed on the client side.)

@auniyal61 you can put replace line into go.mod to depend on an unmerged lib-common patch to be able to show that the lib-common change works with nova-operator and to show how the config would look.

# enable log rotation in oslo config by default
max_logfile_count=1
max_logfile_size_mb=20
log_rotation_type=size
{{if (index . "log_file") }}
{{- if (index . "log_file") -}}
log_file = {{ .log_file }}
{{end}}
{{- end }}
debug=true
{{if eq .service_name "nova-compute"}}
{{- if eq .service_name "nova-compute" -}}
compute_driver = {{ .compute_driver }}
{{if eq .compute_driver "ironic.IronicDriver"}}
{{ if eq .compute_driver "ironic.IronicDriver" -}}
reserved_host_memory_mb = 0
{{end}}
{{ if (index . "enable_ceilometer") }}
{{- end }}
{{- if (index . "enable_ceilometer") -}}
instance_usage_audit = true
instance_usage_audit_period = hour
{{end}}
{{- end }}
# ensure safe defaults for new hosts
initial_cpu_allocation_ratio=4.0
initial_ram_allocation_ratio=1.0
initial_disk_allocation_ratio=0.9
{{/*using a config drive will void issues with ovn and metadata*/}}
force_config_drive=True
{{end}}
{{ if (index . "transport_url") }}
{{- end }}
{{ if (index . "transport_url") -}}
transport_url={{.transport_url}}
{{end}}
{{if eq .service_name "nova-api"}}
{{- end }}
{{- if eq .service_name "nova-api" -}}
# scaling should be done by running more pods
osapi_compute_workers=1
enabled_apis=osapi_compute
{{else if eq .service_name "nova-metadata"}}
{{- else if eq .service_name "nova-metadata" -}}
# scaling should be done by running more pods
metadata_workers=1
enabled_apis=metadata
{{end}}
{{if eq .service_name "nova-novncproxy"}}
{{ if (index . "SSLCertificateFile") }}
{{- end }}
{{- if eq .service_name "nova-novncproxy" -}}
{{- if (index . "SSLCertificateFile") -}}
ssl_only=true
cert={{.SSLCertificateFile}}
key={{.SSLCertificateKeyFile}}
{{end}}
{{end}}
{{- end -}}
{{- end }}

[oslo_concurrency]
lock_path = /var/lib/nova/tmp
Expand All @@ -59,29 +59,29 @@ amqp_auto_delete=false
# we should consider using quorum queues instead
# rabbit_quorum_queue=true
{{/*we might just want to make this always false*/}}
{{ if eq .service_name "nova-api"}}
{{ if eq .service_name "nova-api" -}}
# We cannot set this to true while is
# https://review.opendev.org/c/openstack/oslo.log/+/852443 is not used in the
# nova-api image otherwise logging from the heartbeat thread will cause hangs.
heartbeat_in_pthread=false
{{else}}
{{- else -}}
heartbeat_in_pthread=false
{{end}}
{{- end }}

{{ if eq .service_name "nova-api"}}
{{- if eq .service_name "nova-api" -}}
[oslo_policy]
enforce_new_defaults=true
enforce_scope=true
policy_file=/etc/nova/policy.yaml
{{end}}
{{- end -}}

{{ if eq .service_name "nova-conductor"}}
{{- if eq .service_name "nova-conductor" -}}
[conductor]
# scaling should be done by running more pods
workers=1
{{end}}
{{- end -}}

{{ if eq .service_name "nova-scheduler"}}
{{ if eq .service_name "nova-scheduler" -}}
[filter_scheduler]
available_filters = nova.scheduler.filters.all_filters
enabled_filters = AggregateInstanceExtraSpecsFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,SameHostFilter,DifferentHostFilter,PciPassthroughFilter,NUMATopologyFilter
Expand All @@ -100,56 +100,59 @@ query_placement_for_availability_zone=true
query_placement_for_image_type_support=true
enable_isolated_aggregate_filtering=true
image_metadata_prefilter=true
{{- end }}

{{end}}

{{if eq .service_name "nova-novncproxy"}}
{{- if eq .service_name "nova-novncproxy" -}}
[console]
ssl_minimum_version=tlsv1_3
{{end}}
{{- end }}

[api]
# for compatibility with older release we override the default
# to be the empty string. This ensures no domain suffix is added
# to the instance name.
dhcp_domain = ''
{{if eq .service_name "nova-api" "nova-metadata"}}
{{ if eq .service_name "nova-api" "nova-metadata" -}}
auth_strategy = keystone
{{ if eq .service_name "nova-metadata"}}
{{- if eq .service_name "nova-metadata" -}}
local_metadata_per_cell = {{ .local_metadata_per_cell }}
{{end}}
{{- end }}

[oslo_middleware]
enable_proxy_headers_parsing = True

[wsgi]
api_paste_config = /etc/nova/api-paste.ini
{{end}}
{{- end }}


[oslo_messaging_notifications]
{{ if (index . "nova_enabled_notification") }}
{{ if (index . "nova_enabled_notification") -}}
transport_url = {{ .nova_cell_notify_transport_url }}
driver = messagingv2
notification_format=versioned
{{ else }}
{{- else -}}
driver = noop
{{end}}
{{- end }}

{{if (index . "enable_ceilometer") }}
{{ if (index . "enable_ceilometer") -}}
[notifications]
notify_on_state_change = vm_and_task_state
{{ end }}
{{- end }}


{{ if eq .service_name "nova-novncproxy"}}
{{ if eq .service_name "nova-novncproxy" -}}
[vnc]
enabled = True
novncproxy_host = "::0"
novncproxy_port = 6080
{{if (index . "VencryptClientKey") }}
{{- if (index . "VencryptClientKey") -}}
auth_schemes=vencrypt,none
vencrypt_client_key=/etc/pki/tls/private/vencrypt.key
vencrypt_client_cert=/etc/pki/tls/certs/vencrypt.crt
vencrypt_ca_certs=/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
{{end}}
{{ else if and (eq .service_name "nova-compute") .vnc_enabled }}
{{- end -}}
{{- else if and (eq .service_name "nova-compute") .vnc_enabled -}}
[vnc]
enabled = True
novncproxy_base_url = {{ .novncproxy_base_url }}
Expand All @@ -159,45 +162,45 @@ server_listen = "::0"
# dns currently so we need to use my_ip for now.
# https://docs.openstack.org/nova/latest/configuration/config.html#DEFAULT.console_host
server_proxyclient_address = "$my_ip"
{{else if and (eq .service_name "nova-compute") (not .vnc_enabled) }}
{{ else if and (eq .service_name "nova-compute") (not .vnc_enabled) -}}
[vnc]
enabled = False
{{end}}
{{- end }}


[cache]
# always enable caching
enabled = True
{{if (index . "MemcachedServers")}}
{{ if (index . "MemcachedServers") -}}
# on contoler we prefer to use memcache when its deployed
{{if .MemcachedTLS}}
{{ if .MemcachedTLS -}}
backend = dogpile.cache.pymemcache
{{else}}
{{- else -}}
backend = dogpile.cache.memcached
{{end}}
{{- end -}}
memcache_servers={{ .MemcachedServers }}
tls_enabled={{ .MemcachedTLS }}
{{else}}
{{- else -}}
# on compute nodes or where memcache is not deployed we should use an in memory
# dict cache
backend = oslo_cache.dict
{{end}}
{{- end }}

{{ if eq .service_name "nova-scheduler"}}
{{ if eq .service_name "nova-scheduler" -}}
[workarounds]
disable_fallback_pcpu_query=true
{{end}}
{{ if eq .service_name "nova-compute"}}
{{- end }}
{{ if eq .service_name "nova-compute" -}}
[workarounds]
enable_qemu_monitor_announce_self=true
reserve_disk_resource_for_image_cache=true
# NOTE(gibi): We need this as live migration does not work with
# cpu_mode=host-model . See https://bugs.launchpad.net/nova/+bug/2039803
skip_cpu_compare_on_dest = true
{{end}}

{{- end }}

{{ if eq .service_name "nova-compute" }}
{{ if eq .compute_driver "libvirt.LibvirtDriver" }}
{{ if eq .service_name "nova-compute" -}}
{{- if eq .compute_driver "libvirt.LibvirtDriver" -}}
[libvirt]
live_migration_permit_post_copy=true
live_migration_permit_auto_converge=true
Expand All @@ -216,27 +219,26 @@ live_migration_uri = qemu+ssh://nova@%s/system?keyfile=/var/lib/nova/.ssh/ssh-pr
# https://issues.redhat.com/browse/OSPRH-8806
# https://issues.redhat.com/browse/OSPRH-8712
cpu_power_management=false
{{end}}
{{end}}
{{- end -}}
{{- end}}

{{if (index . "cell_db_address")}}
{{ if (index . "cell_db_address") -}}
[database]
connection = mysql+pymysql://{{ .cell_db_user }}:{{ .cell_db_password}}@{{ .cell_db_address }}/{{ .cell_db_name }}?read_default_file=/etc/my.cnf
{{end}}
{{- end }}


{{if (index . "api_db_address")}}
{{- if (index . "api_db_address") -}}
[api_database]
connection = mysql+pymysql://{{ .api_db_user }}:{{ .api_db_password }}@{{ .api_db_address }}/{{ .api_db_name }}?read_default_file=/etc/my.cnf
{{end}}
{{- end }}

[keystone_authtoken]
{{ if eq .service_name "nova-api"}}
{{ if eq .service_name "nova-api" -}}
www_authenticate_uri = {{ .www_authenticate_uri}}
{{end}}
{{if (index . "MemcachedServersWithInet")}}
{{- end -}}
{{- if (index . "MemcachedServersWithInet") -}}
memcached_servers={{ .MemcachedServersWithInet }}
{{end}}
{{- end }}
auth_url = {{ .keystone_internal_url }}
auth_type = password
project_domain_name = {{ .default_project_domain }}
Expand Down Expand Up @@ -271,7 +273,9 @@ username = {{ .nova_keystone_user }}
password = {{ .nova_keystone_password }}
region_name = {{ .openstack_region_name }}
valid_interfaces = internal
{{if (index . "debug") }}debug=true{{end}}
{{ if (index . "debug") -}}
debug=true
{{- end }}

[neutron]
auth_url = {{ .keystone_internal_url }}
Expand All @@ -283,9 +287,9 @@ username = {{ .nova_keystone_user }}
password = {{ .nova_keystone_password }}
region_name = {{ .openstack_region_name }}
valid_interfaces = internal
{{if eq .service_name "nova-metadata"}}
{{ if eq .service_name "nova-metadata" -}}
metadata_proxy_shared_secret = {{ .metadata_secret }}
{{end}}
{{- end -}}
service_metadata_proxy = true

[cinder]
Expand Down Expand Up @@ -320,8 +324,8 @@ project_name = service
username = {{ .nova_keystone_user }}
password = {{ .nova_keystone_password }}

{{ if (index . "compute_driver") }}
{{if eq .compute_driver "ironic.IronicDriver"}}
{{- if (index . "compute_driver") -}}
{{- if eq .compute_driver "ironic.IronicDriver" -}}
[ironic]
auth_type = password
auth_url = {{ .keystone_internal_url }}
Expand All @@ -330,8 +334,8 @@ username = {{ .nova_keystone_user }}
password = {{ .nova_keystone_password }}
project_domain_name = {{ .default_project_domain }}
user_domain_name = {{ .default_user_domain}}
{{ end }}
{{ end }}
{{- end -}}
{{- end }}

[upgrade_levels]
compute = auto
Expand Down
Loading