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

bugfix: do not output logs in vcluster connect if --print is set #2014

Merged

Conversation

hidalgopl
Copy link
Contributor

@hidalgopl hidalgopl commented Aug 2, 2024

What issue type does this pull request address? (keep at least one, remove the others)
/kind bugfix

What does this pull request do? Which issues does it resolve? (use resolves #<issue_number> if possible)
resolves ENG-4270

Fix replaces the Log if --print flag is set. This new Log instance will log all non-error logs to io.Discard. Also, added two e2e tests:

  1. First executes vcluster connect -n vcluster --print vcluster and writes it to temporary file, and then uses kubectl --kubeconfig=<temporary-file> get pods -A to check if outputed kubeconfig can be used to connect to virtual cluster.
  2. Second tests checks if the vcluster connect -n vcluster --print NOT_EXISTING_CLUSTER_NAME still outputs error.

Please provide a short message that should be published in the vcluster release notes
Fixed an issue where vcluster connect --print outputs invalid kubeconfig (it included log)

What else do we need to know?
I initially tried to construct cobra.Command inside the e2e test (as it is done here, but I couldn't direct the output of the cmd.Execute() to the temporary kubeconfig file (even using cmd.SetOut(kubeCfgFile)). I believe reason for that is that we write to os.Stdout directly here: https://github.com/hidalgopl/vcluster/blob/fix-vcluster-connect-with-print/pkg/cli/connect_helm.go#L154 (so we don't take into account the outWriter from cobra.Command.

@hidalgopl hidalgopl marked this pull request as draft August 2, 2024 12:58
Copy link

netlify bot commented Aug 2, 2024

Deploy Preview for vcluster-docs canceled.

Built without sensitive environment variables

Name Link
🔨 Latest commit b56341c
🔍 Latest deploy log https://app.netlify.com/sites/vcluster-docs/deploys/66acee8d3370dc00083c5f35

@hidalgopl hidalgopl force-pushed the fix-vcluster-connect-with-print branch from a4717f1 to b56341c Compare August 2, 2024 14:34
@hidalgopl hidalgopl marked this pull request as ready for review August 2, 2024 14:54
Copy link
Member

@FabianKramm FabianKramm left a comment

Choose a reason for hiding this comment

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

@hidalgopl thanks for the PR! Great work, LGTM!

@FabianKramm FabianKramm merged commit 04edf4b into loft-sh:main Aug 2, 2024
60 checks passed
@FabianKramm FabianKramm added the backport-to-v0.20 backport this PR to v0.20 branch label Aug 2, 2024
@loft-bot
Copy link

loft-bot commented Aug 2, 2024

💚 All backports created successfully

Status Branch Result
v0.20

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

FabianKramm added a commit that referenced this pull request Aug 3, 2024
[v0.20] Merge pull request #2014 from hidalgopl/fix-vcluster-connect-with-print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-v0.20 backport this PR to v0.20 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants