-
Notifications
You must be signed in to change notification settings - Fork 193
Conversation
Hi @praveenrewar! And thank you for opening your first Pull Request. Someone will review it soon. Thank you for committing to making Tanzu Framework better. |
} | ||
return format | ||
} | ||
func nonExitingMain(p *plugin.Plugin) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the name nonExitingMain
? (Cause it looks like to me it is a non-blocking function while the name says something else, the name a bit confuses me)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main()
function uses os.Exit()
to exit when an error is returned and therefore wouldn't run the defer
functions. We use a function which simply returns an error instead of using os.Exit()
, hence the name nonExitingMain
.
But, I see how it could be a bit confusing, let me know if you have any suggestions for an alternative :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an odd name. Can we call the function what it is doing? Something like kctrlInvoke?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am okay with kctrlInvoke
, however that's not the only thing this function is doing, it's also executing the cmd.
} | ||
|
||
func (adapterUI *AdapterUI) PrintLinef(pattern string, args ...interface{}) { | ||
if strings.Contains(pattern, "Target cluster") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a comment on what this function is meant to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the name of the function is so generic, yet it excludes some specific string like "Target cluster"
, and that is confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a comment on what this function is meant to do?
Sure. Will do.
Also the name of the function is so generic, yet it excludes some specific string like "Target cluster", and that is confusing
The idea is to override the kctrl ui using an adapter ui, so I can't use another name here, but the exclusion of certain strings simply based on a specific pattern bothers me as well. I will see how I can improve it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @maralavi that the check is confusing. Could we link the issue that is resolving this in the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this should be done using the tty flag, but there is an issue with the tty flag where in it is always set to true unless the output is being piped. The issue exists in all the carvel tools and we will be fixing it soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once the tty issue is fixed, we should be able to remove the PrintLinef
"override".
Cluster Generation A/B Results: |
Cluster Generation A/B Results: |
Cluster Generation A/B Results: |
Cluster Generation A/B Results: |
Cluster Generation A/B Results: |
Cluster Generation A/B Results: |
pkg/v1/tkg/test/tkgpackageclient/package_plugin_integration_test.go
Outdated
Show resolved
Hide resolved
Added package repository 'standard-repo' | ||
>>> tanzu package repository add standard-repo --url projects-stg.registry.vmware.com/tkg/test-packages/standard-repo:v1.0.0 -n test-ns | ||
Waiting for package repository to be added | ||
4:04:00PM: packagerepository/standard-repo (packaging.carvel.dev/v1alpha1) namespace: test-ns: Reconciling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this 4:04:00PM
part of the output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This deviates from ISO 8601 format used by tanzu CLI https://github.com/vmware-tanzu/tanzu-framework/blob/main/docs/cli/style_guide.md#time-format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think in this case it's a good exception to the rule -- we want to provide "non-distracting" indication of time passing as output is being added to the screen, user is not interested in full timestamp on every line as it is just noise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to document that is a divergence from rest of plugins with the reasoning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Please let me know the best place to document this.
Cluster Generation A/B Results: |
Cluster Generation A/B Results: |
Bump kapp-controller to v0.34.0 and run go mod tidy
Attach kctrl package command tree to package plugin
The ui adapter is used to make kctrl package command tree consistent with package plugin
Modify tkgpackageclient integration tests according to changes introduced by kctrl
Thanks for the changes @praveenrewar . In Order to make sure no regression has happened, I built from this branch and tested some of the package plugin commands with kctrl integration. The followings are some comments for the commands I tested:
As a reference, in the existing package plugin (not using kctrl), the output was as follows:
And when not providing the version, it was as follows:
|
@maralavi Thanks for looking into the PR. I will reply to all the questions/suggestions in some time, but most of them are design changes that we did intentionally and some of them are good suggestions that I would like to take up with another PR. |
Yep, this was intended. I am thinking of adding these changes to the release notes if that will be helpful.
I honestly don't remember if this was intended or not. If not, I will definitely make this change in the next release of kctrl.
I guess this happening because there's no update to make. We could definitely add an error message here or maybe a hint.
The error message is actually surfaced from kapp-controller, I will look into how we can tweak it a bit.
Yeah, this seems like a bug to me. This would definitely need resolution before the current PR is merged.
Seems like a reasonable ask. I will update it.
The error message suggests that the installed package is not using any values file. We can maybe try to improve the error message a bit.
Yep, this is also intended.
Good catch. I will update it. I will try to address the bug in this PR itself by making changes in kctrl and bumping the commit hash and for the rest of suggestions I will try to make the changes in the same PR as much as possible, but I feel that a separate PR should also be fine. Let me know your thoughts :) |
Thanks @praveenrewar, The fixes don't need to be in this PR. As long as it be individual issues in the kctrl repo for the need-to-be-fixed ones so that the issues can be tracked to eventually get fixed, it should all be good. |
Manually run commands on a management cluster and update package README
Cluster Generation A/B Results: |
Hey @maralavi, I have created the following issues in kctrl for the things that you mentioned as needs to be fixed:
This is an intended behaviour if there was no values file used to install the package. Currently, when using the
Same as above. |
Thanks @praveenrewar for filing the issues. About update there is another case when the update goes half through when no package name is provided and then it fails and then the second time it complains that this package install is already associated with empty package name ''. This seems like idemptency is broken in update. As ideally we want to be able to repeat the operation as many times without ending up in a situation like this. Could I please ask for a ticket for this one as well and post the link here? Thank you:) About the I also had another comment about Changes LGTM, but still need to be reviewed & approved by Vijay before getting merged. |
@maralavi Thank you so much! |
Added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to get agreement from PM on changes to existing flags to see if this constitutes a major version bump and if that is acceptable. To be clear, I am not opposed to the changes here but we need agreement before getting this into a release.
-h, --help help for package | ||
--kube-api-burst int Set Kubernetes API client burst limit (default 1000) | ||
--kube-api-qps float32 Set Kubernetes API client QPS limit (default 1000) | ||
--kubeconfig string Path to the kubeconfig file ($TANZU_KUBECONFIG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are these env vars($TANZU_*) being defined? Is this a new tanzu CLI convention that I am probably not aware of?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @vuil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vijaykatam , Please let me know whom should i contact to take this thread forward?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pinged on a thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I too am wondering how the env vars are being used.
On a related note there is an ongoing effort to introduce the concept of tanzu context
(#2200)
to consolidate the cli endpoints access (including that via kubeconfigs). It may be worth consider aligning the UX with it.
cc @giri-varma
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These environment variables are defined in kctrl (the name is changed using the binary name provided through the adapter).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please log an issue to address as a followup.
(minor): Also the param --kubeconfig-yaml
is odd. Why not use just use --kubeconfig
like kubectl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please log an issue to address as a followup.
Sure. However I am not very clear on what should be covered as part of it. Do we need to remove this convention?
Also the param --kubeconfig-yaml is odd. Why not use just use --kubeconfig like kubectl
We do have --kubeconfig
to provide the path to the kubeconfig file. --kubeconfig-yaml
can be used to provide the content as yaml.
CATEGORY: [ingress] | ||
|
||
Created default values file at /home/contour-default-values.yaml | ||
>>> tanzu package available get contour.tanzu.vmware.com/1.18.2+vmware.1-tkg.1 --default-values-file-output contour-default-values.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vijaykatam , who will log the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am hoping your team can log an issue and work with doc team to review the changes that will land in https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/index.html.
Added package repository 'standard-repo' | ||
>>> tanzu package repository add standard-repo --url projects-stg.registry.vmware.com/tkg/test-packages/standard-repo:v1.0.0 -n test-ns | ||
Waiting for package repository to be added | ||
4:04:00PM: packagerepository/standard-repo (packaging.carvel.dev/v1alpha1) namespace: test-ns: Reconciling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This deviates from ISO 8601 format used by tanzu CLI https://github.com/vmware-tanzu/tanzu-framework/blob/main/docs/cli/style_guide.md#time-format
NAME VERSION RELEASED-AT NAMESPACE | ||
contour.tanzu.vmware.com 1.15.1+vmware.1-tkg.1 test-ns | ||
NAMESPACE NAME VERSION RELEASED-AT | ||
test-ns contour.tanzu.vmware.com 1.15.1+vmware.1-tkg.1 0001-01-01 00:00:00 +0000 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Released-at field is empty for most packages. We should not be displaying a datetime that doesn't make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this does make sense. Would it be okay to make this enhancement in a future PR after having some brainstorming on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I am fine but lets get an issue logged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an issue for this.
carvel-dev/kapp-controller#700
} | ||
return format | ||
} | ||
func nonExitingMain(p *plugin.Plugin) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an odd name. Can we call the function what it is doing? Something like kctrlInvoke?
// Copyright 2022 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package main |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this in main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty neutral on keeping this in main or a separate nested package.
I guess I had kept it in main to avoid more imports.
tableCount int | ||
} | ||
|
||
// PrintLinef overrides go-cli-ui/ui.PrintLinef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like something to upstream to go-cli-ui/ui.PrintLinef
. Override is an odd term because go has no override so I would rename the function to something like PrintLinefWithSkipPattern
and update doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Override is an odd term because go has no override
Yeah, this might be a bit confusing. I just used the term because we are trying to achieve something similar here.
I would rename the function to something like PrintLinefWithSkipPattern and update doc.
PrinLinef
is used in kctrl to print lines, but in case of tanzu cli we don't want PrintLinef
to print the header that mentions the cluster ip, hence I used the adapter to override the behaviour of PrintLinef
here.
adapterUI.outputFormat = outputFormat | ||
} | ||
|
||
// PrintTable overrides go-cli-ui/ui.PrintTable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment on override and func name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to PrintLinef
, PrintTable
is also used to print table in kctrl, but since the output needs to be a bit different in Tanzu CLI and there should also be options to select output format (like json
), this method was added to "override" the behaviour of PrintLinef
.
|
||
// PrintTable overrides go-cli-ui/ui.PrintTable | ||
// It accepts a table and renders it based on the output format | ||
//nolint:gocritic // Cannot change the function signature as it is defined in go-cli-ui |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove nolint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nolint
is used avoid the linting error caused due to the usage of values (and not pointers) for the argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets fix it then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to PrintLinef, PrintTable is also used to print table in kctrl, but since the output needs to be a bit different in Tanzu CLI and there should also be options to select output format (like json), this method was added to "override" the behaviour of PrintLinef.
The function signature exists in go-cli-ui and changing it over there would make it backward incompatible, requiring changes in all the tools that are currently using it.
c.PreRun = func(_ *cobra.Command, args []string) { adapterUI.SetOutputFormat(output) } | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this file could use a unit test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I didn't add a unit test since there were already integration tests running which verify this functionality, but I guess it wouldn't hurt to add a unit test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests for the adapter ui.
--column strings Filter to show only given columns | ||
--debug Include debug output | ||
-h, --help help for package | ||
--kube-api-burst int Set Kubernetes API client burst limit (default 1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaults are super high. What is the reasoning for using these as opposed to defaults set by tools like kubectl or controller-runtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These have been carried over over from kapp. In case of kctrl/tanzu cli I think that it shouldn't matter much (except for the new status
command that have been introduced in the latest release). We can definitely try to figure out an optimum number for these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blocking concerns from me. Lets get all issues logged and linked here. Needs a release note and approval from PM team prior to merging.
-h, --help help for package | ||
--kube-api-burst int Set Kubernetes API client burst limit (default 1000) | ||
--kube-api-qps float32 Set Kubernetes API client QPS limit (default 1000) | ||
--kubeconfig string Path to the kubeconfig file ($TANZU_KUBECONFIG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please log an issue to address as a followup.
(minor): Also the param --kubeconfig-yaml
is odd. Why not use just use --kubeconfig
like kubectl
Added package repository 'standard-repo' | ||
>>> tanzu package repository add standard-repo --url projects-stg.registry.vmware.com/tkg/test-packages/standard-repo:v1.0.0 -n test-ns | ||
Waiting for package repository to be added | ||
4:04:00PM: packagerepository/standard-repo (packaging.carvel.dev/v1alpha1) namespace: test-ns: Reconciling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to document that is a divergence from rest of plugins with the reasoning.
NAME VERSION RELEASED-AT NAMESPACE | ||
contour.tanzu.vmware.com 1.15.1+vmware.1-tkg.1 test-ns | ||
NAMESPACE NAME VERSION RELEASED-AT | ||
test-ns contour.tanzu.vmware.com 1.15.1+vmware.1-tkg.1 0001-01-01 00:00:00 +0000 UTC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I am fine but lets get an issue logged.
|
||
// PrintTable overrides go-cli-ui/ui.PrintTable | ||
// It accepts a table and renders it based on the output format | ||
//nolint:gocritic // Cannot change the function signature as it is defined in go-cli-ui |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets fix it then.
Cluster Generation A/B Results: |
Codecov Report
@@ Coverage Diff @@
## main #1864 +/- ##
=======================================
Coverage ? 42.66%
=======================================
Files ? 378
Lines ? 38415
Branches ? 0
=======================================
Hits ? 16391
Misses ? 20486
Partials ? 1538 Continue to review full report at Codecov.
|
@vijaykatam @maralavi Since we have not been able to move forward with a versioning strategy for the breaking changes, we are planning to make this behaviour opt in using |
Closing this PR with regards to #2522 |
What this PR does / why we need it
Which issue(s) this PR fixes
Fixes #1865
Describe testing done for PR
Release note
PR Checklist
Additional information
Special notes for your reviewer