mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Use strongly-typed types.NodeName for a node name
We had another bug where we confused the hostname with the NodeName. To avoid this happening again, and to make the code more self-documenting, we use types.NodeName (a typedef alias for string) whenever we are referring to the Node.Name. A tedious but mechanical commit therefore, to change all uses of the node name to use types.NodeName Also clean up some of the (many) places where the NodeName is referred to as a hostname (not true on AWS), or an instanceID (not true on GCE), etc.
This commit is contained in:
@@ -237,7 +237,7 @@ func (adc *attachDetachController) nodeAdd(obj interface{}) {
|
||||
return
|
||||
}
|
||||
|
||||
nodeName := node.Name
|
||||
nodeName := types.NodeName(node.Name)
|
||||
if _, exists := node.Annotations[volumehelper.ControllerManagedAttachAnnotation]; exists {
|
||||
// Node specifies annotation indicating it should be managed by attach
|
||||
// detach controller. Add it to desired state of world.
|
||||
@@ -258,7 +258,7 @@ func (adc *attachDetachController) nodeDelete(obj interface{}) {
|
||||
return
|
||||
}
|
||||
|
||||
nodeName := node.Name
|
||||
nodeName := types.NodeName(node.Name)
|
||||
if err := adc.desiredStateOfWorld.DeleteNode(nodeName); err != nil {
|
||||
glog.V(10).Infof("%v", err)
|
||||
}
|
||||
@@ -278,7 +278,9 @@ func (adc *attachDetachController) processPodVolumes(
|
||||
return
|
||||
}
|
||||
|
||||
if !adc.desiredStateOfWorld.NodeExists(pod.Spec.NodeName) {
|
||||
nodeName := types.NodeName(pod.Spec.NodeName)
|
||||
|
||||
if !adc.desiredStateOfWorld.NodeExists(nodeName) {
|
||||
// If the node the pod is scheduled to does not exist in the desired
|
||||
// state of the world data structure, that indicates the node is not
|
||||
// yet managed by the controller. Therefore, ignore the pod.
|
||||
@@ -288,7 +290,7 @@ func (adc *attachDetachController) processPodVolumes(
|
||||
"Skipping processing of pod %q/%q: it is scheduled to node %q which is not managed by the controller.",
|
||||
pod.Namespace,
|
||||
pod.Name,
|
||||
pod.Spec.NodeName)
|
||||
nodeName)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -321,7 +323,7 @@ func (adc *attachDetachController) processPodVolumes(
|
||||
if addVolumes {
|
||||
// Add volume to desired state of world
|
||||
_, err := adc.desiredStateOfWorld.AddPod(
|
||||
uniquePodName, pod, volumeSpec, pod.Spec.NodeName)
|
||||
uniquePodName, pod, volumeSpec, nodeName)
|
||||
if err != nil {
|
||||
glog.V(10).Infof(
|
||||
"Failed to add volume %q for pod %q/%q to desiredStateOfWorld. %v",
|
||||
@@ -345,7 +347,7 @@ func (adc *attachDetachController) processPodVolumes(
|
||||
continue
|
||||
}
|
||||
adc.desiredStateOfWorld.DeletePod(
|
||||
uniquePodName, uniqueVolumeName, pod.Spec.NodeName)
|
||||
uniquePodName, uniqueVolumeName, nodeName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,7 +518,7 @@ func (adc *attachDetachController) getPVSpecFromCache(
|
||||
// corresponding volume in the actual state of the world to indicate that it is
|
||||
// mounted.
|
||||
func (adc *attachDetachController) processVolumesInUse(
|
||||
nodeName string, volumesInUse []api.UniqueVolumeName) {
|
||||
nodeName types.NodeName, volumesInUse []api.UniqueVolumeName) {
|
||||
glog.V(4).Infof("processVolumesInUse for node %q", nodeName)
|
||||
for _, attachedVolume := range adc.actualStateOfWorld.GetAttachedVolumesForNode(nodeName) {
|
||||
mounted := false
|
||||
|
||||
Reference in New Issue
Block a user