Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get windows kernel version directly from registry #58498

Merged
merged 1 commit into from
Jan 29, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions pkg/kubelet/winstats/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,39 @@ func getVersionRevision() (uint16, error) {

// getKernelVersion gets the version of windows kernel.
func getKernelVersion() (string, error) {
ver, err := windows.GetVersion()
// Get CurrentBuildNumber.
buildNumber, err := getCurrentVersionVal("CurrentBuildNumber")
if err != nil {
return "", err
}

// Get CurrentMajorVersionNumber.
majorVersionNumberString, err := getCurrentVersionVal("CurrentMajorVersionNumber")
if err != nil {
return "", err
}
majorVersionNumber, err := windows.UTF16FromString(majorVersionNumberString)
if err != nil {
return "", err
}

// Get CurrentMinorVersionNumber.
minorVersionNumberString, err := getCurrentVersionVal("CurrentMinorVersionNumber")
if err != nil {
return "", err
}
minorVersionNumber, err := windows.UTF16FromString(minorVersionNumberString)
if err != nil {
return "", err
}

// Get UBR.
revision, err := getVersionRevision()
if err != nil {
return "", err
}

major := ver & 0xFF
minor := (ver >> 8) & 0xFF
build := (ver >> 16) & 0xFFFF
return fmt.Sprintf("%d.%d.%05d.%d\n", major, minor, build, revision), nil
return fmt.Sprintf("%d.%d.%s.%d\n", majorVersionNumber[0], minorVersionNumber[0], buildNumber, revision), nil
}

// getOSImageVersion gets the osImage name and version.
Expand Down