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

Human-readable revision describe #475

Merged
merged 7 commits into from
Nov 6, 2019

Conversation

sixolet
Copy link
Contributor

@sixolet sixolet commented Nov 4, 2019

Revision describe based on new format for service describe.

Non-verbose:

$ ./kn revision describe bar-bhndh-34 
Name:         bar-bhndh-34
Namespace:    default
Annotations:  autoscaling.knative.dev/target=-1
Age:          32d
Image:        gcr.io/knative-samples/helloworld-nodejs:latest (pinned to ae8c74)
Env:          ASDF=tame, BAZ=quux
Concurrency:  
  Limit:      1
  Target:     -1
CPU:          400m
Service:      bar

Conditions:  
  OK TYPE                  AGE REASON
  ++ Ready                 32d 
  ++ BuildSucceeded        32d 
  ++ ContainerHealthy      32d 
  ++ ResourcesAvailable    32d 
   I Active                32d NoTraffic

Verbose (note the extra info about service):

$ ./kn revision describe bar-bhndh-34 -v
Name:              bar-bhndh-34
Namespace:         default
Labels:            client.knative.dev/nonce=ygvkcsnvhj
                   serving.knative.dev/configuration=bar
                   serving.knative.dev/configurationGeneration=23
                   serving.knative.dev/service=bar
Annotations:       autoscaling.knative.dev/target=-1
                   client.knative.dev/user-image=gcr.io/knative-samples/helloworld-nodejs:latest
                   serving.knative.dev/lastPinned=1572895120
Age:               32d
Image:             gcr.io/knative-samples/helloworld-nodejs:latest (pinned to ae8c74)
Env:               ASDF=tame
                   BAZ=quux
Concurrency:       
  Limit:           1
  Target:          -1
CPU:               400m
Service:           bar
  Config Gen:      23
  Latest Created:  true
  Latest Ready:    true
  Traffic:         10%
  Tags:            latest

Conditions:  
  OK TYPE                  AGE REASON
  ++ Ready                 32d 
  ++ BuildSucceeded        32d 
  ++ ContainerHealthy      32d 
  ++ ResourcesAvailable    32d 
   I Active                32d NoTraffic (The target is not receiving traffic.)

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Nov 4, 2019
@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 4, 2019
@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 5, 2019
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.

Thanks, looks good to me !

Two points:

  • We shouldn't print a concurrency limit of 0 imo (it does mean to use the default limit, right ? So can just be left out or replaced by this default limit if we are able to query that)
  • We should reuse the common code of kn service describe and kn revision describe. But we can leave that for a later PR.

if ok {
serviceSection := dw.WriteAttribute("Service", serviceName)
if printDetails {
serviceSection.WriteAttribute("Config Gen", revision.Labels[servingserving.ConfigurationGenerationLabelKey])
Copy link
Contributor

Choose a reason for hiding this comment

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

As we are in verbose mode anyway, could we expand this to "Configuration Generation" or maybe just "Generation" ? (compromise: "Config Generation")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

pkg/kn/commands/describe.go Show resolved Hide resolved
}

// Format scale in the format "min ... max" with max = ∞ if not set
func formatScale(minScale *int, maxScale *int) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move that up to a FormatScale, reusable by service describe ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh dang, it looks like I slightly misued git and forgot part of the refactor when I resurrected this PR. Resurrecting that :)

pkg/kn/commands/revision/describe.go Outdated Show resolved Hide resolved
}

// Write request ... limits or only one of them
func writeResourcesHelper(dw printers.PrefixWriter, label string, request *resource.Quantity, limit *resource.Quantity) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method should be unified with the printing code for service describe.

return ret
}

func stringifyEnv(revision *v1alpha1.Revision) []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

unify with service describe.

Copy link
Contributor

@toVersus toVersus left a comment

Choose a reason for hiding this comment

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

A few suggestions, but not necessarily required to take in


envVars := make([]string, 0, len(container.Env))
for _, env := range container.Env {
var value string
Copy link
Contributor

Choose a reason for hiding this comment

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

		value := env.Value
		if env.ValueFrom != nil {
			value = "[ref]"
		}

var percent int64
tags := []string{}
for _, target := range service.Status.Traffic {
if target.RevisionName == name {
Copy link
Contributor

Choose a reason for hiding this comment

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

		if target.RevisionName != name {
			continue
		}
		if target.Percent != nil {
			percent += *target.Percent
		}
		if target.Tag != "" {
			tags = append(tags, target.Tag)
		}

pkg/kn/commands/describe.go Show resolved Hide resolved
pkg/kn/commands/revision/describe_test.go Show resolved Hide resolved
Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

A few error checks missing in addition to current comments.

Thanks for contribution.

pkg/kn/commands/revision/describe.go Show resolved Hide resolved

func WriteScale(dw printers.PrefixWriter, revision *v1alpha1.Revision) {
// Scale spec if given
scale, _ := clientserving.ScalingInfo(&revision.ObjectMeta)
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 want to nag but ignoring errors here... could easily be handled IMO.

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maximilien, sixolet

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

@maximilien
Copy link
Contributor

/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/describe.go 82.7% 73.1% -9.6
pkg/kn/commands/revision/describe.go 78.3% 57.5% -20.7
pkg/kn/commands/service/describe.go 83.7% 79.9% -3.8
pkg/serving/revision_template.go 87.5% 64.7% -22.8

@maximilien
Copy link
Contributor

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 6, 2019
@knative-prow-robot knative-prow-robot merged commit 4874b9a into knative:master Nov 6, 2019
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants