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. ```
This commit is contained in:
		@@ -173,7 +173,7 @@ def shutdown():
 | 
				
			|||||||
    '''
 | 
					    '''
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        if os.path.isfile(kubeconfig_path):
 | 
					        if os.path.isfile(kubeconfig_path):
 | 
				
			||||||
            kubectl('delete', 'node', gethostname().lower())
 | 
					            kubectl('delete', 'node', get_node_name())
 | 
				
			||||||
    except CalledProcessError:
 | 
					    except CalledProcessError:
 | 
				
			||||||
        hookenv.log('Failed to unregister node.')
 | 
					        hookenv.log('Failed to unregister node.')
 | 
				
			||||||
    service_stop('snap.kubelet.daemon')
 | 
					    service_stop('snap.kubelet.daemon')
 | 
				
			||||||
@@ -314,7 +314,7 @@ def send_data(tls, kube_control):
 | 
				
			|||||||
    sans = [
 | 
					    sans = [
 | 
				
			||||||
        hookenv.unit_public_ip(),
 | 
					        hookenv.unit_public_ip(),
 | 
				
			||||||
        ingress_ip,
 | 
					        ingress_ip,
 | 
				
			||||||
        gethostname()
 | 
					        get_node_name()
 | 
				
			||||||
    ]
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Create a path safe name by removing path characters from the unit 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'):
 | 
					    elif is_state('endpoint.openstack.ready'):
 | 
				
			||||||
        cloud_provider = 'openstack'
 | 
					        cloud_provider = 'openstack'
 | 
				
			||||||
    if cloud_provider == 'aws':
 | 
					    if cloud_provider == 'aws':
 | 
				
			||||||
        return getfqdn()
 | 
					        return getfqdn().lower()
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        return gethostname()
 | 
					        return gethostname().lower()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ApplyNodeLabelFailed(Exception):
 | 
					class ApplyNodeLabelFailed(Exception):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user