Specify names on service update and generate names client-side.#282
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sixolet 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 |
knative-prow-robot
left a comment
There was a problem hiding this comment.
@sixolet: 6 warnings.
Details
In response to this:
Proposed Changes
--revision-nameflag allows setting revision names in service update. If you don't provide the service name as a prefix, it'll get auto-added for you.--generate-revision-nameflag (default TRUE) makes revision names client side by default.Whether to include the generation is up for discussion. Otherwise this is substantially similar to the server-side generateName(), up to and including our lack of vowels.
Release Note
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.
|
Cool, now that I've dealt with the old-api cases I feel happier about this. |
|
/retest |
rhuss
left a comment
There was a problem hiding this comment.
Looks good to me with some minor comments. However, I'm still wondering about the usefulness of --generate-revision-name. Why is a random client-side generation better/different than server-side random generation ? The generated name is nowhere reused in the client, and you would need to re-read the generated revision in any case after the revision has been created. But probably I missed something.
If --generate-revision-name is needed, I wonder whether we could combine this with --revision-name to reduce the number of options. E.g. we could say --revision-name=%s-%r{5}-%g e.g. using placeholder which would not be allowed as names (so easily detectable). That way you can flexibly build up your revision names with downstream values (random chars, generation numbers, maybe even label or annotation. values).
In this example -->
%s--> service name%r{5}--> five random chars%g--> next generation id$l{mylabel}--> value of label$a{myanno}--> value of an annotation
That way we could keep a simple but flexible format for the user to specify (and not only those two predefined formats). The other benefit would be to be very explicit (and no hidden and not necessarily inuitive 'prefix with service name if not already present')
| } | ||
|
|
||
| func (p *ConfigurationEditFlags) AddUpdateFlags(command *cobra.Command) { | ||
| func (p *ConfigurationEditFlags) addSharedFlags(command *cobra.Command) { |
There was a problem hiding this comment.
Can you add a comment to explain that "Shared" means that these flags are common between both create() and update() ?
There was a problem hiding this comment.
@duglin We add traffic flags separately on service update command. IMO they don't need to show up in ConfigurationEditFlags as updating traffic block is not configuration-edit operation and only traffic flags change don't result into a new revision.
There was a problem hiding this comment.
From a UX perspective, I'd like to be able to setup the traffic during "service create" - that's all I'm asking for.
rhuss
left a comment
There was a problem hiding this comment.
looks good to me (maybe add one test more for checking the template based generation).
I wonder whether we could add that if --revision-name is given but empty (not sure whether this can be checked with cobra but should be), then we set the name also empty (or don't provided), leading to a server side-generated name.
|
If I understand the motivation of client-side generation as described in https://github.com/knative/client/blob/master/conventions/client.md#change-non-code-attributes then it's about the potential risk of a race condition so that I doubt a bit that this could be the case as you always have an optimistic lock on the service resource, so when two clients simultaneously try to update the service the first one wins, and the second one has to re-fetch the resource (with the updated In the latter case, there is still a slight chance for a race, but is this really that severe?
So if there should be a race for I don't question the algorithm in the document at all, it has been the result of a lengthy (and probably painful) discussion. I just want to point out that I personally would take that risk and just reuse |
|
The chance of the race is low, but the consequences can be high (running code you specifically did not intend to run) |
|
/retest |
| p.markFlagMakesRevision("concurrency-limit") | ||
| command.Flags().Int32VarP(&p.Port, "port", "p", 0, "The port where application listens on.") | ||
| p.markFlagMakesRevision("port") | ||
| command.Flags().StringVar(&p.RevisionName, "revision-name", "{{.Service}}-{{.Random 5}}-{{.Generation}}", |
There was a problem hiding this comment.
this seems excessively long for on-screen help text :-)
There was a problem hiding this comment.
It inspired #351 . I think it's better to describe clearly.
There was a problem hiding this comment.
only the first time, after that when people do --help it'll just annoy them
There was a problem hiding this comment.
Hum. Roland suggested I add the part about the empty string. I think the part about the template is valuable, as it is not discoverable otherwise.
We could make it so, but we don't have a good place for that yet. I'd like to defer shortening it until we have a good place for other doc on options.
rhuss
left a comment
There was a problem hiding this comment.
Looks good, but I miss the --generate-revision-name parameter as indicated in the PR initial comment. Which btw should be named --no-generate-revision-name as the default is true.
|
If you pass the empty string, as the revision name, it's equivalent
… On Aug 10, 2019, at 1:44 AM, Roland Huß ***@***.***> wrote:
@rhuss commented on this pull request.
Looks good, but I miss the --generate-revision-name parameter as indicated in the PR initial comment. Which btw should be named --no-generate-revision-name as the default is true.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Cool. So the last thing which needs clarification whether we enforce a |
|
Seeing something odd: But this works: I'm pretty sure I have both alpha1 and beta1 installed in my cluster. |
|
@duglin that's due to a related thing that I think should be fixed in a different PR: we default to creating services in the old api format, so a newly created service "is using the old api format" until it's created and then the server converts it. |
|
ok, so when #361 is merged then all should be good, right? |
| -p, --port int32 The port where application listens on. | ||
| --requests-cpu string The requested CPU (e.g., 250m). | ||
| --requests-memory string The requested memory (e.g., 64Mi). | ||
| --revision-name string The revision name to set. Must start with the service name and a dash as a prefix. Empty revision name will result in the server generating a name for the revision. Accepts golang templates, allowing {{.Service}} for the service name, {{.Generation}} for the generation, and {{.Random [n]}} for n random consonants. (default "{{.Service}}-{{.Random 5}}-{{.Generation}}") |
There was a problem hiding this comment.
Do we describe what "Generation" is in our docs some place?
|
/lgtm Couple of comments/question though:
Rebase needed. |
|
There we go. Rebased. |
|
The following is the coverage report on pkg/.
|
|
/lgtm |
Fixes #277 #276
Proposed Changes
--revision-nameflag allows setting revision names in service update. If you don't provide the service name as a prefix, it'll get auto-added for you.--generate-revision-nameflag (default TRUE) makes revision names client side by default.Whether to include the generation is up for discussion. Otherwise this is substantially similar to the server-side generateName(), up to and including our lack of vowels.
Release Note