-
Notifications
You must be signed in to change notification settings - Fork 263
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(service create): Wait for a service to be ready when its created #156
feat(service create): Wait for a service to be ready when its created #156
Conversation
Hi @rhuss. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
/assign sixolet |
@rhuss: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
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. |
Some implementation notes:
|
/retest |
/ok-to-test |
hmm, the integration test failure doesn't seem to be related to this PR. |
Nope, it's an issue with this PR. Going to fix it now. |
It looks like that something changes on I can fix that, but this, in general, raises the question against which version of knative serving we should test. And whether we should strive for testing against multiple Knative (0.5, 0.6, ...) versions. This becomes especially important when the internal structure changes. I'm going to fix this for latest now and test it locally against 0.6.0, too (which is not covered then by the integration test). |
Integration test should be fixed if #155 is merged and this PR rebased on top of it |
4fa787d
to
b4f4057
Compare
@sixolet rebased and resolved conflicts. Please let me know whether I'm on the right track because then I would add more tests for the sync/async behaviour and also adapt the e2e test cases for the sync creation of the service. |
What would you print out if success? Same as before “Service Xyz created”? Then adding the URL on the next line for me is a great info to the user. This also does not prevent adding:
One idea if I understand the problem correctly is some kind of a wait limit/timeout should be applied at each Ready stage so that when |
I’d vote to stay with latest since we are still in pre-release mode. |
d15763f
to
d049457
Compare
c57144a
to
25571ed
Compare
I extracted now the wait logic in a service-independent and also cobra-independent package (top-level The option is now renamed to Also, one can switch the default mode, so when the default mode would be async, then an option For now only @sixolet I added the tested of configured generation vs. observed generation, but I never managed to get an event where those two values differ. I tried to find out, in which case these values can be different, and whether these values are already consolidated before the first event is sent. Do you have a pointer for me where I could learn a bit more about the usage of these generation values ? Also, for extracting the generation values I used Otherwise, I added quite some tests, but I haven't touched the e2e tests yet, which at least could be optimized to remove the sleep values (which are not needed in because waiting is the default) |
And soon enough you should be able to do it in Golang :) |
docs/cmd/kn_service_create.md
Outdated
@@ -47,8 +47,10 @@ kn service create NAME --image IMAGE [flags] | |||
--max-scale int Maximal number of replicas. | |||
--min-scale int Minimal number of replicas. | |||
-n, --namespace string List the requested object(s) in given namespace. | |||
--no-wait Don't wait for service to become ready. |
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.
i would prefer if we change it to --wait=bool with a desired default.
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.
I change this. This --no-wait
style was a reminiscence to GNU getopts where long boolean options are used to have --with-
and --no-
prefixes. But guess that's not so common anymore.
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.
@cppforlife @sixolet Just thought about the naming of the option again. If we make waiting the default value, then a --wait=true
doesn't make much sense and doesn't provide any extra value. Also, having an option with a string parameter allows for additional errors like providing a non-standard value (like no
, off
, ....). So I'd really prefer a boolean option here.
My suggestion would be to fall back to the original suggestion of --async
, or any other boolean toggle like --no-wait
, --background
, --apply
, ...
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.
IMO, --no-wait
reads simple and should be easy to use with default value of false.
By default, `kn service create` blocks until the service is either created or an error occured during service creation. With the option --no-wait the behaviour can be switched to an async mode so that that kn returns immediately after the service is created without waiting for a successful Ready status condition. The timeout for how long to wait can be configured with --wait-timeout If a timeout occur, that doesn't mean that the service is not created, but the wait just returns. The default value is 60 seconds. In wait mode, print out the service URL as a last line (so that it can be used together with `tail -1`) to extract the service URL after the service is created. Fixes knative#54
…et yet during startup
* Introduced an --async flag (replacing --wait and --no-wait) * Added proper retry handling on the list watch * Updated help message
ae6a3bf
to
b348c33
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhuss 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 |
The following is the coverage report on pkg/.
|
@cppforlife @sixolet I think we are ready to go and that I adressed all open change requests:
One minor issue which I would adress after a merge of this PR is, whether and how we should show a service URL. I think its need that you see that URL when commands returns (and it can show the URL now as the route is then alreaday in place). However, I'm not so sure about the how. I'd like that it would be easy to use the URL also in scripting so I though about a combination of
The last command would make it super easy to use the URL in scripts so that you can do things like Alternative to this suggestion could be
I think I like the second option better, but as mentioned I would address this in a seperate issue/PR as this PR already has grown quite a bit. |
/lgtm |
…knative#156) * feat(service create): Added --no-wait and --wait-timeout By default, `kn service create` blocks until the service is either created or an error occured during service creation. With the option --no-wait the behaviour can be switched to an async mode so that that kn returns immediately after the service is created without waiting for a successful Ready status condition. The timeout for how long to wait can be configured with --wait-timeout If a timeout occur, that doesn't mean that the service is not created, but the wait just returns. The default value is 60 seconds. In wait mode, print out the service URL as a last line (so that it can be used together with `tail -1`) to extract the service URL after the service is created. Fixes knative#54 * chore(service create): Tolerate if obeservedGeneration has not been set yet during startup * chore(service create): Refactored based on review comments * Introduced an --async flag (replacing --wait and --no-wait) * Added proper retry handling on the list watch * Updated help message * chore(service wait): Added a new test for sync behaviour
Install serving v0.9.0 for client release-v0.9.0
tail -1
) to extract the service URL after the service is created.Current tests has been adapted to work with async behaviour but no
new tests has been added for the new sync mode.
This is coming in a second commit (and put into an extra test file).
Fixes #54