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

Adding a field to templates to allow them to deliver a user message w… #9708

Merged
merged 1 commit into from
Jul 11, 2016
Merged

Adding a field to templates to allow them to deliver a user message w… #9708

merged 1 commit into from
Jul 11, 2016

Conversation

jupierce
Copy link
Contributor

@jupierce jupierce commented Jul 5, 2016

…ith parameters substituted

@jupierce
Copy link
Contributor Author

jupierce commented Jul 5, 2016

Consider the following template: https://gist.github.com/jupierce/4ce49e0f46f8647d798c3db5b6fa42e9

In addition to new-app changes, the feature seemed to call for the PostProcessMessage to be displayed after "oc process", but the existing output of 'process' does not lend itself to that behavior. "oc process" presently displays the list of objects extracted from the transformed template instead of the full template: https://gist.github.com/jupierce/74dab02e628f80d55fc9d94c8086dc9a

I could see us doing any of the following for oc process:

  1. Leave "oc process" as-is and only display the post process message as part of new-app and through the web console
  2. Change "oc process" so that it outputs the full transformed template instead of just a list of objects. This would mean "oc create" would need to be able to interpret a full, already transformed, template as input, and extract/display the post process message. It would also cause ripples through any codebase using oc process output directly.
  3. Include the post process message as an annotation in the "oc process" list output. "oc create" could then have a heuristic that looked for the message and displayed it after processing the list.

@jupierce
Copy link
Contributor Author

jupierce commented Jul 5, 2016

Please let me know your thoughts @bparees @smarterclayton

