mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 00:07:50 +00:00
Revert get version change due to the overlap in PR #55143
This commit is contained in:
parent
b91e030fcf
commit
5fe87574d2
@ -57,18 +57,13 @@ func (p *perfCounterNodeStatsClient) startMonitoring() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
iv, err := exec.Command("powershell", "-command", "(Get-CimInstance Win32_OperatingSystem).Caption").Output()
|
version, err := exec.Command("cmd", "/C", "ver").Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
osImageVersion := strings.TrimSpace(string(iv))
|
|
||||||
|
|
||||||
kv, err := exec.Command("powershell", "-command", "[System.Environment]::OSVersion.Version.ToString()").Output()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
kernelVersion := strings.TrimSpace(string(kv))
|
|
||||||
|
|
||||||
|
osImageVersion := strings.TrimSpace(string(version))
|
||||||
|
kernelVersion := extractVersionNumber(osImageVersion)
|
||||||
p.nodeInfo = nodeInfo{
|
p.nodeInfo = nodeInfo{
|
||||||
kernelVersion: kernelVersion,
|
kernelVersion: kernelVersion,
|
||||||
osImageVersion: osImageVersion,
|
osImageVersion: osImageVersion,
|
||||||
|
@ -18,6 +18,7 @@ limitations under the License.
|
|||||||
package winstats
|
package winstats
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"regexp"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
cadvisorapi "github.com/google/cadvisor/info/v1"
|
cadvisorapi "github.com/google/cadvisor/info/v1"
|
||||||
@ -134,3 +135,11 @@ func (c *statsClient) createRootContainerInfo() (*cadvisorapiv2.ContainerInfo, e
|
|||||||
|
|
||||||
return &rootInfo, nil
|
return &rootInfo, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// extractVersionNumber gets the version number from the full version string on Windows
|
||||||
|
// e.g. extracts "10.0.14393" from "Microsoft Windows [Version 10.0.14393]"
|
||||||
|
func extractVersionNumber(fullVersion string) string {
|
||||||
|
re := regexp.MustCompile("[^0-9.]")
|
||||||
|
version := re.ReplaceAllString(fullVersion, "")
|
||||||
|
return version
|
||||||
|
}
|
||||||
|
@ -116,6 +116,13 @@ func TestWinVersionInfo(t *testing.T) {
|
|||||||
KernelVersion: "v42"})
|
KernelVersion: "v42"})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExtractVersionNumber(t *testing.T) {
|
||||||
|
fullVersion := "Microsoft Windows [Version 10.0.14393]"
|
||||||
|
versionNumber := extractVersionNumber(fullVersion)
|
||||||
|
expected := "10.0.14393"
|
||||||
|
assert.Equal(t, expected, versionNumber)
|
||||||
|
}
|
||||||
|
|
||||||
func getClient(t *testing.T) Client {
|
func getClient(t *testing.T) Client {
|
||||||
f := fakeWinNodeStatsClient{}
|
f := fakeWinNodeStatsClient{}
|
||||||
c, err := newClient(f)
|
c, err := newClient(f)
|
||||||
|
Loading…
Reference in New Issue
Block a user