Repository navigation
feat(helm): Supporting helm3 to show up resource names in helm status - #10912
Conversation
|
@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 |
|
@SoujanyaMangipudi Please squash your commits into one commit. |
f106185 to
e052c7f
Compare
@yxxhero squashed all my commits as mentioned |
|
re opening |
mattfarina
left a comment
There was a problem hiding this comment.
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.
| // IsReachable checks whether the client is able to connect to the cluster. | ||
| IsReachable() error | ||
|
|
||
| Get(resources ResourceList, reader io.Reader) (string, error) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Updated implementation by adding InterfaceResources to avoid breaking changes as recommended
| if len(s.release.Info.Resources) > 0 { | ||
| fmt.Fprintf(out, "RESOURCES:\n%s\n", s.release.Info.Resources) | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Updated implementation to move the new status functionality behind --show-resources flag as recommended
| if len(s.release.Info.Resources) > 0 { | ||
| fmt.Fprintf(out, "RESOURCES:\n%s\n", s.release.Info.Resources) | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Updated implementation to move the new status functionality behind --show-resources flag as recommended
@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 a gentle reminder on this PR. Can you please review? |
|
@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 |
@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
left a comment
There was a problem hiding this comment.
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.
| if s.showResources && len(s.release.Info.Resources) > 0 { | ||
| fmt.Fprintf(out, "RESOURCES:\n%s\n", s.release.Info.Resources) | ||
| } |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
@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
|
@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
left a comment
There was a problem hiding this comment.
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.
| keys = append(keys, key) | ||
| } | ||
|
|
||
| for _, t := range keys { |
There was a problem hiding this comment.
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...

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.
There was a problem hiding this comment.
@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

Yaml

Json

Can you please take a look to see if it works?
There was a problem hiding this comment.
@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?
a7ccfeb to
bed2312
Compare
…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]>
Somangip/mergeto main
|
@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? |
|
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]>
Signed-off-by: Soujanya Mangipudi <[email protected]>
@bridgetkromhout I resolved all the merge conflicts now |
|
@SoujanyaMangipudi I came to review this again only to find the go.sum merge conflict again. |
…HelmMain1219 Signed-off-by: Soujanya Mangipudi <[email protected]>
Somangip/merge helm main1219
@mattfarina I resolved the conflicts again. Can you please take a look and re-trigger the workflows? |
scottrigby
left a comment
There was a problem hiding this comment.
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. |
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]>
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)
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]>
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]>
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:
