v2: Context-aware WaitFor#2957
Conversation
|
Good catch, thanks. I would remove the argument in seconds and let the caller pass a context with a deadline. The predicate function should also accept a context, so that we delegate to the caller the cancellation of hanging functions. The function could be the just called “wait”. WDYT? |
|
@pierreprinetti indeed in many cases context with the deadline is enough, but i found it handy option to pass a timeout. Context of the predicate anyway should be canceled once we exit WaitFor, so it's just handy way of use either WithCancel or WithTimeout if timeout > 0. I'm unsure about other WaitFor* funcs, unfortunately my regex-fu is not that great... |
The |
|
My stance here is: this is not Gophercloud's job. There are plenty of libraries out there that do Wait in fanciful ways. I understand that we might continue providing a function that covers the basic case, but we should keep complexity at a minimum to avoid bugs. Accepting a context and letting the user set it appropriately seems to me like a reasonable compromise. |
|
@pierreprinetti agree, that surface should be minimal but enough. I also agree, that usually you just pass deadline ctx and do not expect fancy logic inside. Optional timeout just makes tests a bit easier to write, but i often have limited context in test suite anyway. I'll drop timeouts. |
99b98d9 to
d1e6046
Compare
|
@pierreprinetti done. |
03ce053 to
38af2a9
Compare
|
@vooon we may have issues here: internal/acceptance/openstack/containerinfra/v1/nodegroups_test.go |
38af2a9 to
b41b9e0
Compare
|
@pierreprinetti thanks, fixed. |
internal/acceptance/openstack/sharedfilesystems/v2/snapshots.go
Outdated
Show resolved
Hide resolved
62212e9 to
04201d6
Compare
Remove timeout logic from WaitFor, just use context, Luke! Improve gophercloud.WaitFor not to wait first second testing: fix error validation with errors.Is acceptance: fix node group acceptance: remove unused ErrTimeout baremetal: update WaitFor signature Fix: gophercloud#2956 Co-authored-by: Martin André <martin.andre@gmail.com> Signed-off-by: Vladimir Ermakov <vooon341@gmail.com>
04201d6 to
7bcc341
Compare
Fixes #2956