Refactor waiting loop to use resourceVersion#1301
Refactor waiting loop to use resourceVersion#1301knative-prow-robot merged 4 commits intoknative:mainfrom
Conversation
knative-prow-robot
left a comment
There was a problem hiding this comment.
@dsimansk: 4 warnings.
Details
In response to this:
Description
Changes
- Use
resourceVersionin*Deletefunctions to get replay of events and prevent- Re-enable
retrylogic when watch channel is closed before timeoutReference
Fixes #1287
/cc @rhuss
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/test-infra repository.
| return polling, nil | ||
| } | ||
|
|
||
| func NewWatcherWithVersion(ctx context.Context, watchFunc watchF, c rest.Interface, ns string, resource string, name string, initialResourceVersion string, timeout time.Duration) (watch.Interface, error) { |
There was a problem hiding this comment.
Golint comments: exported function NewWatcherWithVersion should have comment or be unexported. More info.
| // msgCallback gets called for every event with an 'Ready' condition == UNKNOWN with the event's message. | ||
| func (w *waitForReadyConfig) Wait(ctx context.Context, watcher watch.Interface, name string, options Options, msgCallback MessageCallback) (error, time.Duration) { | ||
|
|
||
| func (w *waitForReadyConfig) Wait(ctx context.Context, name string, initialVersion string, options Options, msgCallback MessageCallback) (error, time.Duration) { |
There was a problem hiding this comment.
Golint arg-order: error should be the last type when returning multiple items.
|
|
||
| // Wait until the expected EventDone is satisfied | ||
| func (w *waitForEvent) Wait(ctx context.Context, watcher watch.Interface, name string, options Options, msgCallback MessageCallback) (error, time.Duration) { | ||
| func (w *waitForEvent) Wait(ctx context.Context, name string, initialVersion string, options Options, msgCallback MessageCallback) (error, time.Duration) { |
There was a problem hiding this comment.
Golint arg-order: error should be the last type when returning multiple items.
|
|
||
| func TestAddWaitForReadyWithChannelClose(t *testing.T) { | ||
| for i, tc := range prepareTestCases("test-service") { | ||
| fakeWatchApi := NewFakeWatch(tc.events) |
There was a problem hiding this comment.
Golint naming: var fakeWatchApi should be fakeWatchAPI. More info.
maximilien
left a comment
There was a problem hiding this comment.
/ok-to-test
Left some feedback, especially related to some missing coverage. Of course we cannot cover all but at least see if you can solve one --- some are same in different locations.
| if err != nil { | ||
| return false, false, err | ||
| } | ||
| defer watcher.Stop() |
There was a problem hiding this comment.
I can comment lines 150-152 and all tests passing. Similar on the other changes. My guess is that your tests are not covering the cases for failed timeout or similar?
| c, ns, resource, name, timeout, make(chan bool), make(chan watch.Event), &sync.WaitGroup{}, | ||
| newTickerPollInterval(time.Second), nativePoll(ctx, c, ns, resource, name)} | ||
| polling.start() | ||
| return polling, nil |
There was a problem hiding this comment.
I can comment this line and all tests pass. So missing coverage.
| if err != nil { | ||
| return err | ||
| } |
There was a problem hiding this comment.
I can comment lines 253-255 and all tests passing
| if err != nil { | ||
| return err | ||
| } |
@maximilien thanks! Sure, I'll take a pass on the test. The waiting loop is pretty tricky anyway, so more coverage is definitely good goal. |
|
@dsimansk Thanks a lot ! I won't be able to make review this week, but will have a look asap early next week. |
|
Sounds good. Thanks @dsimansk |
|
The following is the coverage report on the affected files.
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: navidshaikh The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This reverts commit 9f6ec31.
Description
Changes
resourceVersionin*Deletefunctions to get replay of events and preventretrylogic when watch channel is closed before timeoutReference
Fixes #1287
/cc @rhuss