-
Notifications
You must be signed in to change notification settings - Fork 208
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
connectivity: add retry to external targets #1540
Conversation
Hmm, it seems like the retries for cases where failure is expected are causing the tests to take too long. |
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.
Is there an easy way to disable retries when the test is expected to fail?
The default retry policy is 3 times and 3s delay. We can reduce this number, but first I will check the test cases for expected fails and see if we approach them differently. |
8299efe
to
b1c0e5c
Compare
@squeed I have made changes that retry options are added for commands in which successful result is expected. |
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.
Also, the second commit fixes a couple of comments.
Could you please squash the two commits? It looks like the 2nd commit only changes comments that got introduced/changed in the 1st commit.
connectivity/tests/common.go
Outdated
// all conditions is set return early | ||
if rc.all { | ||
return opts | ||
} | ||
// destIP is checked with pod-to-cidr cases | ||
if peer.Address(ipFam) == rc.destIP { | ||
return opts | ||
} | ||
// destPort and podLabel are checked with pod-to-world case | ||
if peer.Port() == rc.destPort { | ||
for n, v := range rc.podLabels { | ||
if !pod.HasLabel(n, v) { | ||
return []string{} | ||
} | ||
} | ||
return opts | ||
} |
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.
It feels a bit strange this this is essentially all OR destIP matches OR (desPort matches AND label matches)
. Though it currently doesn't have a practical consequence, I'd say it's more straight forward to apply the options if either all
is true OR all specified options are true, i.e. the AND
of all specified options. Something like:
func (rc *retryCondition) CurlOptions(peer check.TestPeer, ipFam check.IPFamily, pod check.Pod, params check.Parameters) []string {
if params.Retry == 0 {
return []string{}
}
opts := []string{
"--retry", strconv.FormatInt(int64(connectRetry), 10),
"--retry-all-errors", // add --retry-all-errors to retry on all possible errors
}
if retryDelay := params.RetryDelay.Seconds(); retryDelay > 0.0 {
opts = append(opts, "--retry-delay", strconv.FormatFloat(retryDelay, 'f', -1, 64))
}
if rc.all {
return opts
}
if rc.destIP != "" && peer.Address(ipFam) != rc.destIP {
return []string{}
}
if rc.destPort != 0 && peer.Port() != rc.destPort {
return []string{}
}
for n, v := range rc.podLabels {
if !pod.HasLabel(n, v) {
return []string{}
}
}
return opts
}
That way it's independent of the test cases these options are currently used with and allows for easier extensibility in the future.
What do you think?
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.
This implementation is much more elegant 👍 but it is missing one thing if no options are set it still sets the retry options. So I added a check earlier to return in this case
if !rc.all && rc.destIP == "" && rc.destPort == 0 {
return []string{}
}
I am assuming this change is okay with you and pushing the changes 😃
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.
but it is missing one thing if no options are set it still sets the retry options. So I added a check earlier to return in this case
Ah, good point. I missed that. Shouldn't we also consider pod labels in the options not being set (ref. my inline comment)?
This commit adds --retry and --retry-delay flags to connectivity test. They are used in external pod-to-world and po-to-cidr tests to try to reconnect on failures thus making flaky tests less likely. Fixes comments of PodToWorld and PodToCIDR functions. Signed-off-by: Birol Bilgin <[email protected]>
c11ce49
to
2592105
Compare
I am guessing the failing test is related to #1527 |
Adds --retry and --retry-delay flags to the connectivity test.
They are used in external
pod-to-world
andpo-to-cidr
tests to try to reconnecton failures thus making flaky tests less likely.