Skip to content

feat(helm): Supporting helm3 to show up resource names in helm status - #10912

Merged
mattfarina merged 10 commits into
helm:mainfrom
SoujanyaMangipudi:main
Dec 23, 2022
Merged

mattfarina merged 10 commits into
helm:mainfrom
SoujanyaMangipudi:main

Conversation

@SoujanyaMangipudi

@SoujanyaMangipudi SoujanyaMangipudi commented Apr 28, 2022 •

Copy link
Copy Markdown
Contributor

feat(helm): Supporting helm3 to show up resource names that were deployed as part of release in helm status command

Creating a new PR based on this existing stale PR #7728

Sample output for helm status command with new --show-resources flag:
image

@pull-request-size pull-request-size Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 28, 2022
@SoujanyaMangipudi

SoujanyaMangipudi commented Apr 28, 2022 •

Copy link
Copy Markdown
Contributor Author

@bacongobbler, @mattfarina I picked this previous PR #7728 for updating helm status command as this is a feature that will be useful in our internal implementations. This code also fixes some of the issues the previous PR has i.e. duplicate pod display and not all resources getting displayed. Can you please review and provide your feedback on the same? If possible our target is to merge this feature into helm 3.9.0

@yxxhero

yxxhero commented Apr 29, 2022

Copy link
Copy Markdown
Member

@SoujanyaMangipudi Please squash your commits into one commit.

@SoujanyaMangipudi
SoujanyaMangipudi force-pushed the main branch 2 times, most recently from f106185 to e052c7f Compare April 29, 2022 17:52
@SoujanyaMangipudi

Copy link
Copy Markdown
Contributor Author

@SoujanyaMangipudi Please squash your commits into one commit.

@yxxhero squashed all my commits as mentioned

@SoujanyaMangipudi

Copy link
Copy Markdown
Contributor Author

re opening

@mattfarina mattfarina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for getting this going again.

While I have not had a chance to do a full review, a couple things jumped right out to me. I was looking for these as we had discussed them with regard to the previous work on this.

Comment thread pkg/kube/interface.go Outdated
// IsReachable checks whether the client is able to connect to the cluster.
IsReachable() error

Get(resources ResourceList, reader io.Reader) (string, error)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Unfortunately, this Interface can't be changed. It would be compatibility breaking so we can't do it until Helm v4. The HIP that describes backwards compatibility points to the Go projects stance and method for handling this.

If you look in this file you'll see we're done this before with InterfaceExt. We'll need another new one like InterfaceGet or something similar. Could you please add the comment about merging this with the main interface for Helm v4, like InterfaceExt does.

Also, could you please document the function.

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.

Updated implementation by adding InterfaceResources to avoid breaking changes as recommended

