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
bug_fix: updating the parseKernelVersion() function #30699
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some tests please?
I'll look into the changes requested and update it soon, I'll also add test cases for the same. |
Hey @lmb |
@danehans PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you need to run gofmt
on the change:
Unformatted Go source code:
./pkg/version/version_unix.go
diff ./pkg/version/version_unix.go.orig ./pkg/version/version_unix.go
--- ./pkg/version/version_unix.go.orig
+++ ./pkg/version/version_unix.go
@@ -28,18 +28,18 @@
// So as observered the kernel value is N.N.N-m or N.N-m or N-m
// There for we use regular expresions to extract the patch number
- // from the last element of the verStrs array and append "0" to
+ // from the last element of the verStrs array and append "0" to
// the verStrs array in case the until its lenght is 3 as in all
// cases we want to return from this function : Major.Minor.PatchNumber
- patch := regexp.MustCompilePOSIX(`^[0-9]+`).FindString(verStrs[len(verStrs) - 1])
+ patch := regexp.MustCompilePOSIX(`^[0-9]+`).FindString(verStrs[len(verStrs)-1])
if patch == "" {
- verStrs[len(verStrs) - 1] = "0"
+ verStrs[len(verStrs)-1] = "0"
} else {
- verStrs[len(verStrs) - 1] = patch
- }
-
- for len(verStrs) <= 3{
+ verStrs[len(verStrs)-1] = patch
+ }
+
+ for len(verStrs) <= 3 {
verStrs = append(verStrs, "0")
}
https://github.com/cilium/cilium/actions/runs/7926471252/job/21808931886?pr=30699
Thank you for pointing it out @tklauser . |
Hey @tklauser, |
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
@MeherRushi It seems there are still some issues reported by golangci-lint: https://github.com/cilium/cilium/actions/runs/8015579723/job/21900979066?pr=30699 Could you please fix these as well? |
yes will look into it |
@MeherRushi the linter CI job is failing due to:
The |
@danehans . Thanks for pointing it out. |
Head branch was pushed to by a user without write access
@danehans I have made the requested changes. Please have a look once |
Commit 40100ef does not match "(?m)^Signed-off-by:". Please follow instructions provided in https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#developer-s-certificate-of-origin |
/test |
acb3be1
to
43e54d2
Compare
Previously, Cilium expects the kernel version to always have 3 digits. However, the kernel is perfectly allowed to have only 2 or even only 1 digit for the version number. https://github.com/torvalds/linux/blob/35a4474b5c3dd4315f72bd53e87b97f128d9bb3d/Makefile#L367 This patch makes changes to the following : - cilium/pkg/version/version_unix.go - updated the parseKernelVersion() to handle single as well double digit kernel versions along with the standard kernel versioning. - cilium/pkg/version/version_unix_test.go - added additional test cases Fixes: cilium#30630 Signed-off-by: MeherRushi <meherrushi2@gmail.com>
/test |
Thanks for the guidance and help @tklauser @lmb @danehans @optix2000 |
Previously, Cilium expects the kernel version to always have 3 digits.
However, the kernel is perfectly allowed to have only 2 or even only 1 digit
for the version number.
https://github.com/torvalds/linux/blob/35a4474b5c3dd4315f72bd53e87b97f128d9bb3d/Makefile#L367
This patch makes changes to the following :
handle single as well double digit kernel versions along with the standard
kernel versioning.
Fixes: #30630
Signed-off-by: MeherRushi meherrushi2@gmail.com
Description of change
The issue #30630 address that kernel versions of single and double digit are not being parsed by cilium. I have updated the parseKernelVersion() to handle this case.
Previously the assumption was that kernel version will be something as:
4.9.17-040917-generic
I have updated it based on the following:
@lmb @tklauser Please do review the change in code. If it is correct, I also plan on adding test cases for the same
Fixes: #30630