Skip to content

Commit

Permalink
Merge pull request #181 from kishen-v/Cleanup
Browse files Browse the repository at this point in the history
Initialize the CR logs command-pair during runtime
  • Loading branch information
Power Cloud Robot authored Nov 7, 2024
2 parents b757b80 + 37c26e2 commit f3ae7d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions kubetest2-tf/deployer/dumplogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ import (
)

var commandFilename = map[string]string{
fmt.Sprintf("%s.log", common.CommonProvider.Runtime): fmt.Sprintf("journalctl -xeu %s --no-pager", common.CommonProvider.Runtime),

"dmesg.log": "dmesg",
"kernel.log": "sudo journalctl --no-pager --output=short-precise -k",
"services.log": "sudo systemctl list-units -t service --no-pager --no-legend --all"}
"dmesg": "dmesg",
"kernel": "sudo journalctl --no-pager --output=short-precise -k",
"services": "sudo systemctl list-units -t service --no-pager --no-legend --all"}

func (d *deployer) DumpClusterLogs() error {
var errors []error
var stdErr, stdOut bytes.Buffer

// Set exclusively as maps are declared during compile-time and may be set with defaults.
commandFilename[common.CommonProvider.Runtime] = fmt.Sprintf("journalctl -xeu %s --no-pager", common.CommonProvider.Runtime)

klog.Infof("Collecting cluster logs under %s", d.logsDir)
// create a directory based on the generated path: _rundir/dump-cluster-logs
if _, err := os.Stat(d.logsDir); os.IsNotExist(err) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/providers/common/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (p *Provider) BindFlags(flags *pflag.FlagSet) {
&p.BuildVersion, "build-version", "", "Kubernetes Build Version",
)
flags.StringVar(
&p.Runtime, "runtime", "", "Runtime used while installing k8s cluster",
&p.Runtime, "runtime", "containerd", "Runtime used while installing k8s cluster",
)
flags.StringVar(
&p.StorageServer, "s3-server", "", "S3 server where Kubernetes Bits are stored",
Expand Down

0 comments on commit f3ae7d6

Please sign in to comment.