Skip to content
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

feat(wait): add wait for delete operation #682

Merged
merged 10 commits into from
Feb 25, 2020

Conversation

dsimansk
Copy link
Contributor

@dsimansk dsimansk commented Feb 19, 2020

Fixes #671

Proposed Changes

  • Add waitForEvent logic to wait package
  • Refactor client.DeleteService()
    • timeout == 0 asyn delete without wait
    • otherwise wait a given time for delete op to complete
  • Change service delete to wait by default
  • Add --no-wait flag to delete op

Generated doc for --no-wait flag seems a bit off, as it was meant for ready use-case primarly. I'll take a closer after actual waiting logic in reviewed.

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Feb 19, 2020
Copy link
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: 5 warnings.

In response to this:

Fixes #671

Proposed Changes

  • Add client.WaitForEvent() to handle waiting for event types
  • Change service delete to wait for deletion by default
  • Add --no-wait flag to delete op

Generated doc for --no-wait flag seems a bit off, as it was meant for ready use-case primarly. I'll take a closer after actual waiting logic in reviewed.

/wip

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.

kind string
}

type EventDone func(ev *watch.Event) bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: exported type EventDone should have comment or be unexported. More info.

return &waitForReadyConfig{
kind: kind,
watchMaker: watchMaker,
conditionsExtractor: extractor,
}
}

func NewWaitForEvent(kind string, watchMaker WatchMaker, eventDone EventDone) Wait {
Copy link
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 NewWaitForEvent should have comment or be unexported. More info.

@@ -178,6 +194,29 @@ func (w *waitForReadyConfig) waitForReadyCondition(start time.Time, name string,
}
}

func (w *waitForEvent) Wait(name string, timeout time.Duration, msgCallback MessageCallback) (error, time.Duration) {
Copy link
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.

sr.r.Add("WaitForEvent", []interface{}{kind, name, timeout, done}, []interface{}{err})
}

func (c *MockKnServingClient) WaitForEvent(kind, name string, timeout time.Duration, done wait.EventDone) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: exported method MockKnServingClient.WaitForEvent should have comment or be unexported. More info.

@@ -125,6 +125,16 @@ func (c *MockKnServingClient) WaitForService(name string, timeout time.Duration,
return mock.ErrorOrNil(call.Result[0]), call.Result[1].(time.Duration)
}

// Wait for a service to become ready, but not longer than provided timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: comment on exported method ServingRecorder.WaitForEvent should be of the form "WaitForEvent ...". More info.

@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 19, 2020
@dsimansk
Copy link
Contributor Author

/assign @rhuss

@dsimansk
Copy link
Contributor Author

/wip

@dsimansk dsimansk changed the title feat(wait): add wait for delete operation WIP: feat(wait): add wait for delete operation Feb 19, 2020
@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 Feb 19, 2020
@@ -24,8 +24,11 @@ kn service delete NAME [flags]
### Options

```
--async DEPRECATED: please use --no-wait instead. Delete service and don't wait for it to become ready.
Copy link
Contributor

Choose a reason for hiding this comment

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

don't add that, not deeded to add a deprecated option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still part of AddConditionWaitFlags() and I wish I could create overloaded method...:) But of course, I agress it shouldn't be created with deprecated flag.

Copy link
Contributor

Choose a reason for hiding this comment

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

yep, I've seen. its ok.

@dsimansk
Copy link
Contributor Author

/lint

Copy link
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: 2 unresolved warnings and 3 new warnings.

In response to this:

/lint

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.

}

func (c *MockKnServingClient) DeleteService(name string) error {
call := c.recorder.r.VerifyCall("DeleteService", name)
func (c *MockKnServingClient) DeleteService(name string, timeout time.Duration) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: exported method MockKnServingClient.DeleteService should have comment or be unexported. More info.

@@ -76,6 +76,28 @@ func TestAddWaitForReady(t *testing.T) {
}
}

func TestAddWaitForDelete(t *testing.T) {
for i, tc := range prepareDeleteTestCases("test-service") {
fakeWatchApi := NewFakeWatch(tc.events)
Copy link
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.

kind string
}

// Done marker to stop actual waiting on given event state
Copy link
Contributor

Choose a reason for hiding this comment

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

Golint comments: comment on exported type EventDone should be of the form "EventDone ..." (with optional leading article). More info.

Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

Looks good, with some comment :)

pkg/serving/v1/client.go Show resolved Hide resolved
pkg/serving/v1/client.go Outdated Show resolved Hide resolved
pkg/serving/v1/client.go Outdated Show resolved Hide resolved
@@ -24,8 +24,11 @@ kn service delete NAME [flags]
### Options

```
--async DEPRECATED: please use --no-wait instead. Delete service and don't wait for it to become ready.
Copy link
Contributor

Choose a reason for hiding this comment

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

yep, I've seen. its ok.

pkg/wait/wait_for_ready.go Outdated Show resolved Hide resolved
pkg/wait/wait_for_ready.go Outdated Show resolved Hide resolved
@dsimansk dsimansk changed the title WIP: feat(wait): add wait for delete operation feat(wait): add wait for delete operation Feb 21, 2020
@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 Feb 21, 2020
@dsimansk
Copy link
Contributor Author

