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

Fix invalid prerelease characters when parse kernel version #2450

Merged
merged 1 commit into from Jul 27, 2021
Merged

Fix invalid prerelease characters when parse kernel version #2450

merged 1 commit into from Jul 27, 2021

Conversation

Jexf
Copy link
Member

@Jexf Jexf commented Jul 22, 2021

Check kernel version splitted array length and intercept the first 3 elements for parsing kernel version.

Fixes #2449

Signed-off-by: Zhengdong Wu zhengdong.wu@transwarp.io

@Jexf Jexf changed the title Add compatible adaptation to parse kernel version (#2449) Add compatible adaptation to parse kernel version Jul 22, 2021
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Jexf for fixing it. Can you link the PR to its issue by adding the keyword "Fixes #xx" in the PR description? So that it can be more clear what's this for and merging it can close that issue automatically.

}
patch := regexp.MustCompilePOSIX(`^[0-9]+`).FindString(verStrs[2])
if patch == "" {
verStrs[2] = "0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a case the kernel release doesn't have patch number?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a case the kernel release doesn't have patch number?

Maybe there is no need to check kernel patch number, the kernel patch usually be numbers, and it will lose prerelease value, I will remove it.

pkg/util/runtime/runtime_linux.go Show resolved Hide resolved
@tnqn tnqn requested a review from antoninbas July 22, 2021 16:51
@Jexf
Copy link
Member Author

Jexf commented Jul 23, 2021

/test-all
/test-ipv6-all
/test-ipv6-only-all

@Jexf Jexf changed the title Add compatible adaptation to parse kernel version Fix invalid prerelease characters when parse kernel version #2449 Jul 23, 2021
@Jexf Jexf changed the title Fix invalid prerelease characters when parse kernel version #2449 Fix invalid prerelease characters when parse kernel version Jul 23, 2021
@Jexf
Copy link
Member Author

Jexf commented Jul 23, 2021

/test-all
/test-ipv6-all
/test-ipv6-only-all

@codecov-commenter
Copy link

codecov-commenter commented Jul 23, 2021

Codecov Report

Merging #2450 (294a628) into main (9adf9c9) will increase coverage by 5.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2450      +/-   ##
==========================================
+ Coverage   59.79%   64.88%   +5.08%     
==========================================
  Files         284      284              
  Lines       22171    25419    +3248     
==========================================
+ Hits        13258    16493    +3235     
+ Misses       7490     7374     -116     
- Partials     1423     1552     +129     
Flag Coverage Δ
e2e-tests 56.00% <42.85%> (?)
kind-e2e-tests 46.84% <0.00%> (-0.21%) ⬇️
unit-tests 42.02% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/util/runtime/runtime_linux.go 76.47% <100.00%> (+76.47%) ⬆️
pkg/controller/egress/ipallocator/allocator.go 67.82% <0.00%> (-15.16%) ⬇️
pkg/controller/networkpolicy/endpoint_querier.go 77.64% <0.00%> (-13.79%) ⬇️
pkg/apis/controlplane/v1beta1/conversion.go 72.44% <0.00%> (-11.89%) ⬇️
pkg/legacyapis/core/v1alpha2/register.go 69.23% <0.00%> (-10.77%) ⬇️
pkg/controller/egress/controller.go 76.76% <0.00%> (-10.44%) ⬇️
pkg/apis/stats/register.go 71.42% <0.00%> (-10.39%) ⬇️
pkg/legacyapis/stats/register.go 71.42% <0.00%> (-10.39%) ⬇️
pkg/ovs/openflow/ofctrl_meter.go 33.84% <0.00%> (-10.16%) ⬇️
pkg/legacyapis/security/v1alpha1/register.go 73.33% <0.00%> (-10.00%) ⬇️
... and 269 more

Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a question about why there is a special handling for "5.0" case but not for "5".

pkg/util/runtime/runtime_linux.go Show resolved Hide resolved
pkg/util/runtime/runtime_linux.go Show resolved Hide resolved
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
@antoninbas since you added the function, could you please take a look?

pkg/util/runtime/runtime_linux.go Show resolved Hide resolved
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but do you think we could have a quick unit test for this function now that we have added some logic? Should be very quick to build a table-driven test.

@Jexf Jexf closed this Jul 26, 2021
@Jexf Jexf reopened this Jul 26, 2021
@Jexf
Copy link
Member Author

Jexf commented Jul 26, 2021

Thanks for reminding, I have added unit test, please review again : ) @antoninbas @tnqn

antoninbas
antoninbas previously approved these changes Jul 26, 2021
Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually had a couple of comments

I noticed that you didn't sign the commit, so the DCO check is failing. https://github.com/antrea-io/antrea/blob/main/CONTRIBUTING.md#sign-off-your-work

if tc.expectedError != nil {
assert.Equal(t, tc.expectedError, err)
} else {
assert.Nil(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be require.Nil to bypass the next check in case of an error

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reminding, already updated.

},
}
for _, tc := range testcases {
expectedKernelVersion, err := parseKernelVersionStr(tc.kernelString)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/expectedKernelVersion/parsedKernelVersion

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reminding, already updated.

tnqn
tnqn previously approved these changes Jul 27, 2021
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@tnqn
Copy link
Member

tnqn commented Jul 27, 2021

@Jexf DCO check failed:

Commit sha: 6e34ef4, Author: Wu zhengdong, Committer: Wu zhengdong; Expected "Wu zhengdong zhengdong.wu@transwarp.io", but got "Zhengdong Wu zhengdong.wu@transwarp.io".

The signed-off author needs to be exactly same as the author information of the commit.

@tnqn
Copy link
Member

tnqn commented Jul 27, 2021

/test-all

tnqn
tnqn previously approved these changes Jul 27, 2021
@Jexf
Copy link
Member Author

Jexf commented Jul 27, 2021

@Jexf DCO check failed:

Commit sha: 6e34ef4, Author: Wu zhengdong, Committer: Wu zhengdong; Expected "Wu zhengdong zhengdong.wu@transwarp.io", but got "Zhengdong Wu zhengdong.wu@transwarp.io".

The signed-off author needs to be exactly same as the author information of the commit.

Has been updated : )

Check kernel version splitted array length and intercept the first
3 elements for parsing kernel version.

Signed-off-by: Wu zhengdong <zhengdong.wu@transwarp.io>
@tnqn
Copy link
Member

tnqn commented Jul 27, 2021

/test-all

1 similar comment
@Jexf
Copy link
Member Author

Jexf commented Jul 27, 2021

/test-all

@antoninbas
Copy link
Contributor

Unrelated Kind test failure

@antoninbas antoninbas merged commit 52402d3 into antrea-io:main Jul 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse kernel version failed with "4.19.43-300.el7.x86_64" for meter feature
4 participants