Skip to content

Include status reason in oc get build output - #4909

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
rhcarvalho:descriptive-oc-get-build
Oct 22, 2015
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
rhcarvalho:descriptive-oc-get-build

Conversation

@rhcarvalho

Copy link
Copy Markdown
Contributor

Useful to find at a glance potential errors with existing builds.

Follow up on #4872

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@thoraxe @smarterclayton @bparees PTAL

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

This is an example output of oc get build:

$ oc get build
NAME                    TYPE      FROM      STATUS    STARTED   MESSAGE
chained-builds-app1-1   Docker    Git       New                 the referenced output ImageStream demo/chained-builds-app1 does not exist

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

[test]

@smarterclayton

Copy link
Copy Markdown
Contributor

Hrm... That's probably too long. What are the pod limits? Also, it all
has to be limited to our standard char width for regular and wide outputs.

On Oct 2, 2015, at 8:10 AM, Rodolfo Carvalho [email protected]
wrote:

This is an example output of oc get build:

$ oc get build
NAME TYPE FROM STATUS STARTED MESSAGE
chained-builds-app1-1 Docker Git New the
referenced output ImageStream demo/chained-builds-app1 does not exist

—
Reply to this email directly or view it on GitHub
#4909 (comment).

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

That's probably too long.

I thought of that as well. I have tried limiting to e.g. 60 chars, but then you'll get partial information and have to figure out where to get the full message:

$ oc get build
NAME                    TYPE      FROM      STATUS    STARTED   MESSAGE
chained-builds-app1-1   Docker    Git       New                 the referenced output ImageStream demo/chained-builds-app...

We do show the full message in "oc describe".

What are the pod limits?

Pods don't seem to have any explicit limits on output width of the columns.

I discussed earlier today with @bparees an alternative to show a marker like a * after the status if there's any message, but then we discarded this idea since build.status.message doesn't imply error condition, and will leave users wondering what New*, Complete*, etc mean.

Having a ShortErrorMessage for builds would require adding a new field and make sure it stays in sync with build.status.message. Didn't seem very promising.

The current approach will show with all words what is wrong. For most builds the MESSAGE column will be empty, so it won't be cluttering the output.

WDYT?

it all has to be limited to our standard char width for regular and wide outputs

Couldn't find where we define those?

@smarterclayton

Copy link
Copy Markdown
Contributor

Hrm, we designed for 80 and 120 (-o wide). If we can predict the other
columns let's try to cap description (I would prefer a structured Reason
though).

On Oct 2, 2015, at 2:54 PM, Rodolfo Carvalho [email protected]
wrote:

That's probably too long.

I thought of that as well. I have tried limiting to e.g. 60 chars, but then
you'll get partial information and have to figure out where to get the full
message:

$ oc get build
NAME TYPE FROM STATUS STARTED MESSAGE
chained-builds-app1-1 Docker Git New the
referenced output ImageStream demo/chained-builds-app...

We do show the full message in "oc describe".

What are the pod limits?

Pods don't seem to have
https://github.com/openshift/origin/blob/master/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go#L528-L594
any explicit limits on output width of the columns.

I discussed earlier today with @bparees https://github.com/bparees an
alternative to show a marker like a * after the status if there's any
message, but then we discarded this idea since build.status.message doesn't
imply error condition, and will leave users wondering what New_, Complete_,
etc mean.

Having a ShortErrorMessage for builds would require adding a new field and
make sure it stays in sync with build.status.message. Didn't seem very
promising.

The current approach will show with all words what is wrong. For most
builds the MESSAGE column will be empty, so it won't be cluttering the
output.

WDYT?

it all has to be limited to our standard char width for regular and wide
outputs

Couldn't find where we define those?

—
Reply to this email directly or view it on GitHub
#4909 (comment).

@smarterclayton

Copy link
Copy Markdown
Contributor

Pods today change the status field with more info. I think that's a good
place to start to set context

On Oct 2, 2015, at 2:54 PM, Rodolfo Carvalho [email protected]
wrote:

That's probably too long.

I thought of that as well. I have tried limiting to e.g. 60 chars, but then
you'll get partial information and have to figure out where to get the full
message:

$ oc get build
NAME TYPE FROM STATUS STARTED MESSAGE
chained-builds-app1-1 Docker Git New the
referenced output ImageStream demo/chained-builds-app...

We do show the full message in "oc describe".

What are the pod limits?

Pods don't seem to have
https://github.com/openshift/origin/blob/master/Godeps/_workspace/src/k8s.io/kubernetes/pkg/kubectl/resource_printer.go#L528-L594
any explicit limits on output width of the columns.

I discussed earlier today with @bparees https://github.com/bparees an
alternative to show a marker like a * after the status if there's any
message, but then we discarded this idea since build.status.message doesn't
imply error condition, and will leave users wondering what New_, Complete_,
etc mean.

Having a ShortErrorMessage for builds would require adding a new field and
make sure it stays in sync with build.status.message. Didn't seem very
promising.

The current approach will show with all words what is wrong. For most
builds the MESSAGE column will be empty, so it won't be cluttering the
output.

WDYT?

it all has to be limited to our standard char width for regular and wide
outputs

Couldn't find where we define those?

—
Reply to this email directly or view it on GitHub
#4909 (comment).

@rhcarvalho
rhcarvalho force-pushed the descriptive-oc-get-build branch from e5f4e72 to 2e0c8fa Compare October 5, 2015 14:25
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

Hrm, we designed for 80 and 120 (-o wide). If we can predict the other
columns let's try to cap description (I would prefer a structured Reason
though).

@smarterclayton I'm going with your preferred way, adding a new Build.Status.Reason field.

Seems that in oc get build the width of the columns is not well defined / not limited and we ignore the wide flag. I opened an issue as a reminder to tackle it later #4950.

@rhcarvalho rhcarvalho changed the title Include status message in oc get build output Include status reason in oc get build output Oct 5, 2015
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@smarterclayton @bparees PTAL

Comment thread pkg/build/controller/controller.go Outdated

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'd prefer to see all these as constants defined in a single location

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.

There should be one set of constants in build/api

@rhcarvalho
rhcarvalho force-pushed the descriptive-oc-get-build branch from 2e0c8fa to 317d8d2 Compare October 6, 2015 10:53
@rhcarvalho
rhcarvalho force-pushed the descriptive-oc-get-build branch from 317d8d2 to b083f0a Compare October 6, 2015 14:16
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

Comments addressed, PTAL.

@bparees

bparees commented Oct 7, 2015

Copy link
Copy Markdown
Contributor

needs squashing

@rhcarvalho
rhcarvalho force-pushed the descriptive-oc-get-build branch from b083f0a to cb84a10 Compare October 8, 2015 14:43
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

squashed

Comment thread pkg/build/controller/factory/factory.go Outdated

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.

len(build.Status.Reason) == 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

why?

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.

π ~/go/src/github.com/openshift/origin grep -R '== 0' pkg/ | wc -l
896
π ~/go/src/github.com/openshift/origin grep -R '== ""' pkg/ | wc -l
66

consistency?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Isn't grep losing context in this case?
AFAIK the idiomatic way to check if a string is the empty string in Go is to do that obvious comparison.
https://groups.google.com/d/msg/golang-nuts/7Ks1iq2s7FA/GOujoyeYsOcJ
That post dates back to 2010, and for already some years the compiler is good enough that there's no significant difference in compiled code.

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.

It's a convention we follow in our codebase to not compare against empty strings.

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.

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.

We use len(str) == 0 as our empty string check everywhere

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm interested to know why do we do it that way?

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.

Convention. We picked one pattern and enforced it.

On Oct 11, 2015, at 3:34 PM, Rodolfo Carvalho [email protected]
wrote:

In pkg/build/controller/factory/factory.go
#4909 (comment):

