Skip to content
New issue

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

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

Already on GitHub? # to your account

Add more validation of IPPool CRD #3570

Merged
merged 1 commit into from
Apr 2, 2022
Merged

Conversation

jianjuns
Copy link
Contributor

Validate IP version and prefix length fields.

Signed-off-by: Jianjun Shen shenj@vmware.com

@codecov-commenter
Copy link

codecov-commenter commented Mar 31, 2022

Codecov Report

Merging #3570 (1808fe8) into main (ce0de59) will decrease coverage by 5.84%.
The diff coverage is 42.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3570      +/-   ##
==========================================
- Coverage   63.94%   58.10%   -5.85%     
==========================================
  Files         278      278              
  Lines       27838    27846       +8     
==========================================
- Hits        17802    16180    -1622     
- Misses       8110     9877    +1767     
+ Partials     1926     1789     -137     
Flag Coverage Δ
kind-e2e-tests 39.75% <0.00%> (-11.23%) ⬇️
unit-tests 43.36% <42.85%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
pkg/controller/ipam/validate.go 79.54% <42.85%> (-2.72%) ⬇️
...g/agent/apiserver/handlers/featuregates/handler.go 0.00% <0.00%> (-82.36%) ⬇️
pkg/agent/controller/networkpolicy/reject.go 0.00% <0.00%> (-78.23%) ⬇️
pkg/agent/controller/networkpolicy/packetin.go 0.00% <0.00%> (-68.37%) ⬇️
pkg/apis/controlplane/v1beta2/helper.go 33.33% <0.00%> (-66.67%) ⬇️
pkg/controller/networkpolicy/mutate.go 0.00% <0.00%> (-62.07%) ⬇️
pkg/controller/egress/store/egressgroup.go 1.38% <0.00%> (-55.56%) ⬇️
...kg/apiserver/registry/system/supportbundle/rest.go 20.45% <0.00%> (-54.55%) ⬇️
pkg/apiserver/handlers/webhook/mutation_crd.go 0.00% <0.00%> (-52.64%) ⬇️
...ver/registry/controlplane/nodestatssummary/rest.go 50.00% <0.00%> (-50.00%) ⬇️
... and 69 more

Copy link
Contributor

@gran-vmv gran-vmv left a comment

Choose a reason for hiding this comment

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

LGTM except a small comment.

return false, fmt.Sprintf(
"Range is invalid. IP version of range %s-%s differs from Pool IP version", r.Start, r.End)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

Validate IP version and prefix length fields.

Signed-off-by: Jianjun Shen <shenj@vmware.com>
@@ -152,7 +176,7 @@ func TestEgressControllerValidateExternalIPPool(t *testing.T) {
},
SubnetInfo: crdv1alpha2.SubnetInfo{
Gateway: "10:2400::01",
PrefixLength: 64,
Copy link
Member

Choose a reason for hiding this comment

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

why changing this? the new prefix /24 seems more unrealistic in ipv6.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a check to prefix length must <32 for IPv4, so this case will fail for that reason (which is covered by a earlier test case already) if the length is still 64.

Copy link
Member

Choose a reason for hiding this comment

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

got it, thanks for explanation.

@jianjuns
Copy link
Contributor Author

jianjuns commented Apr 1, 2022

/test-all

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

@@ -152,7 +176,7 @@ func TestEgressControllerValidateExternalIPPool(t *testing.T) {
},
SubnetInfo: crdv1alpha2.SubnetInfo{
Gateway: "10:2400::01",
PrefixLength: 64,
Copy link
Member

Choose a reason for hiding this comment

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

got it, thanks for explanation.

@jianjuns
Copy link
Contributor Author

jianjuns commented Apr 1, 2022

/test-flexible-ipam-e2e

@jianjuns jianjuns merged commit 7be763e into antrea-io:main Apr 2, 2022
GraysonWu pushed a commit to GraysonWu/antrea that referenced this pull request Apr 6, 2022
Validate IP version and prefix length fields.

Signed-off-by: Jianjun Shen <shenj@vmware.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants