Merge pull request #65487 from dshcherb/master

Automatic merge from submit-queue (batch tested with PRs 60150, 65467, 65487, 65595, 65374). 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>.

use lowercase hostnames for node names

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

Uppercase hostnames used in charms result in (lowercase) node name lookup errors. This happens when /etc/hostname contains uppercase characters and gethostname or getfqdn return those characters.

**Special notes for your reviewer**:

Discovered in a field deployment where hostnames are all uppercase.

**Release note**:

```release-note
Hostnames are now converted to lowercase before being used for node lookups in the kubernetes-worker charm.
```
pull/8/head
Kubernetes Submit Queue 2018-06-28 19:15:12 -07:00 committed by GitHub
commit 4859645cea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -173,7 +173,7 @@ def shutdown():
'''
try:
if os.path.isfile(kubeconfig_path):
kubectl('delete', 'node', gethostname().lower())
kubectl('delete', 'node', get_node_name())
except CalledProcessError:
hookenv.log('Failed to unregister node.')
service_stop('snap.kubelet.daemon')
@ -314,7 +314,7 @@ def send_data(tls, kube_control):
sans = [
hookenv.unit_public_ip(),
ingress_ip,
gethostname()
get_node_name()
]
# Create a path safe name by removing path characters from the unit name.
@ -1058,9 +1058,9 @@ def get_node_name():
elif is_state('endpoint.openstack.ready'):
cloud_provider = 'openstack'
if cloud_provider == 'aws':
return getfqdn()
return getfqdn().lower()
else:
return gethostname()
return gethostname().lower()
class ApplyNodeLabelFailed(Exception):