Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit 4321fef

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request #58502 from dixudx/register_openstack_hostname
Automatic merge from submit-queue (batch tested with PRs 57867, 58490, 58502, 58134). 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>. Openstack: register metadata.hostname as node name **What this PR does / why we need it**: Currently Openstack can boot up instances with the name like `xyz/abc`, which is not a valid kubelet node name. While `hostname` retrieved from `meta_data.json` has already been sanitized by Openstack to valid DNS-1123 format string. It's safe to register this `metadata.hostname` as valid kubelet node name. /kind bug /sig openstack **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 #57765 **Special notes for your reviewer**: /assign @dims @FengyunPan **Release note**: ```release-note Openstack: register metadata.hostname as node name ```
2 parents 90a4c31 + a8dedc6 commit 4321fef

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

pkg/cloudprovider/providers/openstack/metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type DeviceMetadata struct {
6969
// See http://docs.openstack.org/user-guide/cli_config_drive.html
7070
type Metadata struct {
7171
Uuid string `json:"uuid"`
72-
Name string `json:"name"`
72+
Hostname string `json:"hostname"`
7373
AvailabilityZone string `json:"availability_zone"`
7474
Devices []DeviceMetadata `json:"devices,omitempty"`
7575
// .. and other fields we don't care about. Expand as necessary.

pkg/cloudprovider/providers/openstack/metadata_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
var FakeMetadata = Metadata{
2525
Uuid: "83679162-1378-4288-a2d4-70e13ec132aa",
26-
Name: "test",
26+
Hostname: "test",
2727
AvailabilityZone: "nova",
2828
}
2929

@@ -81,8 +81,8 @@ func TestParseMetadata(t *testing.T) {
8181
t.Fatalf("Should succeed when provided with valid data: %s", err)
8282
}
8383

84-
if md.Name != "test" {
85-
t.Errorf("incorrect name: %s", md.Name)
84+
if md.Hostname != "test.novalocal" {
85+
t.Errorf("incorrect hostname: %s", md.Hostname)
8686
}
8787

8888
if md.Uuid != "83679162-1378-4288-a2d4-70e13ec132aa" {

pkg/cloudprovider/providers/openstack/openstack_instances.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (i *Instances) CurrentNodeName(hostname string) (types.NodeName, error) {
5858
if err != nil {
5959
return "", err
6060
}
61-
return types.NodeName(md.Name), nil
61+
return types.NodeName(md.Hostname), nil
6262
}
6363

6464
func (i *Instances) AddSSHKeyToAllInstances(user string, keyData []byte) error {

0 commit comments

Comments
 (0)