Comment thread cmd/helm/status.go Outdated
Comment on lines +127 to +158
if len(s.release.Info.Resources) > 0 {
fmt.Fprintf(out, "RESOURCES:\n%s\n", s.release.Info.Resources)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The Helm HIP on backwards compatibility covers CLI output and notes that structure can't change. Since Helm v3 has not showed the resources up to this point, displaying them needs to happen behind a flag. Could you please add a flag for this with a note to remove the flag in Helm v4.

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.

Updated implementation to move the new status functionality behind --show-resources flag as recommended

Comment thread cmd/helm/status.go Outdated
Comment on lines +127 to +158
if len(s.release.Info.Resources) > 0 {
fmt.Fprintf(out, "RESOURCES:\n%s\n", s.release.Info.Resources)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The Helm HIP on backwards compatibility covers CLI output and notes that structure can't change. Since Helm v3 has not showed the resources up to this point, displaying them needs to happen behind a flag. Could you please add a flag for this with a note to remove the flag in Helm v4.

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.

Updated implementation to move the new status functionality behind --show-resources flag as recommended

@SoujanyaMangipudi

Copy link
Copy Markdown
Contributor Author

Thank you for getting this going again.

While I have not had a chance to do a full review, a couple things jumped right out to me. I was looking for these as we had discussed them with regard to the previous work on this.

@mattfarina thank you so much for starting the review on this PR. I updated the PR to avoid any breaking changes as mentioned in your comments. Can you please review and let me know any further changes required?

@mattfarina mattfarina added this to the 3.10.0 milestone May 12, 2022
@SoujanyaMangipudi

Copy link
Copy Markdown
Contributor Author

@mattfarina a gentle reminder on this PR. Can you please review?

@mattfarina

Copy link
Copy Markdown
Collaborator

@SoujanyaMangipudi I was coming to review this (it's on my todo list... for real) and I noticed there is a merge conflict with the go.sum file. Can you fix this and then I'll come back and review it. I'm really looking forward to getting this in.

@SoujanyaMangipudi

Copy link
Copy Markdown
Contributor Author

@SoujanyaMangipudi I was coming to review this (it's on my todo list... for real) and I noticed there is a merge conflict with the go.sum file. Can you fix this and then I'll come back and review it. I'm really looking forward to getting this in.

@mattfarina I merged helm main branch into my branch now and the PR shows no conflicts anymore. Please let me know in case anything else is needed.

@mattfarina mattfarina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for continuing to work on this PR. It's almost there. When testing with JSON and YAML output formats I noticed an issue and was wondering if you could fix it.

Comment thread cmd/helm/status.go Outdated
Comment on lines +130 to +158
if s.showResources && len(s.release.Info.Resources) > 0 {
fmt.Fprintf(out, "RESOURCES:\n%s\n", s.release.Info.Resources)
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is sending a text blob with the status rather than a JSON structure of the status. kubectl will provide a JSON object with the status when outputting json (or YAML when outputting YAML). Would it be possible to have a JSON output for the status instead of the text block reported for table output?

This would, I think, mean moving the printer usage out of Get and to the place it's printed.

@SoujanyaMangipudi SoujanyaMangipudi Jun 27, 2022 •

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.

@mattfarina while checking further I realized json and yaml outputs for status command already print manifest which is the list of release resources. Do you think it will be a better implementation to remove resources from these output formats and keep it only for normal output mode? What I mean is Resources will be shown only when helm status command is executed without any output formats. json or yaml format will not show helm status and continue to behave the way if it is today

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.

@mattfarina I really want to merge this PR in release 3.10 and need a little input and help for this comment. At this point I wonder if we can leave this as is as this does not break the json functionality. Json and Yaml commands already print manifest so resources will just be something additional. What are your thoughts on this? @bridgetkromhout FYI on the resources printing feature for helm 3.10

@Jont828

Jont828 commented Jul 7, 2022 •

Copy link
Copy Markdown

@SoujanyaMangipudi Thanks for working on this! I'm working on a project where I import Helm as a library and I'd like to be able to check to see if all the pods/deployments in the manifest are ready. I'm not too familiar with Helm's codebase, but if I understand correctly, is the idea of this PR to query the manifest and build a kube client to query each resource?

@mattfarina mattfarina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

While I like the idea, the place where the resources are turned into a string is the wrong place. It should not happen within the client API. That should be a data structure that can be turned into the display at the display time. This is the one major change that I think needs to happen. This way yaml and json outputs can be supported in addition to Helm SDK users... so they don't need to parse strings.

Comment thread pkg/kube/client.go Outdated
keys = append(keys, key)
}

for _, t := range keys {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

When I try to output using yaml or json the resources section is one long string. This is because Get returns a string rather than a data structure that can be transformed into yaml, json, or a string output. See...
Screenshot from 2022-09-08 13-39-37

Get should return a data structure for the resources. Then when they are printed they can be turned into a string, json, or yaml.

The conversion to a string should happen elsewhere and should not be in the client 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.

@mattfarina thank you for your guidance on this! I believe I was able to make the required changes and successfully test on local with all 3 formats
image
Yaml
image
Json
image

Can you please take a look to see if it works?

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.

@mattfarina sorry for repeated pings like I mentioned before we wanted this feature to get merged into helm 3.10 release. Hence was wondering if you take a look at latest changes?

@pull-request-size pull-request-size Bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 9, 2022
…oyed as part of release in helm status command

Creating a new PR based on this existing stale PR helm#7728

Signed-off-by: Soujanya Mangipudi <[email protected]>

# Conflicts:
#	go.sum
Extend Interface with new InterfaceResources to avoid breaking changes
Move change to staus command behind --show-resources flag

Signed-off-by: Soujanya Mangipudi <[email protected]>
Signed-off-by: Soujanya Mangipudi <[email protected]>

fix circleci tests

Signed-off-by: Soujanya Mangipudi <[email protected]>

fix formatting errors

Signed-off-by: Soujanya Mangipudi <[email protected]>

fix tests

Signed-off-by: Soujanya Mangipudi <[email protected]>

fix tests

Signed-off-by: Soujanya Mangipudi <[email protected]>

fix gofmt issue

Signed-off-by: Soujanya Mangipudi <[email protected]>
@hickeyma hickeyma modified the milestones: 3.10.0, 3.11.0 Sep 23, 2022

@mattfarina mattfarina left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Note, there is cleanup that would need to be done after this to restore k8s 1.25 support. I'm willing to make the change for that prior to cutting the release.

@SoujanyaMangipudi

Copy link
Copy Markdown
Contributor Author

@mattfarina thank you so much for approving my PR. Regarding next steps as I don't have permissions to merge the PR will you be able to help me with that?

@bridgetkromhout

Copy link
Copy Markdown
Member

Hi @SoujanyaMangipudi Looks like we now have merge conflicts that need to be resolved on this PR. Thanks.

Signed-off-by: Soujanya Mangipudi <[email protected]>
@pull-request-size pull-request-size Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 12, 2022
@pull-request-size pull-request-size Bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 12, 2022
@SoujanyaMangipudi

Copy link
Copy Markdown
Contributor Author

Hi @SoujanyaMangipudi Looks like we now have merge conflicts that need to be resolved on this PR. Thanks.

@bridgetkromhout I resolved all the merge conflicts now

@mattfarina

Copy link
Copy Markdown
Collaborator

@SoujanyaMangipudi I came to review this again only to find the go.sum merge conflict again.

@SoujanyaMangipudi

SoujanyaMangipudi commented Dec 19, 2022 •

Copy link
Copy Markdown
Contributor Author

@SoujanyaMangipudi I came to review this again only to find the go.sum merge conflict again.

@mattfarina I resolved the conflicts again. Can you please take a look and re-trigger the workflows?

@scottrigby scottrigby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This all looks fantastic, great work @SoujanyaMangipudi 👍

As a side note, there was an issue reported in the PR that this one was based on (#7728) related to helm rollback. It wasn't clear how that PR would affect helm rollback, and more info was requested by the reporter but never given. For good measure here, I've tried but haven't been able to reproduce that issue here.

@SoujanyaMangipudi

Copy link
Copy Markdown
Contributor Author

This all looks fantastic, great work @SoujanyaMangipudi 👍

As a side note, there was an issue reported in the PR that this one was based on (#7728) related to helm rollback. It wasn't clear how that PR would affect helm rollback, and more info was requested by the reporter but never given. For good measure here, I've tried but haven't been able to reproduce that issue here.

Thank you @scottrigby! We now moved the new functionality behind a --show-resources flag for helm status command and also created a new InterfaceResources extension to avoid breaking changes. I believe these two changes handled the original issue reported.

@mattfarina
mattfarina merged commit eb7150f into helm:main Dec 23, 2022
mattfarina added a commit to mattfarina/helm that referenced this pull request Jan 12, 2023
Fixes helm#11712

A change was made that when validation was turned off the Kubernetes
packages were building objects as a Table type. This was done for
display purposes. When details about the objects was going to be
printed as part of helm#10912.

This broke rollback, and possibly other functionality, as a Table
type was returned in some cases that needed the regular object.
This caused things to break silently.

The fix involved adding in a new Function (and interface) to
query for tables instead of the objects themselves. There was not
a clean way to add it to the existing function that covered all
cases.

A second problem was noticed along the way. When data was output
via status as YAML or JSON it was in the form of a table rather
than the objects themselves. This did not reflect expectations
and did not match the functionality in kubectl. The code was
updated to return a table when that was presented and the objects
when they are being output for YAML or JSON. The API also supports
this handling to SDK users can replicate this functionality.

API changes made here were never released. The functions were
developed for this release of Helm and only ever appeared in an
RC. In this case, they can be changed.

Signed-off-by: Matt Farina <[email protected]>
mattfarina added a commit that referenced this pull request Jan 13, 2023
Fixes #11712

A change was made that when validation was turned off the Kubernetes
packages were building objects as a Table type. This was done for
display purposes. When details about the objects was going to be
printed as part of #10912.

This broke rollback, and possibly other functionality, as a Table
type was returned in some cases that needed the regular object.
This caused things to break silently.

The fix involved adding in a new Function (and interface) to
query for tables instead of the objects themselves. There was not
a clean way to add it to the existing function that covered all
cases.

A second problem was noticed along the way. When data was output
via status as YAML or JSON it was in the form of a table rather
than the objects themselves. This did not reflect expectations
and did not match the functionality in kubectl. The code was
updated to return a table when that was presented and the objects
when they are being output for YAML or JSON. The API also supports
this handling to SDK users can replicate this functionality.

API changes made here were never released. The functions were
developed for this release of Helm and only ever appeared in an
RC. In this case, they can be changed.

Signed-off-by: Matt Farina <[email protected]>
(cherry picked from commit 36e18fa)
wujunwei pushed a commit to wujunwei/helm that referenced this pull request Jan 30, 2023
Fixes helm#11712

A change was made that when validation was turned off the Kubernetes
packages were building objects as a Table type. This was done for
display purposes. When details about the objects was going to be
printed as part of helm#10912.

This broke rollback, and possibly other functionality, as a Table
type was returned in some cases that needed the regular object.
This caused things to break silently.

The fix involved adding in a new Function (and interface) to
query for tables instead of the objects themselves. There was not
a clean way to add it to the existing function that covered all
cases.

A second problem was noticed along the way. When data was output
via status as YAML or JSON it was in the form of a table rather
than the objects themselves. This did not reflect expectations
and did not match the functionality in kubectl. The code was
updated to return a table when that was presented and the objects
when they are being output for YAML or JSON. The API also supports
this handling to SDK users can replicate this functionality.

API changes made here were never released. The functions were
developed for this release of Helm and only ever appeared in an
RC. In this case, they can be changed.

Signed-off-by: Matt Farina <[email protected]>
scottrigby pushed a commit to scottrigby/helm that referenced this pull request Feb 21, 2023
Fixes helm#11712

A change was made that when validation was turned off the Kubernetes
packages were building objects as a Table type. This was done for
display purposes. When details about the objects was going to be
printed as part of helm#10912.

This broke rollback, and possibly other functionality, as a Table
type was returned in some cases that needed the regular object.
This caused things to break silently.

The fix involved adding in a new Function (and interface) to
query for tables instead of the objects themselves. There was not
a clean way to add it to the existing function that covered all
cases.

A second problem was noticed along the way. When data was output
via status as YAML or JSON it was in the form of a table rather
than the objects themselves. This did not reflect expectations
and did not match the functionality in kubectl. The code was
updated to return a table when that was presented and the objects
when they are being output for YAML or JSON. The API also supports
this handling to SDK users can replicate this functionality.

API changes made here were never released. The functions were
developed for this release of Helm and only ever appeared in an
RC. In this case, they can be changed.

Signed-off-by: Matt Farina <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature 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