From 9a8c6db448f200ddd9a06813affab804b183de20 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Fri, 9 Mar 2018 19:52:07 -0500 Subject: [PATCH] Split out the hostname when default dhcp_domain is used in nova.conf When /etc/nova/nova.conf does not have specify dhcp_domain to empty string, a default string of '.novalocal' is returned by the meta data service. So we need to just split the string and pick the first one in the array. ``` $ curl http://169.254.169.254/latest/meta-data/hostname testvm-1.novalocal $ curl http://169.254.169.254/latest/meta-data/public-hostname testvm-1.novalocal $ curl http://169.254.169.254/latest/meta-data/local-hostname testvm-1.novalocal ``` --- pkg/cloudprovider/providers/openstack/openstack_instances.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/cloudprovider/providers/openstack/openstack_instances.go b/pkg/cloudprovider/providers/openstack/openstack_instances.go index 95c20413d34..5081a4382bc 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_instances.go +++ b/pkg/cloudprovider/providers/openstack/openstack_instances.go @@ -20,6 +20,7 @@ import ( "context" "fmt" "regexp" + "strings" "github.com/golang/glog" "github.com/gophercloud/gophercloud" @@ -60,7 +61,7 @@ func (i *Instances) CurrentNodeName(ctx context.Context, hostname string) (types if err != nil { return "", err } - return types.NodeName(md.Hostname), nil + return types.NodeName(strings.Split(md.Hostname, ".")[0]), nil } // AddSSHKeyToAllInstances is not implemented for OpenStack