mirror of https://github.com/k3s-io/k3s
Merge pull request #63903 from liggitt/openstack-node-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>. Restore pre-1.10 openstack instance naming behavior As noted in https://github.com/kubernetes/kubernetes/pull/61890#issuecomment-377282182 and https://github.com/kubernetes/kubernetes/issues/62295#issuecomment-389374492, the 1.10 changes to the openstack cloud provider node name computation (in #58502, #61000, and #61890) broke existing deployments that provisioned instances with credentials matching their instance names. It also did not account for version skewed kubelets, which can run 1.8 and 1.9 versions against a 1.10 master, and still register based on instance name. This PR reverts the incompatible changes to restore pre-1.10 behavior. Further improvements to handle instances with names that cannot be used as node names are tracked in https://github.com/kubernetes/kubernetes/issues/62295 /assign @dims /sig openstack /kind bug ```release-note Restores the pre-1.10 behavior of the openstack cloud provider which uses the instance name as the Kubernetes Node name. This requires instances be named with RFC-1123 compatible names. ```pull/8/head
commit
835afe683f
|
@ -70,7 +70,7 @@ type DeviceMetadata struct {
|
||||||
// See http://docs.openstack.org/user-guide/cli_config_drive.html
|
// See http://docs.openstack.org/user-guide/cli_config_drive.html
|
||||||
type Metadata struct {
|
type Metadata struct {
|
||||||
UUID string `json:"uuid"`
|
UUID string `json:"uuid"`
|
||||||
Hostname string `json:"hostname"`
|
Name string `json:"name"`
|
||||||
AvailabilityZone string `json:"availability_zone"`
|
AvailabilityZone string `json:"availability_zone"`
|
||||||
Devices []DeviceMetadata `json:"devices,omitempty"`
|
Devices []DeviceMetadata `json:"devices,omitempty"`
|
||||||
// .. and other fields we don't care about. Expand as necessary.
|
// .. and other fields we don't care about. Expand as necessary.
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
|
|
||||||
var FakeMetadata = Metadata{
|
var FakeMetadata = Metadata{
|
||||||
UUID: "83679162-1378-4288-a2d4-70e13ec132aa",
|
UUID: "83679162-1378-4288-a2d4-70e13ec132aa",
|
||||||
Hostname: "test",
|
Name: "test",
|
||||||
AvailabilityZone: "nova",
|
AvailabilityZone: "nova",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +81,8 @@ func TestParseMetadata(t *testing.T) {
|
||||||
t.Fatalf("Should succeed when provided with valid data: %s", err)
|
t.Fatalf("Should succeed when provided with valid data: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if md.Hostname != "test.novalocal" {
|
if md.Name != "test" {
|
||||||
t.Errorf("incorrect hostname: %s", md.Hostname)
|
t.Errorf("incorrect name: %s", md.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if md.UUID != "83679162-1378-4288-a2d4-70e13ec132aa" {
|
if md.UUID != "83679162-1378-4288-a2d4-70e13ec132aa" {
|
||||||
|
|
|
@ -121,7 +121,6 @@ type RouterOpts struct {
|
||||||
type MetadataOpts struct {
|
type MetadataOpts struct {
|
||||||
SearchOrder string `gcfg:"search-order"`
|
SearchOrder string `gcfg:"search-order"`
|
||||||
RequestTimeout MyDuration `gcfg:"request-timeout"`
|
RequestTimeout MyDuration `gcfg:"request-timeout"`
|
||||||
DHCPDomain string `gcfg:"dhcp-domain"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenStack is an implementation of cloud provider Interface for OpenStack.
|
// OpenStack is an implementation of cloud provider Interface for OpenStack.
|
||||||
|
@ -234,7 +233,6 @@ func configFromEnv() (cfg Config, ok bool) {
|
||||||
cfg.Global.TrustID != "")
|
cfg.Global.TrustID != "")
|
||||||
|
|
||||||
cfg.Metadata.SearchOrder = fmt.Sprintf("%s,%s", configDriveID, metadataID)
|
cfg.Metadata.SearchOrder = fmt.Sprintf("%s,%s", configDriveID, metadataID)
|
||||||
cfg.Metadata.DHCPDomain = "novalocal"
|
|
||||||
cfg.BlockStorage.BSVersion = "auto"
|
cfg.BlockStorage.BSVersion = "auto"
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -252,7 +250,6 @@ func readConfig(config io.Reader) (Config, error) {
|
||||||
cfg.BlockStorage.TrustDevicePath = false
|
cfg.BlockStorage.TrustDevicePath = false
|
||||||
cfg.BlockStorage.IgnoreVolumeAZ = false
|
cfg.BlockStorage.IgnoreVolumeAZ = false
|
||||||
cfg.Metadata.SearchOrder = fmt.Sprintf("%s,%s", configDriveID, metadataID)
|
cfg.Metadata.SearchOrder = fmt.Sprintf("%s,%s", configDriveID, metadataID)
|
||||||
cfg.Metadata.DHCPDomain = "novalocal"
|
|
||||||
|
|
||||||
err := gcfg.ReadInto(&cfg, config)
|
err := gcfg.ReadInto(&cfg, config)
|
||||||
return cfg, err
|
return cfg, err
|
||||||
|
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/gophercloud/gophercloud"
|
"github.com/gophercloud/gophercloud"
|
||||||
|
@ -62,11 +61,7 @@ func (i *Instances) CurrentNodeName(ctx context.Context, hostname string) (types
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
domain := "." + i.opts.DHCPDomain
|
return types.NodeName(md.Name), nil
|
||||||
if i.opts.DHCPDomain != "" && strings.HasSuffix(md.Hostname, domain) {
|
|
||||||
return types.NodeName(strings.TrimSuffix(md.Hostname, domain)), nil
|
|
||||||
}
|
|
||||||
return types.NodeName(strings.Split(md.Hostname, ".")[0]), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddSSHKeyToAllInstances is not implemented for OpenStack
|
// AddSSHKeyToAllInstances is not implemented for OpenStack
|
||||||
|
|
Loading…
Reference in New Issue