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

[flexible-ipam] Fix IP annotation not work on a StatefulSet #5715

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

gran-vmv
Copy link
Contributor

@gran-vmv gran-vmv commented Nov 16, 2023

Make IP pre-allocation working on StatefulSet.

@gran-vmv gran-vmv self-assigned this Nov 16, 2023
@gran-vmv gran-vmv marked this pull request as draft November 16, 2023 08:57
@gran-vmv
Copy link
Contributor Author

/test-flexible-ipam-e2e

@gran-vmv gran-vmv marked this pull request as ready for review November 16, 2023 08:59
@gran-vmv gran-vmv marked this pull request as draft November 16, 2023 08:59
@gran-vmv gran-vmv force-pushed the ipam-stsip branch 2 times, most recently from 036f7bb to 0395a1d Compare November 16, 2023 09:27
@gran-vmv gran-vmv marked this pull request as ready for review November 17, 2023 02:04
@gran-vmv gran-vmv force-pushed the ipam-stsip branch 2 times, most recently from 4c3cef1 to 8167259 Compare November 21, 2023 03:35
Comment on lines 292 to 293
want bool
want1 []net.IP
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
want bool
want1 []net.IP
hasIPPool bool
expectedIPs []net.IP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 341 to 342
assert.Equalf(t, want, got, "getIPPoolsForStatefulSet()")
assert.Equalf(t, tt.want1, got1, "getIPPoolsForStatefulSet()")
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel it's better to replace "getIPPoolsForStatefulSet()" with some helpful messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to

			assert.Equalf(t, want, got, "Unexpected IPPool result")
			assert.Equalf(t, tt.expectedIPs, got1, "Unexpected IP result")

pkg/controller/ipam/antrea_ipam_controller.go Show resolved Hide resolved
splittedIPStrings := strings.Split(ipStrings, annotation.AntreaIPAMAnnotationDelimiter)
for _, ipString := range splittedIPStrings {
ip := net.ParseIP(ipString)
if ipString != "" && ip == nil {
Copy link
Member

Choose a reason for hiding this comment

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

The check is confusing. If ipString could be "", it will append nil to ips, I don't think we expect that?

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. Fixed.

for _, ipString := range splittedIPStrings {
ip := net.ParseIP(ipString)
if ipString != "" && ip == nil {
klog.Errorf("invalid IP annotation %s", ipStrings)
Copy link
Member

Choose a reason for hiding this comment

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

  1. Use structured logging
  2. Captilize first letter
  3. Add more context, lack of information by just "invalid IP annotation"

Check https://github.com/tnqn/code-review-comments#logging for suggestions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to klog.ErrorS(fmt.Errorf("invalid IP format"), "Ignore IP annotation", "PodIPs", ipStrings)

for _, ipString := range splittedIPStrings {
ip := net.ParseIP(ipString)
if ip == nil {
klog.ErrorS(fmt.Errorf("invalid IP format"), "Ignore IP annotation", "PodIPs", ipStrings)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
klog.ErrorS(fmt.Errorf("invalid IP format"), "Ignore IP annotation", "PodIPs", ipStrings)
klog.ErrorS(nil, "Ignored invalid Pod IP annotation in the StatefulSet template", "annotation", ipStrings, "statefulSet", klog.KObj(ss))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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

@tnqn
Copy link
Member

tnqn commented Dec 6, 2023

/test-flexible-ipam-e2e
/test-all

@tnqn
Copy link
Member

tnqn commented Dec 7, 2023

/test-conformance

2 similar comments
@tnqn
Copy link
Member

tnqn commented Dec 8, 2023

/test-conformance

@tnqn
Copy link
Member

tnqn commented Dec 12, 2023

/test-conformance

@tnqn tnqn merged commit 0464c5f into antrea-io:main Dec 13, 2023
51 of 54 checks passed
@gran-vmv gran-vmv added this to the Antrea v1.15 release milestone Dec 27, 2023
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.

None yet

3 participants