-
Notifications
You must be signed in to change notification settings - Fork 359
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
Conversation
/test-flexible-ipam-e2e |
036f7bb
to
0395a1d
Compare
4c3cef1
to
8167259
Compare
want bool | ||
want1 []net.IP |
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.
want bool | |
want1 []net.IP | |
hasIPPool bool | |
expectedIPs []net.IP |
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.
Fixed.
assert.Equalf(t, want, got, "getIPPoolsForStatefulSet()") | ||
assert.Equalf(t, tt.want1, got1, "getIPPoolsForStatefulSet()") |
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.
I feel it's better to replace "getIPPoolsForStatefulSet()" with some helpful messages.
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.
Changed to
assert.Equalf(t, want, got, "Unexpected IPPool result")
assert.Equalf(t, tt.expectedIPs, got1, "Unexpected IP result")
splittedIPStrings := strings.Split(ipStrings, annotation.AntreaIPAMAnnotationDelimiter) | ||
for _, ipString := range splittedIPStrings { | ||
ip := net.ParseIP(ipString) | ||
if ipString != "" && ip == nil { |
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.
The check is confusing. If ipString
could be "", it will append nil
to ips
, I don't think we expect that?
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. Fixed.
for _, ipString := range splittedIPStrings { | ||
ip := net.ParseIP(ipString) | ||
if ipString != "" && ip == nil { | ||
klog.Errorf("invalid IP annotation %s", ipStrings) |
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.
- Use structured logging
- Captilize first letter
- Add more context, lack of information by just "invalid IP annotation"
Check https://github.com/tnqn/code-review-comments#logging for suggestions.
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.
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) |
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.
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)) |
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.
Done.
Signed-off-by: gran <gran@vmware.com>
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.
LGTM
/test-flexible-ipam-e2e |
/test-conformance |
2 similar comments
/test-conformance |
/test-conformance |
Make IP pre-allocation working on StatefulSet.