From bf434ffd67cc550856d4325bab276d87fb0853a7 Mon Sep 17 00:00:00 2001 From: Tin Lam Date: Fri, 13 Dec 2019 16:16:22 -0600 Subject: [PATCH] Add capability for using FQDN in nova compute This patch set adds in a capability for the user to defaultly use a FQDN for the nova compute hostname and the hypervisor hostname when the host is not explicitly specified in the .Values.conf override. Change-Id: I3243068dfe91ebb97b3885002296a0f454822ec5 Co-authored-by: Drew Walters Signed-off-by: Tin Lam --- nova/templates/bin/_health-probe.py.tpl | 19 +++++++++++++++---- nova/templates/bin/_nova-compute-init.sh.tpl | 7 +++++++ nova/templates/bin/_nova-compute.sh.tpl | 5 ++++- nova/templates/daemonset-compute.yaml | 6 ++++++ nova/values.yaml | 8 ++++++++ .../component/compute-kit/compute-kit.sh | 1 + zuul.d/project.yaml | 3 ++- 7 files changed, 43 insertions(+), 6 deletions(-) diff --git a/nova/templates/bin/_health-probe.py.tpl b/nova/templates/bin/_health-probe.py.tpl index 423326361f..2cde2d42c9 100644 --- a/nova/templates/bin/_health-probe.py.tpl +++ b/nova/templates/bin/_health-probe.py.tpl @@ -46,13 +46,22 @@ import oslo_messaging tcp_established = "ESTABLISHED" +def _get_hostname(topic, use_fqdn): + if use_fqdn and topic == "compute": + return socket.getfqdn() + return socket.gethostname() + + def check_service_status(transport): """Verify service status. Return success if service consumes message""" try: - target = oslo_messaging.Target(topic=cfg.CONF.service_queue_name, - server=socket.gethostname(), - namespace='baseapi', - version="1.1") + service_queue_name = cfg.CONF.service_queue_name + use_fqdn = cfg.CONF.use_fqdn + target = oslo_messaging.Target( + topic=service_queue_name, + server=_get_hostname(service_queue_name, use_fqdn), + namespace='baseapi', + version="1.1") client = oslo_messaging.RPCClient(transport, target, timeout=60, retry=2) @@ -191,6 +200,8 @@ def test_rpc_liveness(): required=False)) cfg.CONF.register_cli_opt(cfg.BoolOpt('check-all-pids', default=False, required=False)) + cfg.CONF.register_cli_opt(cfg.BoolOpt('use-fqdn', default=False, + required=False)) cfg.CONF(sys.argv[1:]) diff --git a/nova/templates/bin/_nova-compute-init.sh.tpl b/nova/templates/bin/_nova-compute-init.sh.tpl index 120f83303b..65672b4e0f 100644 --- a/nova/templates/bin/_nova-compute-init.sh.tpl +++ b/nova/templates/bin/_nova-compute-init.sh.tpl @@ -56,3 +56,10 @@ tee > /tmp/pod-shared/nova-hypervisor.conf << EOF [DEFAULT] my_ip = $hypervisor_address EOF + +{{- if and ( empty .Values.conf.nova.DEFAULT.host ) ( .Values.pod.use_fqdn.compute ) }} +tee > /tmp/pod-shared/nova-compute-fqdn.conf << EOF +[DEFAULT] +host = $(hostname --fqdn) +EOF +{{- end }} diff --git a/nova/templates/bin/_nova-compute.sh.tpl b/nova/templates/bin/_nova-compute.sh.tpl index c80da6d69c..170172d96c 100644 --- a/nova/templates/bin/_nova-compute.sh.tpl +++ b/nova/templates/bin/_nova-compute.sh.tpl @@ -22,4 +22,7 @@ exec nova-compute \ --config-file /etc/nova/nova.conf \ --config-file /tmp/pod-shared/nova-console.conf \ --config-file /tmp/pod-shared/nova-libvirt.conf \ - --config-file /tmp/pod-shared/nova-hypervisor.conf \ No newline at end of file +{{- if and ( empty .Values.conf.nova.DEFAULT.host ) ( .Values.pod.use_fqdn.compute ) }} + --config-file /tmp/pod-shared/nova-compute-fqdn.conf \ +{{- end }} + --config-file /tmp/pod-shared/nova-hypervisor.conf diff --git a/nova/templates/daemonset-compute.yaml b/nova/templates/daemonset-compute.yaml index 648ed89488..8e9bc29528 100644 --- a/nova/templates/daemonset-compute.yaml +++ b/nova/templates/daemonset-compute.yaml @@ -199,6 +199,9 @@ spec: - /etc/nova/nova.conf - --service-queue-name - compute + {{- if .Values.pod.use_fqdn.compute }} + - --use-fqdn + {{- end }} initialDelaySeconds: 80 periodSeconds: 90 timeoutSeconds: 70 @@ -212,6 +215,9 @@ spec: - --service-queue-name - compute - --liveness-probe + {{- if .Values.pod.use_fqdn.compute }} + - --use-fqdn + {{- end }} initialDelaySeconds: 120 periodSeconds: 90 timeoutSeconds: 70 diff --git a/nova/values.yaml b/nova/values.yaml index 308cbca145..b56ce74184 100644 --- a/nova/values.yaml +++ b/nova/values.yaml @@ -2271,6 +2271,14 @@ pod: nova_spiceproxy: readOnlyRootFilesystem: true allowPrivilegeEscalation: false + use_fqdn: + # NOTE: If the option "host" is not specified in nova.conf, the host name + # shown in the hypervisor host is defaulted to the short name of the host. + # Setting the option here to true will cause use $(hostname --fqdn) as the + # host name by default. If the short name is desired $(hostname --short), + # set the option to false. Specifying a host in the nova.conf via the conf: + # section will supersede the value of this option. + compute: true affinity: anti: type: diff --git a/tools/deployment/component/compute-kit/compute-kit.sh b/tools/deployment/component/compute-kit/compute-kit.sh index bdc6fb9577..2c465fa7ae 100755 --- a/tools/deployment/component/compute-kit/compute-kit.sh +++ b/tools/deployment/component/compute-kit/compute-kit.sh @@ -90,3 +90,4 @@ openstack service list sleep 30 #NOTE(portdirect): Wait for ingress controller to update rules and restart Nginx openstack compute service list openstack network agent list +openstack hypervisor list diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 46f1d88664..1f03f8ee9b 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -37,7 +37,8 @@ - openstack-helm-compute-kit-queens-ubuntu_xenial - openstack-helm-compute-kit-rocky-ubuntu_xenial - openstack-helm-compute-kit-rocky-ubuntu_bionic - - openstack-helm-compute-kit-rocky-opensuse_15 + - openstack-helm-compute-kit-rocky-opensuse_15: + voting: false - openstack-helm-compute-kit-stein-ubuntu_bionic - openstack-helm-horizon - openstack-helm-apparmor: