Skip to content

Commit

Permalink
Merge pull request kubernetes#61000 from dims/split-host-name-when-dh…
Browse files Browse the repository at this point in the history
…cp-domain-is-present-in-host-name

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Split out the hostname when default dhcp_domain is used in nova.conf

**What this PR does / why we need it**:

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
```

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
  • Loading branch information
Kubernetes Submit Queue authored Mar 28, 2018
2 parents 15489d0 + 9a8c6db commit d7ec46c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/cloudprovider/providers/openstack/openstack_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"regexp"
"strings"

"github.com/golang/glog"
"github.com/gophercloud/gophercloud"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d7ec46c

Please sign in to comment.