Skip to content

Refactor waiting loop to use resourceVersion#1301

Merged
knative-prow-robot merged 4 commits intoknative:mainfrom
dsimansk:waiting-loop-refactor
May 17, 2021
Merged

Refactor waiting loop to use resourceVersion#1301
knative-prow-robot merged 4 commits intoknative:mainfrom
dsimansk:waiting-loop-refactor

Conversation

@dsimansk
Copy link
Copy Markdown
Contributor

@dsimansk dsimansk commented May 4, 2021

Description

Changes

  • Use resourceVersion in *Delete functions to get replay of events and prevent
  • Re-enable retry logic when watch channel is closed before timeout

Reference

Fixes #1287

/cc @rhuss

@knative-prow-robot knative-prow-robot requested a review from rhuss May 4, 2021 20:48
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 4, 2021
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label May 4, 2021
Copy link
Copy Markdown
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dsimansk: 4 warnings.

Details

In response to this:

Description

Changes

  • Use resourceVersion in *Delete functions to get replay of events and prevent
  • Re-enable retry logic when watch channel is closed before timeout

Reference

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.

Comment thread pkg/wait/poll_watcher.go
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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Golint naming: var fakeWatchApi should be fakeWatchAPI. More info.

@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 4, 2021
Copy link
Copy Markdown
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/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()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread pkg/wait/poll_watcher.go
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can comment this line and all tests pass. So missing coverage.

Comment thread pkg/eventing/v1/client.go
Comment on lines +253 to +255
if err != nil {
return err
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can comment lines 253-255 and all tests passing

Comment thread pkg/serving/v1/client.go
Comment on lines +318 to +320
if err != nil {
return err
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous...

@knative-prow-robot knative-prow-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label May 5, 2021
@dsimansk
Copy link
Copy Markdown
Contributor Author

dsimansk commented May 6, 2021

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.

@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.

@rhuss
Copy link
Copy Markdown
Contributor

rhuss commented May 7, 2021

@dsimansk Thanks a lot ! I won't be able to make review this week, but will have a look asap early next week.

@maximilien
Copy link
Copy Markdown
Contributor

Sounds good. Thanks @dsimansk

@knative-metrics-robot
Copy link
Copy Markdown

The following is the coverage report on the affected files.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/eventing/v1/client.go 85.8% 86.0% 0.1
pkg/serving/v1/client.go 69.3% 69.0% -0.3
pkg/wait/wait_for_ready.go 76.1% 81.0% 4.9

@dsimansk dsimansk changed the title WIP: Refactor waiting loop to use resourceVersion Refactor waiting loop to use resourceVersion May 13, 2021
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 13, 2021
Copy link
Copy Markdown
Contributor

@navidshaikh navidshaikh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label May 17, 2021
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 17, 2021
@knative-prow-robot knative-prow-robot merged commit 9f6ec31 into knative:main May 17, 2021
dsimansk added a commit to dsimansk/client that referenced this pull request May 18, 2021
knative-prow-robot pushed a commit that referenced this pull request May 18, 2021
* Revert "Refactor waiting loop to use resourceVersion (#1301)"

This reverts commit 9f6ec31.

* Remove changelog entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor watch functions to pass resourceVersion

6 participants