@rhuss pls check if the following change is acceptable b97e2ca as part of this PR. :)

@dsimansk
Copy link
Contributor Author

/retest

@rhuss
Copy link
Contributor

rhuss commented Feb 21, 2020

@dsimansk staring at this latest integration error at https://prow.knative.dev/view/gcs/knative-prow/pr-logs/pull/knative_client/682/pull-knative-client-integration-tests-latest-release/1230890397631254528 I think it's not only good enough to wait for the service to be deleted, but also on all revisions attached to this service. As you can see, in the log, the service was deleted sync (per this PR), but the next create still references a revision from this old service in its traffic split. This indicates to me, that although the service has been removed, that it's not the case for its owned revision (therefore somehow the subsequent service create could still select this old revision which is just about to delete (and that doesn't how up anymore in the dumps which happens some time later).

@rhuss
Copy link
Contributor

rhuss commented Feb 21, 2020

Do you think its hard to implement to wait for the service and all objects which have this service as ownerReference ?

@rhuss
Copy link
Contributor

rhuss commented Feb 21, 2020

btw, yesterday I stumbled upon: https://github.com/k14s/kapp/blob/master/docs/apply-waiting.md which is more of a generic "wait" on resources. Not sure about the implementation, but we could have a look, too.

@navidshaikh
Copy link
Collaborator

Nice observation on the logs! 👍

A service is created with BYO revision name and deleted.
Another service with same "name" in the same namespace is created with BYO revision name, why client should generate the same revision name (as generated in earlier service create) ?

@dsimansk
Copy link
Contributor Author

/retest

1 similar comment
@navidshaikh
Copy link
Collaborator

/retest

@dsimansk
Copy link
Contributor Author

/retest

1 similar comment
@dsimansk
Copy link
Contributor Author

/retest

@knative-metrics-robot
Copy link

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/kn/commands/service/delete.go 82.4% 86.4% 4.0
pkg/serving/v1/client.go 73.3% 74.7% 1.4
pkg/wait/wait_for_ready.go 74.3% 77.6% 3.4

@dsimansk
Copy link
Contributor Author

dsimansk commented Feb 25, 2020

@navidshaikh I've reverted sync revision delete commit 9bb60ac due to several side-effects that popped up in E2E tests.
I'd say this PR is good for a review in current state and I'll open a follow-up with sync revision delete, once it's a bit more stable.

Copy link
Collaborator

@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
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 25, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk, navidshaikh

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 /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 Feb 25, 2020
@knative-prow-robot knative-prow-robot merged commit 345653b into knative:master Feb 25, 2020
duglin pushed a commit to duglin/client that referenced this pull request Apr 1, 2020
In it's current state it now takes me about 25 seconds for the `kn delete`
to complete. Before knative#682 it used to be
almost immediate. This is because we now pass in the
`DeletePropagationBackground` flag. I believe this is a mistake, not only
because of the 20+ seconds of additional time to delete things, but IMO
the CLI should talk to the server in the same way regardless of the --wait
flag. That flag should just be a CLI thing to indicate if the user wants the CLI
to wait for the server to complete but not HOW the server should do the delete.

Signed-off-by: Doug Davis <[email protected]>
knative-prow-robot pushed a commit that referenced this pull request Apr 8, 2020
* Remove the delete propagation flag

In it's current state it now takes me about 25 seconds for the `kn delete`
to complete. Before #682 it used to be
almost immediate. This is because we now pass in the
`DeletePropagationBackground` flag. I believe this is a mistake, not only
because of the 20+ seconds of additional time to delete things, but IMO
the CLI should talk to the server in the same way regardless of the --wait
flag. That flag should just be a CLI thing to indicate if the user wants the CLI
to wait for the server to complete but not HOW the server should do the delete.

Signed-off-by: Doug Davis <[email protected]>

* try just tweaking the --no-wait flag

Signed-off-by: Doug Davis <[email protected]>
rhuss pushed a commit to rhuss/knative-client that referenced this pull request Apr 15, 2020
* Remove the delete propagation flag

In it's current state it now takes me about 25 seconds for the `kn delete`
to complete. Before knative#682 it used to be
almost immediate. This is because we now pass in the
`DeletePropagationBackground` flag. I believe this is a mistake, not only
because of the 20+ seconds of additional time to delete things, but IMO
the CLI should talk to the server in the same way regardless of the --wait
flag. That flag should just be a CLI thing to indicate if the user wants the CLI
to wait for the server to complete but not HOW the server should do the delete.

Signed-off-by: Doug Davis <[email protected]>

* try just tweaking the --no-wait flag

Signed-off-by: Doug Davis <[email protected]>
knative-prow-robot pushed a commit that referenced this pull request Apr 15, 2020
* (refactor) address the e2e extract / refactor of issue #763 (#765)

* (refactor) address the e2e extract / refactor of issue #763

* various updates to address reviewers feedback

* renamed lib/test/integration to lib/test and package to test

