diff --git a/pkg/kubelet/kubelet_node_status.go b/pkg/kubelet/kubelet_node_status.go index 5a83e91f9ea..d8fa79bb9a3 100644 --- a/pkg/kubelet/kubelet_node_status.go +++ b/pkg/kubelet/kubelet_node_status.go @@ -438,12 +438,6 @@ func (kl *Kubelet) recordEvent(eventType, event, message string) { kl.recorder.Eventf(kl.nodeRef, eventType, event, message) } -// Set the GOOS and GOARCH for this node -func (kl *Kubelet) setNodeStatusGoRuntime(node *v1.Node) { - node.Status.NodeInfo.OperatingSystem = goruntime.GOOS - node.Status.NodeInfo.Architecture = goruntime.GOARCH -} - // record if node schedulable change. func (kl *Kubelet) recordNodeSchedulableEvent(node *v1.Node) { kl.lastNodeUnschedulableLock.Lock() @@ -509,7 +503,7 @@ func (kl *Kubelet) defaultNodeStatusFuncs() []func(*v1.Node) error { nodestatus.VersionInfo(kl.cadvisor.VersionInfo, kl.containerRuntime.Type, kl.containerRuntime.Version), nodestatus.DaemonEndpoints(kl.daemonEndpoints), nodestatus.Images(kl.nodeStatusMaxImages, kl.imageManager.GetImageList), - withoutError(kl.setNodeStatusGoRuntime), + nodestatus.GoRuntime(), ) if utilfeature.DefaultFeatureGate.Enabled(features.AttachVolumeLimit) { setters = append(setters, withoutError(kl.setVolumeLimits)) diff --git a/pkg/kubelet/nodestatus/setters.go b/pkg/kubelet/nodestatus/setters.go index 69ff9bbfdee..83788a64d3c 100644 --- a/pkg/kubelet/nodestatus/setters.go +++ b/pkg/kubelet/nodestatus/setters.go @@ -20,6 +20,7 @@ import ( "fmt" "math" "net" + goruntime "runtime" "strings" "time" @@ -376,6 +377,15 @@ func Images(nodeStatusMaxImages int32, } } +// GoRuntime returns a Setter that sets GOOS and GOARCH on the node. +func GoRuntime() Setter { + return func(node *v1.Node) error { + node.Status.NodeInfo.OperatingSystem = goruntime.GOOS + node.Status.NodeInfo.Architecture = goruntime.GOARCH + return nil + } +} + // ReadyCondition returns a Setter that updates the v1.NodeReady condition on the node. func ReadyCondition( nowFunc func() time.Time, // typically Kubelet.clock.Now