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

Add support for projected volume in describe function #70158

Merged

Conversation

WanLinghao
Copy link
Contributor

@WanLinghao WanLinghao commented Oct 24, 2018

/kind bug

Currently, the output of kubectl describe pod xxx shows as below when it has projected volume bounds:

Volumes:
  token:
  <unknown>
  default-token-4wx7l:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-4wx7l
    Optional:    false

After this patch, the output will be like

Volumes:
  token:
    Type:  Projected (a volume that contains injected data)
           - Secret:
             Name:      dzd
             Optional:  false
           - Token:
             ExpirationSeconds:  4000
           - ConfigMap:
             Name:      kube-root-ca.crt
             Optional:  false
           - DownwardAPI
  default-token-4wx7l:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-4wx7l
    Optional:    false

add support for projected volume in describe function 

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Oct 24, 2018
@juanvallejo
Copy link
Contributor

/sig cli

@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 24, 2018
infos := []string{}
for _, source := range projected.Sources {
if source.Secret != nil {
infos = append(infos, fmt.Sprintf(" - Secret:\n"+
Copy link
Contributor

Choose a reason for hiding this comment

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

Indent by 4 spaces here

Copy link
Contributor

@juanvallejo juanvallejo Oct 24, 2018

Choose a reason for hiding this comment

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

Also, to keep consistency with other volume describers, I'd be in favor of removing the - at the beginning of this section, and just squashing it down so it reads like:

    SecretName: ...
    SecretOptional: ...
    TokenExpirationSeconds: ...
    ...

@neolit123
Copy link
Member

/kind feature
@WanLinghao please add a release note that explains the change instead of NONE.
the PR title can be used for that.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. labels Oct 24, 2018
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 25, 2018
@WanLinghao
Copy link
Contributor Author

@juanvallejo Thanks for the review. Comments addressed, now the output looks like:

Volumes:
  token:
    Type:                    Projected (a volume that contains injected data)
    SecretName:              user
    SecretOptionalName:      true
    TokenExpirationSeconds:  4000
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       true
    DownwardAPI

DownwardAPI is special, since data in DownwardAPI is too complicate to print, so if DonwardAPI volume exists in the projected volume, just print "DownwardAPI" with no data. WDYT

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 25, 2018
@WanLinghao
Copy link
Contributor Author

@neolit123 Done

}
}

w.Write(LEVEL_2, "Type:\tProjected (a volume that contains injected data)\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

s/a volume that contains injected data/a volume that contains injected data from multiple sources/ ?

@juanvallejo
Copy link
Contributor

if DonwardAPI volume exists in the projected volume, just print "DownwardAPI" with no data. WDYT

Sure, alternatively, we could print "true" or the amount of items referenced under downwardAPI

DownwardAPI     true

or

DownwardAPI     2 items

@juanvallejo
Copy link
Contributor

/lgtm

Thanks, cc @soltysh for approval

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 25, 2018
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 26, 2018
@WanLinghao
Copy link
Contributor Author

@soltysh @juanvallejo comments addressed, now the output looks like:

Volumes:
  token:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    SecretName:              user
    SecretOptionalName:      <nil>
    TokenExpirationSeconds:  4000
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true

@WanLinghao
Copy link
Contributor Author

/test pull-kubernetes-verify

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

Also, please squash your changes into a single commit.

@@ -837,6 +839,31 @@ func printConfigMapVolumeSource(configMap *api.ConfigMapVolumeSource, w PrefixWr
configMap.Name, optional)
}

func printProjectedVolumeSource(projected *api.ProjectedVolumeSource, w PrefixWriter) {
infos := []string{}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why you're creating this array if you're then writing it, why not just directly writing to writer?

@WanLinghao
Copy link
Contributor Author

@soltysh Comments addressed, PTAL

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 29, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: soltysh, WanLinghao

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2018
@k8s-ci-robot k8s-ci-robot merged commit a9406c0 into kubernetes:master Oct 29, 2018
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants