From 7adb0a2656895d660eef17cd76212b74040b0a4a Mon Sep 17 00:00:00 2001 From: Angela Li Date: Tue, 23 Jul 2019 10:59:24 -0700 Subject: [PATCH] Set the systemUUID for windows nodes --- pkg/kubelet/winstats/winstats.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/winstats/winstats.go b/pkg/kubelet/winstats/winstats.go index b55560a7333..2b34bfd8ae4 100644 --- a/pkg/kubelet/winstats/winstats.go +++ b/pkg/kubelet/winstats/winstats.go @@ -20,6 +20,8 @@ limitations under the License. package winstats import ( + "os/exec" + "strings" "syscall" "time" "unsafe" @@ -103,9 +105,24 @@ func (c *StatsClient) WinContainerInfos() (map[string]cadvisorapiv2.ContainerInf } // WinMachineInfo returns a cadvisorapi.MachineInfo with details about the -// node machine. Analogous to cadvisor MachineInfo method. +// node machine. Run the powershell command to get the SystemUUID for Windows node +// in here if it isn't provided by cadvisor. func (c *StatsClient) WinMachineInfo() (*cadvisorapi.MachineInfo, error) { - return c.client.getMachineInfo() + infos, err := c.client.getMachineInfo() + if err != nil { + return nil, err + } + + if infos.SystemUUID == "" { + cmd := exec.Command("powershell.exe", "-Command", "(Get-CimInstance -Class Win32_ComputerSystemProduct).UUID") + out, err := cmd.CombinedOutput() + if err != nil { + return infos, err + } + infos.SystemUUID = strings.TrimRight(string(out), "\r\n") + } + + return infos, nil } // WinVersionInfo returns a cadvisorapi.VersionInfo with version info of