lift node-info setters into defaultNodeStatusFuncs

Instead of hiding these behind a helper, we just register them in a
uniform way. We are careful to keep the call-order of the setters the
same, though we can consider re-ordering in a future PR to achieve
fewer appends.
This commit is contained in:
Michael Taufen 2018-06-27 15:26:47 -07:00
parent 2df7e1ad5c
commit aa94a3ba4e

View File

@ -633,18 +633,6 @@ func (kl *Kubelet) setNodeStatusGoRuntime(node *v1.Node) {
node.Status.NodeInfo.Architecture = goruntime.GOARCH node.Status.NodeInfo.Architecture = goruntime.GOARCH
} }
// Set status for the node.
func (kl *Kubelet) setNodeStatusInfo(node *v1.Node) {
kl.setNodeStatusMachineInfo(node)
kl.setNodeStatusVersionInfo(node)
kl.setNodeStatusDaemonEndpoints(node)
kl.setNodeStatusImages(node)
kl.setNodeStatusGoRuntime(node)
if utilfeature.DefaultFeatureGate.Enabled(features.AttachVolumeLimit) {
kl.setVolumeLimits(node)
}
}
// record if node schedulable change. // record if node schedulable change.
func (kl *Kubelet) recordNodeSchedulableEvent(node *v1.Node) { func (kl *Kubelet) recordNodeSchedulableEvent(node *v1.Node) {
kl.lastNodeUnschedulableLock.Lock() kl.lastNodeUnschedulableLock.Lock()
@ -702,9 +690,19 @@ func (kl *Kubelet) defaultNodeStatusFuncs() []func(*v1.Node) error {
if kl.appArmorValidator != nil { if kl.appArmorValidator != nil {
validateHostFunc = kl.appArmorValidator.ValidateHost validateHostFunc = kl.appArmorValidator.ValidateHost
} }
return []func(*v1.Node) error{ var setters []func(n *v1.Node) error
setters = append(setters,
nodestatus.NodeAddress(kl.nodeIP, kl.nodeIPValidator, kl.hostname, kl.externalCloudProvider, kl.cloud, nodeAddressesFunc), nodestatus.NodeAddress(kl.nodeIP, kl.nodeIPValidator, kl.hostname, kl.externalCloudProvider, kl.cloud, nodeAddressesFunc),
withoutError(kl.setNodeStatusInfo), withoutError(kl.setNodeStatusMachineInfo),
withoutError(kl.setNodeStatusVersionInfo),
withoutError(kl.setNodeStatusDaemonEndpoints),
withoutError(kl.setNodeStatusImages),
withoutError(kl.setNodeStatusGoRuntime),
)
if utilfeature.DefaultFeatureGate.Enabled(features.AttachVolumeLimit) {
setters = append(setters, withoutError(kl.setVolumeLimits))
}
setters = append(setters,
nodestatus.OutOfDiskCondition(kl.clock.Now, kl.recordNodeStatusEvent), nodestatus.OutOfDiskCondition(kl.clock.Now, kl.recordNodeStatusEvent),
nodestatus.MemoryPressureCondition(kl.clock.Now, kl.evictionManager.IsUnderMemoryPressure, kl.recordNodeStatusEvent), nodestatus.MemoryPressureCondition(kl.clock.Now, kl.evictionManager.IsUnderMemoryPressure, kl.recordNodeStatusEvent),
nodestatus.DiskPressureCondition(kl.clock.Now, kl.evictionManager.IsUnderDiskPressure, kl.recordNodeStatusEvent), nodestatus.DiskPressureCondition(kl.clock.Now, kl.evictionManager.IsUnderDiskPressure, kl.recordNodeStatusEvent),
@ -712,7 +710,8 @@ func (kl *Kubelet) defaultNodeStatusFuncs() []func(*v1.Node) error {
nodestatus.ReadyCondition(kl.clock.Now, kl.runtimeState.runtimeErrors, kl.runtimeState.networkErrors, validateHostFunc, kl.containerManager.Status, kl.recordNodeStatusEvent), nodestatus.ReadyCondition(kl.clock.Now, kl.runtimeState.runtimeErrors, kl.runtimeState.networkErrors, validateHostFunc, kl.containerManager.Status, kl.recordNodeStatusEvent),
nodestatus.VolumesInUse(kl.volumeManager.ReconcilerStatesHasBeenSynced, kl.volumeManager.GetVolumesInUse), nodestatus.VolumesInUse(kl.volumeManager.ReconcilerStatesHasBeenSynced, kl.volumeManager.GetVolumesInUse),
withoutError(kl.recordNodeSchedulableEvent), withoutError(kl.recordNodeSchedulableEvent),
} )
return setters
} }
// Validate given node IP belongs to the current host // Validate given node IP belongs to the current host