Signed-off-by: Roland Huß <[email protected]>
# Conflicts:
#	CHANGELOG.adoc
#	test/e2e/service_export_import_apply_test.go
#	test/e2e/trigger_test.go

* fix(plugin): Fix plugin lookup with file ext on Windows (#774)

* fix(plugin): Fix plugin lookup with file ext on Windows

* chore: Update changelog

* fix: Reflect review feedback

* fix: Reflect review feedback and add future todo

Signed-off-by: Roland Huß <[email protected]>
# Conflicts:
#	CHANGELOG.adoc

* fix(issue #762): correct error message when updating service (#778)

* fix(issue #762): correct error message when updating service

* correct message when updating service and passing many names
* fix issue with TestServiceUpdateWithMultipleImages running create vs update

* * added TestServiceDescribeWithMultipleNames
* added TestServiceCreateWithMultipleNames
* fix error message for service delete since many names can be passed

* Use vendored deps while running e2e locally (#783)

Also set GO111MODULE=on unconditionally

* Update sink binding create usage string (#785)

* Add "--target-utilization" to manage "autoscaling.knative.dev/targetUtilizationPercentage" annotation (#788)

* Support setting "autoscaling.knative.dev/targetUtilizationPercentage" annotation.

Signed-off-by: Roland Huß <[email protected]>
# Conflicts:
#	test/e2e/service_options_test.go

* Remove the delete propagation flag (#770)

* Remove the delete propagation flag

In it's current state it now takes me about 25 seconds for the `kn delete`
to complete. Before #682 it used to be
almost immediate. This is because we now pass in the
`DeletePropagationBackground` flag. I believe this is a mistake, not only
because of the 20+ seconds of additional time to delete things, but IMO
the CLI should talk to the server in the same way regardless of the --wait
flag. That flag should just be a CLI thing to indicate if the user wants the CLI
to wait for the server to complete but not HOW the server should do the delete.

Signed-off-by: Doug Davis <[email protected]>

* try just tweaking the --no-wait flag

Signed-off-by: Doug Davis <[email protected]>

* Fix error when output is set to name (#775)

* fix error when output is set to name

* add e2e test

* change to flags/listprint.go

Signed-off-by: Roland Huß <[email protected]>
# Conflicts:
#	test/e2e/basic_workflow_test.go

* Show all revisions when run `service describe -v` (#790)

* The `kn service describe -v` command shows repetitive revisions, because
  the revision would be covered by next one.

* Fix resource listing with -oname flag (#799)

* Fix resource listing with -oname flag

* add e2e tests

Signed-off-by: Roland Huß <[email protected]>
# Conflicts:
#	test/e2e/ping_test.go
#	test/e2e/revision_test.go
#	test/e2e/route_test.go
#	test/e2e/source_apiserver_test.go
#	test/e2e/source_binding_test.go
#	test/e2e/trigger_test.go

* Make wait, no-wait and async flags per bool var CLI convention (#802)

* Make wait, no-wait and async flags per bool var CLI convention

 Fixes #800

 - Deprecated bool vars can be supported for CLI convention
 - Bind --async flag value to --no-wait
 - Only one flag among [wait, no-wait, async] can be provided, else raise an error

* Simplify conditionals

* Add unit tests for deprecated flag async

* Fix a typo

* e2e: Foreground delete for revisions and services in e2e (#794)

* e2e: Foreground delete for revisions and services in e2e

 to avoid any race conditions and flakes

* Use --wait instead of --no-wait=false

Signed-off-by: Roland Huß <[email protected]>
# Conflicts:
#	test/e2e/basic_workflow_test.go
#	test/e2e/revision_test.go

* e2e: Run tekton e2e against pipeline v0.11.1 (#803)

* Use buildah task from master branch and paramterize FORMAT

* Configure pipeline v0.11.1

* DNM: Run tekton e2e in this PR

* Revert "DNM: Run tekton e2e in this PR"

This reverts commit 903f5be.

* Update CHANGELOG for v0.13.2 (#804)

* Pin serving to v0.13.2 and update version command (#797)

* Pin serving v0.13.2 dep to v0.13.2

* Update version command

 now points to serving v0.13.2 and eventing v0.13.6

* Copy go.sum as generated in CI

Signed-off-by: Roland Huß <[email protected]>
# Conflicts:
#	go.mod
#	go.sum
#	vendor/modules.txt

* add missing vendored files

* fixed error reporting for traffics tests

* Updated test

* fix formatting

* e2e for service export (#739)

* e2e for service export

* e2e for service export

* e2e for service export

* e2e for service export

* e2e for service export

Signed-off-by: Roland Huß <[email protected]>
# Conflicts:
#	test/e2e/service_export_import_apply_test.go

Co-authored-by: dr.max <[email protected]>
Co-authored-by: David Simansky <[email protected]>
Co-authored-by: Navid Shaikh <[email protected]>
Co-authored-by: Lv Jiawei <[email protected]>
Co-authored-by: Doug Davis <[email protected]>
Co-authored-by: Ying Chun Guo <[email protected]>
Co-authored-by: Murugappan Chetty <[email protected]>
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. 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.

Add --wait and --no-wait for all delete operation
6 participants