@@ -13,6 +13,9 @@ type Template struct {
unversioned.TypeMeta
kapi.ObjectMeta

// Optional: An instructional message for the user processing this template (escaped parameters will be substitued).
Copy link
Contributor

Choose a reason for hiding this comment

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

escaped parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing to "An instructional message for the user processing this template (parameter substitution will be performed)." for clarity.

Copy link
Contributor

Choose a reason for hiding this comment

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

how about: "An instructional message for the user that will be displayed when the template is instantiated (parameter substitution will be performed)."

(technically it is true that the message is handled during processing, but the only clients that are going to display the message are clients that are doing actual instantiation. If the user just runs "oc process" on the template, the message will not be explicitly displayed).

@bparees
Copy link
Contributor

bparees commented Jul 5, 2016

a few nits/open question but mostly looks good. please update one of the existing tests to also validate this new logic (hopefully we have an appropriate one that does parameter substitution testing already).

@@ -24841,6 +24841,10 @@
"$ref": "v1.ObjectMeta",
"description": "Standard object's metadata."
},
"postProcessMessage": {
"type": "string",
"description": "Optional: An instructional message for the user processing this template (escaped parameters will be substitued)."
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

any good go spell-checkers out there? :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

not to worry, we have a large contingent of high-functioning OCD sufferers in this org.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you mean CDO (alphabetized, like it should be)

@jupierce
Copy link
Contributor Author

jupierce commented Jul 6, 2016

@bparees

  • Test added
  • API guidance improved

@@ -946,6 +955,8 @@ func (d *TemplateDescriber) DescribeTemplate(template *templateapi.Template) (st
formatMeta(out, template.ObjectMeta)
out.Write([]byte("\n"))
out.Flush()
d.DescribePostProcessMessage(template.PostProcessMessage, out)
Copy link
Contributor

Choose a reason for hiding this comment

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

the parameters seem more important than the post process message, and the message is likely to be longish, so I'd put it after the params

@jorgemoralespou
Copy link

@bparees @jupierece As a good developer that I am I usually just look at the end of the output of new-app so I would move this mage right to the end to make it easier to catch attention of the user.

@jupierce
Copy link
Contributor Author

jupierce commented Jul 6, 2016

@jorgemoralespou That was definitely my intent at the outset; however, new-app has two characteristics which pointed me to the current implementation:
(1) new-app can process multiple templates during a single invocation. If message output was deferred until the end of the process, the resultant messages might no longer be contextually tied to the template which created them.
(2) Moving messages to the end of new-app processing would require a much more invasive change to the current implementation.

@bparees
Copy link
Contributor

bparees commented Jul 6, 2016

+1 @jupierce, was going to say something similar. you could also new-app multiple things, some of which are templates and some are not.

// Objects is an array of objects to include in this template. Required.
// PostProcessMessage is an optional instructional message for the user
// processing this template (parameter substitution will be performed).
PostProcessMessage string `json:"postProcessMessage,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

PostProcess is too technical, I'd want someone who is a brand new user to figure it out. Message is probably sufficient.

Copy link
Contributor

Choose a reason for hiding this comment

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

Add a longer description that captures why someone would use this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Use the lowercase names in godoc so the messages in swagger match the JSON

@smarterclayton
Copy link
Contributor

We already need to do better error detection in new-app (for instance, new app should not run without --confirm if objects already exist). So in the future we'll have a better idea of whether we'll fail or not before we do the actual processing. We're not optimizing for the multiple template case, but we should be aware of it. If the experience is better for an end user on the single template case if it's at the end, that's where we should show it.

@bparees
Copy link
Contributor

bparees commented Jul 6, 2016

If the experience is better for an end user on the single template case if it's at the end, that's where we should show it.

it's better until:

  1. we make the new-app code so messy trying to move that line of output to the end that we can't easily fix the next issue/feature that is requested for it or the next person to touch the code has to spend extra hours figuring out what is going on because it's not logically grouped anymore. that hurts user experience too.

  2. someone instantiates a template that provides a useless message and then tells us "hey, it'd be better if you told me that a buildconfig got created as the last message so at least i'd know to start it, instead of the last message being this useless message the user provided. We can't expect all our users provide useful messages in their templates, so that shouldn't be the most important/last thing we display"

@smarterclayton
Copy link
Contributor

On Jul 6, 2016, at 7:12 PM, Ben Parees [email protected] wrote:

If the experience is better for an end user on the single template case if
it's at the end, that's where we should show it.

it's better until:

  1. we make the new-app code so messy trying to move that line of output to
    the end that we can't easily fix the next issue/feature that is requested
    for it or the next person to touch the code has to spend extra hours
    figuring out what is going on because it's not logically grouped anymore.
    that hurts user experience too.

We can fix new-app. Making the code better is a time thing, but usability
matters more.

  1. someone instantiates a template that provides a useless message and then
    tells us "hey, it'd be better if you told me that a buildconfig got created
    as the last message so at least i'd know to start it, instead of the last
    message being this useless message the user provided. We can't expect all
    our users provide useful messages in their templates, so that shouldn't be
    the most important/last thing we display"

I don't think I agree. Anyone who provides a template message almost
certainly thinks their message is more important than what new-app already
displays. Our messages at the end are breadcrumbs, but they are at best
affordances to move the user to the next logical step. It's arguable that
new-app should stream build / deployment output to you rather than write
the message. I might even argue we should suppress the list of things the
template creates in favor of a user generated message.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9708 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/ABG_p5-mG7dCHljA5vMJO4OOG7X6538Mks5qTDZpgaJpZM4JFaEm
.

@bparees
Copy link
Contributor

bparees commented Jul 6, 2016

I don't think I agree. Anyone who provides a template message almost
certainly thinks their message is more important than what new-app already
displays.

i fully expect a significant portion will contain "this is my template message" or whatever content we put in a sample template that they copied. or "creates a foo and a bar"

i don't think you can assume that just because the template message field is non empty, it's therefore properly spec'd and useful.

and in any case my argument is primarily one of expediency. We have finite time, this isn't worth the refactoring effort/code complexity. (particularly in light of this being turned into some sort of magic special case that only happens when we're instantiating a single template, because for any other case it's absolutely the wrong thing to do).

@bparees
Copy link
Contributor

bparees commented Jul 7, 2016

in case it is still not clear: i am not disagreeing that for the single scenario of "i'm using new-app to instantiate a single template that has a useful message and nothing else" printing the message last is preferable.

I am arguing that it's not worth the code churn, particularly in light of all the cases in which is not useful which we'd either have to special case out (more code churn), or accept resulted in a worse experience for those cases.

@smarterclayton
Copy link
Contributor

I don't, and we aren't designing for that. We do not add features and then
say "users will not use these right, so let's just have a crappy feature".
We figure out how the feature enables the user, and then we support
enabling it.

On Wed, Jul 6, 2016 at 7:47 PM, Ben Parees [email protected] wrote:

I don't think I agree. Anyone who provides a template message almost
certainly thinks their message is more important than what new-app already
displays.

i fully expect a significant portion will contain "this is my template
message" or whatever content we put in a sample template that they copied.
or "creates a foo and a bar"

i don't think you can assume that just because the template message field
is non empty, it's therefore properly spec'd and useful.

and in any case my argument is primarily one of expediency. We have finite
time, this isn't worth the refactoring effort/code complexity.
(particularly in light of this being turned into some sort of magic special
case that only happens when we're instantiating a single template, because
for any other case it's absolutely the wrong thing to do).


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9708 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABG_p_KYBR0q8M4rQEG_0yrYpz4RqeABks5qTD6NgaJpZM4JFaEm
.

@smarterclayton
Copy link
Contributor

I'm not a big fan of "well, we didn't have much time, so we did a hack job
that we'll have to fix later", as you well know.

On Wed, Jul 6, 2016 at 8:29 PM, Clayton Coleman [email protected] wrote:

I don't, and we aren't designing for that. We do not add features and
then say "users will not use these right, so let's just have a crappy
feature". We figure out how the feature enables the user, and then we
support enabling it.

On Wed, Jul 6, 2016 at 7:47 PM, Ben Parees [email protected]
wrote:

I don't think I agree. Anyone who provides a template message almost
certainly thinks their message is more important than what new-app already
displays.

i fully expect a significant portion will contain "this is my template
message" or whatever content we put in a sample template that they copied.
or "creates a foo and a bar"

i don't think you can assume that just because the template message field
is non empty, it's therefore properly spec'd and useful.

and in any case my argument is primarily one of expediency. We have
finite time, this isn't worth the refactoring effort/code complexity.
(particularly in light of this being turned into some sort of magic special
case that only happens when we're instantiating a single template, because
for any other case it's absolutely the wrong thing to do).


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9708 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABG_p_KYBR0q8M4rQEG_0yrYpz4RqeABks5qTD6NgaJpZM4JFaEm
.

@bparees
Copy link
Contributor

bparees commented Jul 7, 2016

I'm not a big fan of "well, we didn't have much time, so we did a hack job
that we'll have to fix later", as you well know.

The current implementation is not a "hack job", it positions the output in the same location as the other output related to the template that was processed..

And i'm not a big fan of "we spent 3 days moving a line of text down slightly in the output instead of fixing 3 other issues in the product, and in the process we ensured that the next time we have to touch this code, it's going to consume extra time for someone because now it's more complicated than it needed to be"

here are 21 open CLI issues that contain the word "new-app" that we could work on instead of reworking this implementation because we don't think our users are capable of reading 10 lines of text:
https://github.com/openshift/origin/issues?q=is%3Aissue+is%3Aopen+new-app+label%3Acomponent%2Fcli

@bparees
Copy link
Contributor

bparees commented Jul 7, 2016

regarding oc process, yes it should be left as is, it's primary use case is to be piped into oc create or oc apply, so it does not make sense to have it outputting this message. The message is intended for new-app instantiation and web console instantiation. oc process is definitely an advanced user flow at this point.

@smarterclayton
Copy link
Contributor

If we add a message intended for end users, and we put it in the wrong
place, that can sometimes have the result of being worse than doing
nothing at all. Let's talk tomorrow.

On Wed, Jul 6, 2016 at 8:49 PM, Ben Parees [email protected] wrote:

regarding oc process, yes it should be left as is, it's primary use case
is to be piped into oc create or oc apply, so it does not make sense to
have it outputting this message. The message is intended for new-app
instantiation and web console instantiation. oc process is definitely an
advanced user flow at this point.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#9708 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABG_p3Bv3rLk_jfImiOrOoqhEkniDYK5ks5qTE0NgaJpZM4JFaEm
.

@bparees
Copy link
Contributor

bparees commented Jul 7, 2016

i think we should split the new-app updates out of this PR so we can move forward w/ the api+parameter substitution changes, regardless of what we decide to do w/ the new-app output.

that way @jwforres can pick up this change for the web console sooner than later.

@jupierce
Copy link
Contributor Author

jupierce commented Jul 7, 2016

Changes:
(1) Changed from PostProcessMessage to Message in template definition.
(2) Improved description of field.
[test]

@bparees
Copy link
Contributor

bparees commented Jul 7, 2016

lgtm, can you remove the new-app change for now, we'll get api sign-off and merge this, and then @smarterclayton and I will resume our battle royale in your follow-up PR?

@jupierce
Copy link
Contributor Author

jupierce commented Jul 7, 2016

New commit removes changes from new-app.

As a new user of the system I will throw in my impression: it doesn't seem like I should have needed to use new-app at all. I would have expected an incarnation of "oc create" to allow me to process a local template file and the user message to be printed as its last step.
Honestly, even that "oc create -f <template.json>" created a Template resource instead of just instantiating the declared objects was counter-intuitive.

@@ -14,15 +14,23 @@ type Template struct {
// Standard object's metadata.
kapi.ObjectMeta `json:"metadata,omitempty"`

// Objects is an array of objects to include in this template. Required.
// message is an optional instructional message that will
// be displayed when this template is instantiated.
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by instantiated? You can't output this message in the oc process template | oc create -f flow, right? We're adding a template API field for the the new-app only flow? @jwforres would need to special case this in the webconsole too.

Copy link
Contributor

Choose a reason for hiding this comment

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

@deads2k yes this is being added to the webconsole, @jwforres is aware of it. in fact it's the primary use case for adding this.

would you be happier with "optional message that may be displayed depending which client you use and whether it bothers to support this field"?

Copy link
Contributor

Choose a reason for hiding this comment

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

would you be happier with "optional message that may be displayed depending which client you use and whether it bothers to support this field"?

Yeah, along with, "in our default client, we ignore this in the default processing/creation workflow".

Copy link
Contributor

Choose a reason for hiding this comment

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

our default client is new-app and it's not going to ignore it.

Copy link
Contributor

Choose a reason for hiding this comment

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

our default client is new-app and it's not going to ignore it.

As opposed the oc process command we built specifically to instantiate templates?

Copy link
Contributor

@bparees bparees Jul 7, 2016

Choose a reason for hiding this comment

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

correct. oc process got deprecated when @smarterclayton decided to add template processing to new-app.

oc process is for advanced users who want to pipe to oc apply or something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Instantiated - my initial wording was "processed", but it was suggested that the only reason we process templates is to instantiate the underlying objects in etcd.
  • Correct, the present implementation does not attempt to output the message during "oc process" (or create). Only targeting new-app and the web console with @jwforres 's help.

@bparees
Copy link
Contributor

bparees commented Jul 7, 2016

oc create is not going to instantiate a template, because oc create creates resources, and a template definition is a resource, so oc create template will always create a template resource, not instantiate them. I agree it's slightly confusing to a new user to distinguish between "creating a template" (which we called "registering" or "installing" it) and instantiating a template, but I don't see us special casing oc create behavior in the case of a template resource because you'd still need a way to declare your intention to register the template when that is what you want to do.

@deads2k
Copy link
Contributor

deads2k commented Jul 7, 2016

special casing oc create behavior in the case of a template resource

Neither do I. I would picture having an openshift.io/creation-message annotation supported on every object that has an ObjectMeta.

@deads2k
Copy link
Contributor

deads2k commented Jul 7, 2016

Having it on individual objects would also give a spot for anyone at any later date to have a field that amounts to a description of what the resource actually is or is trying to do. Putting it on a template instead means you get it once and you better pay attention.

@jupierce
Copy link
Contributor Author

jupierce commented Jul 7, 2016

@bparees Completely agree on preserving the behavior of "oc create -f" to allow advanced users to create a Template resource. Merely suggesting a short-cut for new users:
oc create [templateFile.json]

@liggitt
Copy link
Contributor

liggitt commented Jul 7, 2016

Having it on individual objects would also give a spot for anyone at any later date to have a field that amounts to a description of what the resource actually is or is trying to do. Putting it on a template instead means you get it once and you better pay attention.

interesting, though I wouldn't want a getting started message that included a substituted in admin username and generated password to be persisted as an object annotation

@deads2k
Copy link
Contributor

deads2k commented Jul 7, 2016

interesting, though I wouldn't want a getting started message that included a substituted in admin username and generated password to be persisted as an object annotation

You could do worse than, "... (default username/password is admin/admin". Also, I'd expect people to be at least trying to use their SA as an oauth client, so it would be "... login with your openshift credentials".

@bparees
Copy link
Contributor

bparees commented Jul 7, 2016

@deads2k: can you take this topic to another issue/proposal?

@deads2k
Copy link
Contributor

deads2k commented Jul 7, 2016

@deads2k: can you take this topic to another issue/proposal?

I see it as a replacement for this pull, not an addition to it. Why would I want this feature if I had descriptions or creation messages on any API object and the existing template substitution logic?

@bparees
Copy link
Contributor

bparees commented Jul 7, 2016

because what you're proposing is way more tedious for a template author.

"this template creates a route with hostname $HOST}, your login is ${USER} and your password is ${PASSWORD}. You should go login and create a regular user account for yourself".

vs putting all that stuff on random resources within the template and who knows how it gets displayed to the user.

@deads2k
Copy link
Contributor

deads2k commented Jul 7, 2016

because what you're proposing is way more tedious for a template author.

"this template creates a route with hostname $HOST}, your login is ${USER} and your password is ${PASSWORD}. You should go login and create a regular user account for yourself".

vs putting all that stuff on random resources within the template and who knows how it gets displayed to the user.

Do you have a better example? That just turns into an annotation on the route:

"Exposes a <blank> server at $HOST with default credentials user/password. You should login and create a regular user account"

Looks like the same amount of work.

@bparees
Copy link
Contributor

bparees commented Jul 7, 2016

you haven't solved the problem of how all these random annotations get presented to the user in a cohesive way.

@smarterclayton
Copy link
Contributor

Let's have an in person discussion.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 11, 2016
@@ -870,6 +870,15 @@ type TemplateDescriber struct {
kctl.ObjectDescriber
}

// DescribePostProcessMessage prints the message that will be parameter substituted and displayed to the
// user when this template is processed.
func (d *TemplateDescriber) DescribePostProcessMessage(msg string, out *tabwriter.Writer) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename method

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to DescribeMessage(...)

@smarterclayton
Copy link
Contributor

API approved but one minor code change

// Parameter substitution will be performed on the message before being
// displayed so that generated credentials and other parameters can be
// included in the output.
Message string `json:"message,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

need to start this godoc w/ "message"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bparees It appears to in my view of the commit. There are several inline comments that split the full godoc in half in the github diff view.

Copy link
Contributor

Choose a reason for hiding this comment

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

whoops, you're right, it was just such a natural start to the comment I didn't think to scroll up, my bad.

@bparees
Copy link
Contributor

bparees commented Jul 11, 2016

one nit and lgtm.

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 34a3c56

@bparees
Copy link
Contributor

bparees commented Jul 11, 2016

[merge]

@openshift-bot
Copy link
Contributor

openshift-bot commented Jul 11, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6071/) (Image: devenv-rhel7_4567)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 34a3c56

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6054/)

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 11, 2016
@openshift-bot openshift-bot merged commit 1c784e0 into openshift:master Jul 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants