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

[d8] Add d8 collect-debug-info #81

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[d8] Add d8 collect-debug-info #81

wants to merge 2 commits into from

Conversation

d2285
Copy link
Member

@d2285 d2285 commented Jan 28, 2025

This pr add d8 platform collect-debug-info option to save output debug info to tar.gz archive.
e.g.

d8 p collect-debug-info --help
Collect debug info from Deckhouse Kubernetes Platform.

 © Flant JSC 2025

Usage:
  d8 platform collect-debug-info [flags]

Flags:
  -h, --help   help for collect-debug-info

Global Flags:
  -k, --kubeconfig string   KubeConfig of the cluster. (default is $KUBECONFIG when it is set, $HOME/.kube/config otherwise) (default "/root/.kube/config")

@d2285 d2285 requested a review from mvasl as a code owner January 28, 2025 16:20
@d2285 d2285 marked this pull request as draft January 28, 2025 16:20
@d2285 d2285 force-pushed the d8-collect-debug-info branch from 4200c8f to a29a9ac Compare January 28, 2025 16:28
@d2285 d2285 changed the title D8 collect debug info [d8] Add d8 collect-debug-info Jan 28, 2025
@d2285 d2285 self-assigned this Jan 28, 2025
@d2285 d2285 marked this pull request as ready for review January 28, 2025 16:46
@d2285 d2285 requested a review from name212 as a code owner January 30, 2025 15:30
@d2285 d2285 force-pushed the d8-collect-debug-info branch 2 times, most recently from ca010b1 to 581ed5d Compare January 30, 2025 15:36
@d2285 d2285 removed the request for review from name212 January 30, 2025 16:08
@d2285 d2285 force-pushed the d8-collect-debug-info branch 3 times, most recently from bfca89d to 07b5b93 Compare January 30, 2025 16:20
Copy link
Member

@mvasl mvasl left a comment

Choose a reason for hiding this comment

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

Some minor things

@raabdullaev raabdullaev requested a review from name212 February 19, 2025 08:47
@d2285 d2285 force-pushed the d8-collect-debug-info branch from 7be2faa to 7e546d9 Compare February 24, 2025 08:54
Comment on lines +166 to +168
if term.IsTerminal(int(os.Stdout.Fd())) {
return fmt.Errorf("Please provide output tar.gz to dump debug logs, ex. \"> dump-logs.tar.gz\"")
}
Copy link
Member

Choose a reason for hiding this comment

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

This can be done early, there is no point in reaching to the kube-apiserver if we know that we are not going to output to file and throw error anyway

Copy link
Member

@mvasl mvasl Feb 24, 2025

Choose a reason for hiding this comment

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

PreRunE seems like a good place to put such checks
https://pkg.go.dev/github.com/spf13/cobra#Command

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed, moved it to PreRunE

Copy link
Member

Choose a reason for hiding this comment

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

It seems that you forgot to remove it here

Comment on lines +42 to +46
var err error
if term.IsTerminal(int(os.Stdout.Fd())) {
return fmt.Errorf("Please provide output tar.gz to dump debug logs, ex. \"> dump-logs.tar.gz\"")
}
return err
Copy link
Member

@mvasl mvasl Feb 26, 2025

Choose a reason for hiding this comment

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

var err error is not required, return nil explicitly. Doing it in this way may cause nasty bugs that are hard to debug.

https://go.dev/doc/faq#nil_error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants