-
Notifications
You must be signed in to change notification settings - Fork 118
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
OCPBUGS-39403: Fix parseIPList to Continue Processing After Invalid IPs and Return Valid IPs #621
OCPBUGS-39403: Fix parseIPList to Continue Processing After Invalid IPs and Return Valid IPs #621
Conversation
Hi @mJace. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/assign |
parseIPList
to Continue Processing After Invalid IPs and Return Valid IPsparseIPList
to Continue Processing After Invalid IPs and Return Valid IPs
@mJace : would it be possible for you to provide some unit tests for this change? |
/assign |
80ce105
to
51aad66
Compare
@alebedev87 |
return list | ||
|
||
if len(invalidIPs) > 0 { | ||
log.V(7).Info("parseIPList found invalid IP/CIDR items", "invalidIPs", invalidIPs) |
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 would keep the log line up at line 391 where you find an invalid IP, e.g. log it for each invalid ip. Then you don't need the invalidIPs slice, nor to take a len later.
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.
Thank you for your advice.
/ok-to-test |
51aad66
to
31fdfe8
Compare
/retest-required |
/retest |
validIPs = append(validIPs, ip) | ||
} else { | ||
// Log invalid IP/CIDR | ||
log.V(0).Info("parseIPList found invalid IP/CIDR", 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.
Since this changes behavior, we need to make sure this error is noticed, and indicate that the invalid IP is now ignored. Something like this:
log.V(0).Info("parseIPList found invalid IP/CIDR", ip) | |
log.Error("error parsing IP list, ignoring invalid IP/CIDR", 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.
I added a customErr for IP/CIDR since only net.parseCIDR
returns err
.
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'm wondering whether this one should be an error, taking into account that now we don't stop the parsing and there can be some valid IPs still. I think that the error would make more sense down the code where we find that the list is empty. However in the similar conditions in the same function (when we return ""
) we use log.V(7).Info()
. So it seems to be inconsistent.
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.
@alebedev87 That’s why I use log.V(0).Info at the beginning.
I reviewed all scenarios that call log.Error() in template_helper.go
, and they all return "" immediately.
Since, in this case, we will continue parsing the rest of the IP, is it okay to use log.Info but at a higher log level?
If yes, what level should I use here?
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 default log level is 2 so if we want this message to be visible it has to be <= 2
. From what I can see in template_helper.go
the log level 0
is what's used in similar cases (example) - when the user needs to be informed but the flow may continue. Similarly, looking at the other functions - failing the parsing with an error if the list of valid IPs/CIDRs is empty seems to be the way to go.
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.
Btw the condition about the trimmer list being compared to the given list doesn't seem to use the right logging level:
if trimmedList != list {
log.V(7).Info("parseIPList leading/trailing spaces found")
return ""
}
I would prefer it to be a level 0
too as we want the user to see this.
@@ -1061,7 +1112,7 @@ func TestParseIPList(t *testing.T) { | |||
} | |||
return | |||
} | |||
if got != tc.input { | |||
if got != tc.expectedReturn { |
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.
Followup to https://github.com/openshift/router/pull/621/files#r1815351390.
if got != tc.expectedReturn { | |
if expectedEmpty && got != "" || got != tc.expectedReturn { |
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 this was taken care of.
@@ -1061,7 +1112,7 @@ func TestParseIPList(t *testing.T) { | |||
} | |||
return | |||
} | |||
if got != tc.input { | |||
if got != tc.expectedReturn { | |||
t.Errorf("Failure: expected %q, got %q", tc.input, got) |
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.
t.Errorf("Failure: expected %q, got %q", tc.input, got) | |
if expectedEmpty { | |
log.Errorf("Failure: expected none, got %q", got) | |
} else { | |
t.Errorf("Failure: expected %q, got %q", tc.expectedReturn, got) | |
} |
09efe4a
to
aeb7e77
Compare
@mJace: This pull request references Jira Issue OCPBUGS-39403, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
/jira refresh |
@alebedev87: This pull request references Jira Issue OCPBUGS-39403, which is valid. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
81ad24e
to
f0926cb
Compare
/lgtm Holding for @candita to have another look. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alebedev87 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
1 similar comment
/retest |
openshift/origin#29466 should fix the image registry failure of |
openshift/origin#29466 is merged |
/lgtm |
Pre-merge verified on cluster version: 4.18.0-0.ci.test-2025-02-12-162751-ci-ln-2i21xl2-latest
marking bug as verified |
@mJace: This pull request references Jira Issue OCPBUGS-39403, which is valid. 3 validation(s) were run on this bug
No GitHub users were found matching the public email listed for the QA contact in Jira (iamin@redhat.com), skipping review request. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
@mJace: all tests passed! Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
@mJace: Jira Issue OCPBUGS-39403: All pull requests linked via external trackers have merged: Jira Issue OCPBUGS-39403 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
[ART PR BUILD NOTIFIER] Distgit: ose-haproxy-router-base |
[ART PR BUILD NOTIFIER] Distgit: openshift-enterprise-haproxy-router |
Summary
This PR updates the
parseIPList
function to handle IP lists containing invalid IPs or CIDRs more gracefully. Previously, the function would return an empty string as soon as it encountered an invalid IP or CIDR. This update ensures that the function will now continue processing the rest of the list and return a space-separated string of all valid IPs and CIDRs.Changes
parseIPList
to:Benefits
Additional Notes