@@ -95,6 +96,10 @@ func (factory _BuildControllerFactory) Create() controller.RunnableController {
build := obj.(_buildapi.Build)
err := buildController.HandleBuild(build)
if err != nil {

  •         // Set default Reason.
    
  •         if build.Status.Reason == "" {
    

I'm interested to know why do we do it that way?

—
Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/4909/files#r41714498.

@mfojtik

mfojtik commented Oct 8, 2015

Copy link
Copy Markdown
Contributor

two small nits, LGTM otherwise... would love to see some tests for this ;-)

@danmcp

danmcp commented Oct 16, 2015

Copy link
Copy Markdown

@rhcarvalho Bump

@openshift-bot

Copy link
Copy Markdown
Contributor

@rhcarvalho
rhcarvalho force-pushed the descriptive-oc-get-build branch 2 times, most recently from de31810 to 463f0f9 Compare October 21, 2015 14:49
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

The first commit is part of #5275.

I've updated the implementation so that the output will look like this:

$ oc get builds
NAME                    TYPE      FROM         STATUS                         STARTED
centos-1                Docker    Dockerfile   Complete                       2 minutes ago
chained-builds-app1-1   Docker    Git          New (InvalidOutputReference)   

@bparees @mfojtik PTAL

@mfojtik

mfojtik commented Oct 21, 2015

Copy link
Copy Markdown
Contributor

@rhcarvalho looks better imho :-)

Comment thread pkg/build/api/v1/types.go Outdated

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.

do we really need these constants defined in the public api?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

IIRC it was motivated by this comment: #4909 (comment).

I followed the pattern for what we do in similar cases. If Build.Status.Reason is of some specific type, then I think the constants should be exported.

We can also have it be a plain string, but then the compiler wouldn't help us ensure the reason is one of a known set of "constants defined in a single location".

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 don't have any problem with there being constants for it, i agree there should be i, i just don't see why you need to define the same constants 3 times. I would think it would be sufficient to define them in the internal types.go and be done with it, given how it's being used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I share the same feeling about declaring it 3 times. But that's how we do it for all other constants: they are declared in api/types.go, api/v1/types.go and api/v1beta3/types.go.

I don't have the answer for why we do it that way.

It was already some time since I wrote that code, but one thing I remember is that it affects conversion code. Maybe we don't want to have interdependency among the api packages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If I remove the constant from api/v1/types.go, then will have to write in that file:

// BuildStatus contains the status of a build
type BuildStatus struct {
    // Phase is the point in the build lifecycle.
    Phase BuildPhase `json:"phase"`

    // Cancelled describes if a cancelling event was triggered for the build.
    Cancelled bool `json:"cancelled,omitempty"`

    // Reason is a brief CamelCase string that describes any failure and is meant for machine parsing and tidy display in the CLI.
    Reason api.StatusReason `json:"reason,omitempty" description:"brief CamelCase string describing a failure, meant for machine parsing and tidy display in the CLI"`
...

It doesn't seem right to me to make a versioned api depend on an unversioned, internal type.

Unless we make the Reason field of type string, which has the disadvantage of losing the type checking.

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.

you can define the type without defining the actual constants.

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.

(03:36:56 PM) claytonc: bparees: i'm just going to hazard a guess, but if you're talking about constants, we should only put constants in internal unless they're different
(03:36:59 PM) claytonc: and since constants shouldn't change
(03:37:06 PM) claytonc: we should always just add new constants to the internal api
(03:37:13 PM) claytonc: regarding the structs
(03:37:20 PM) claytonc: you should add them to the v1beta3 structs and convertsions
(03:37:31 PM) bparees: claytonc: yeah i was only talking about the constants.

@bparees

bparees commented Oct 21, 2015

Copy link
Copy Markdown
Contributor

question about constants in the api, last two commits should be squashed, and then lgtm.

@rhcarvalho
rhcarvalho force-pushed the descriptive-oc-get-build branch from 463f0f9 to a21de26 Compare October 21, 2015 16:33
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@bparees regarding the API changes, I'd ask for @smarterclayton's API review on that (and the rest of API changes).

@smarterclayton is it alright to have those exported constants in the API?

@bparees

bparees commented Oct 21, 2015

Copy link
Copy Markdown
Contributor

i'm less concerned about whether it's "alright" and more concerned about what purpose it serves.

@rhcarvalho
rhcarvalho force-pushed the descriptive-oc-get-build branch from a21de26 to a582538 Compare October 21, 2015 21:11
@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@bparees I've removed the constants from api/v1 and api/v1beta3 as you wanted. I think it is in disparity with the other constants in all other cases I've seen. For example, the constants for api/v1 BuildPhase are not referenced anywhere (according to my go oracle...). But cleaning that up is another endeavor I'm not taking now :D

@bparees

bparees commented Oct 21, 2015

Copy link
Copy Markdown
Contributor

lgtm and i'm taking #4909 (comment) as an api sign off from @smarterclayton

@bparees

bparees commented Oct 21, 2015

Copy link
Copy Markdown
Contributor

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/3722/) (Image: devenv-rhel7_2521)

@smarterclayton

Copy link
Copy Markdown
Contributor

Yes, is fine.

@smarterclayton

Copy link
Copy Markdown
Contributor

[test]

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

Looks like the merge failed because of a test flake in test/cmd/newapp.sh:24?
It's similar to this issue reported a couple of weeks ago: #4948

And include status reason in oc get build output. Useful to find at a
glance potential errors with existing builds.

Also, clear build reason and message on phase change.
Message is a human-readable message indicating details about why the
build has this status, but we were never clearing the message after
status changes.
@rhcarvalho
rhcarvalho force-pushed the descriptive-oc-get-build branch from a582538 to 785cdc8 Compare October 22, 2015 07:52
@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 785cdc8

@rhcarvalho

Copy link
Copy Markdown
Contributor Author

@bparees @smarterclayton I rebased against master to get rid of the first commit that was merged in #5275.
The changeset I'm introducing as part of this PR is unmodified.

This is the merge job that failed yesterday: https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/3718/consoleFull
Hope it will work today 🙏

@mfojtik

mfojtik commented Oct 22, 2015

Copy link
Copy Markdown
Contributor

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 785cdc8

openshift-bot pushed a commit that referenced this pull request Oct 22, 2015
@openshift-bot
openshift-bot merged commit df76ab6 into openshift:master Oct 22, 2015
@rhcarvalho
rhcarvalho deleted the descriptive-oc-get-build branch October 22, 2015 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants