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

DAOS-10625 control: Create the tool to collect the logs/config for support purpose #11094

Merged
merged 38 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8353d18
DAOS-10625 control: Create the tool to collect the logs/config for su…
Dec 20, 2022
59ba3a0
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
Dec 21, 2022
a1a57f9
Adding UNit test code.. (Still WORK IN PROGRESS)
Jan 10, 2023
e2360fd
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
Jan 10, 2023
f83ba36
Adding option to collect daoe Agent log and config file.
Jan 11, 2023
51b59e8
Added Avocado test for support collectlog command.
Jan 12, 2023
dc1c5f7
Updating code based on review comments.
Jan 13, 2023
b0b2b77
2> Updaing code based on Review comments.
Jan 14, 2023
8a39560
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
Jan 18, 2023
d24f1a9
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
Jan 19, 2023
6b4964b
3> Updating code based on review comments.
Jan 19, 2023
794040e
Update src/tests/ftest/control/dmg_support_collectlog.py
Jan 20, 2023
cdb94ec
Updated code based on review comments.
Jan 24, 2023
f18ea15
Adding partial Rsync option.
Jan 25, 2023
c46b120
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
Feb 17, 2023
bb2365d
FIx flask8 Error.
Feb 17, 2023
1e29b1a
Fix Rsync/Archive code in case of Rsync does not work and we need
Feb 23, 2023
e8dde8d
Adding Unit tests for suppor collect-log
Mar 8, 2023
94ec075
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
Mar 13, 2023
47a8b1d
Fix codespell
Mar 13, 2023
ebf03f0
Added unit test code.
Mar 15, 2023
d67f78e
Adding Functional tests.
Mar 28, 2023
19e8d58
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
Apr 4, 2023
3718e0f
Adding Functional tests.
Apr 4, 2023
a58a3b4
Added Functional and Unit test code.
Apr 4, 2023
16cba5e
Debugging the dmg folder permission issue in Ci.
Apr 6, 2023
a6ed89f
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
Apr 6, 2023
17c4a13
Fixed the dmg support collect-log which was having issue in Ci.
Apr 6, 2023
474b599
Code updated based on review comments.
Apr 10, 2023
837c93a
Test-tag: pr control
Apr 10, 2023
4048a28
Code updated based on review comments.
May 2, 2023
62d0207
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
May 2, 2023
25d4e9c
Test code updated based on review comments.
May 3, 2023
3e8afea
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
May 5, 2023
22afee5
code updated based on review comments.
May 16, 2023
ddb212e
Cleanup target log folder as Avocado cart_logtest.py is failing for t…
May 17, 2023
f4f0dc8
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
May 30, 2023
d09903b
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
Jun 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/control/cmd/daos_agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type cliOptions struct {
DumpInfo dumpAttachInfoCmd `command:"dump-attachinfo" description:"Dump system attachinfo"`
DumpTopo hwprov.DumpTopologyCmd `command:"dump-topology" description:"Dump system topology"`
NetScan netScanCmd `command:"net-scan" description:"Perform local network fabric scan"`
Support supportCmd `command:"support" description:"Perform debug tasks to help support team"`
}

type (
Expand Down Expand Up @@ -114,6 +115,25 @@ func exitWithError(log logging.Logger, err error) {
os.Exit(1)
}

type (
supportAgentConfig interface {
setSupportConf(string)
getSupportConf() string
}

supportAgentConfigCmd struct {
supportCfgPath string
}
)

func (cmd *supportAgentConfigCmd) setSupportConf(cfgPath string) {
cmd.supportCfgPath = cfgPath
}

func (cmd *supportAgentConfigCmd) getSupportConf() string {
return cmd.supportCfgPath
}

func parseOpts(args []string, opts *cliOptions, invoker control.Invoker, log *logging.LeveledLogger) error {
p := flags.NewParser(opts, flags.Default)
p.Options ^= flags.PrintErrors // Don't allow the library to print errors
Expand Down Expand Up @@ -176,6 +196,10 @@ func parseOpts(args []string, opts *cliOptions, invoker control.Invoker, log *lo
log.Debugf("agent config loaded from %s", cfgPath)
}

if suppCmd, ok := cmd.(supportAgentConfig); ok {
suppCmd.setSupportConf(cfgPath)
}

if opts.RuntimeDir != "" {
log.Debugf("Overriding socket path from config file with %s", opts.RuntimeDir)
cfg.RuntimeDir = opts.RuntimeDir
Expand Down
99 changes: 99 additions & 0 deletions src/control/cmd/daos_agent/support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
//
// (C) Copyright 2022-2023 Intel Corporation.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//

package main

import (
"fmt"
"os"
"path/filepath"

"github.com/daos-stack/daos/src/control/common/cmdutil"
"github.com/daos-stack/daos/src/control/lib/support"
)

// supportCmd is the struct representing the top-level support subcommand.
type supportCmd struct {
CollectLog collectLogCmd `command:"collect-log" description:"Collect logs from client"`
agentConfigPath string
}

// collectLogCmd is the struct representing the command to collect the log from client side.
type collectLogCmd struct {
supportAgentConfigCmd
cmdutil.LogCmd
support.CollectLogSubCmd
}

func (cmd *collectLogCmd) Execute(_ []string) error {
var LogCollection = map[int32][]string{
support.CopyAgentConfigEnum: {""},
support.CollectAgentLogEnum: {""},
support.CollectAgentCmdEnum: support.AgentCmd,
support.CollectClientLogEnum: {""},
support.CollectSystemCmdEnum: support.SystemCmd,
}

// Default 3 steps of log/conf collection.
progress := support.ProgressBar{
Total: len(LogCollection),
NoDisplay: false,
}

if cmd.Archive {
progress.Total++
}

// Copy the custom log folder
if cmd.ExtraLogsDir != "" {
LogCollection[support.CollectExtraLogsDirEnum] = []string{""}
progress.Total++
}

if cmd.TargetFolder == "" {
cmd.TargetFolder = filepath.Join(os.TempDir(), "daos_support_client_logs")
}
cmd.Infof("Support Logs will be copied to %s", cmd.TargetFolder)

progress.Steps = 100 / progress.Total
params := support.CollectLogsParams{}
params.TargetFolder = cmd.TargetFolder
params.ExtraLogsDir = cmd.ExtraLogsDir
params.Config = cmd.getSupportConf()
for logFunc, logCmdSet := range LogCollection {
for _, logCmd := range logCmdSet {
cmd.Debugf("Log Function Enum = %d -- Log Collect Cmd = %s ", logFunc, logCmd)
params.LogFunction = logFunc
params.LogCmd = logCmd

err := support.CollectSupportLog(cmd.Logger, params)
if err != nil {
fmt.Println(err)
if cmd.Stop {
return err
}
}
}
fmt.Printf(progress.Display())
}

if cmd.Archive {
cmd.Debugf("Archiving the Log Folder %s", cmd.TargetFolder)
err := support.ArchiveLogs(cmd.Logger, params)
if err != nil {
return err
}

// FIXME: DAOS-13290 Workaround for files held open
for i := 1; i < 3; i++ {
os.RemoveAll(cmd.TargetFolder)
}
Comment on lines +91 to +93
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would you need to do this twice to the same folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some time single delete fail as go code is still holding those files. I tried to debug but did not find any other way to check which holds it. So for now I just put this workaround which needs to be removed after finding the root cause.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is good practice to create a ticket for technical debt so that it's not forgotten. Then you can add a comment, e.g. // FIXME: DAOS-xxxx Workaround for files held open. It is concerning that there is a workaround for behavior that is not understood, but this isn't critical code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure will open defect.

}

fmt.Printf(progress.Display())

return nil
}
1 change: 1 addition & 0 deletions src/control/cmd/daos_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type mainOpts struct {
Version versionCmd `command:"version" description:"Print daos_server version"`
MgmtSvc msCmdRoot `command:"ms" description:"Perform tasks related to management service replicas"`
DumpTopo hwprov.DumpTopologyCmd `command:"dump-topology" description:"Dump system topology"`
Support supportCmd `command:"support" description:"Perform debug tasks to help support team"`
Config configCmd `command:"config" alias:"cfg" description:"Perform tasks related to configuration of hardware on the local server"`

// Allow a set of tests to be run before executing commands.
Expand Down
97 changes: 97 additions & 0 deletions src/control/cmd/daos_server/support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//
// (C) Copyright 2022-2023 Intel Corporation.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//

package main

import (
"fmt"
"os"
"path/filepath"

"github.com/daos-stack/daos/src/control/common/cmdutil"
"github.com/daos-stack/daos/src/control/lib/support"
)

// supportCmd is the struct representing the top-level support subcommand.
type supportCmd struct {
CollectLog collectLogCmd `command:"collect-log" description:"Collect logs from server"`
}

// collectLogCmd is the struct representing the command to collect the Logs/config for support purpose
type collectLogCmd struct {
cfgCmd
cmdutil.LogCmd
support.CollectLogSubCmd
}

func (cmd *collectLogCmd) Execute(_ []string) error {
var LogCollection = map[int32][]string{
support.CopyServerConfigEnum: {""},
support.CollectSystemCmdEnum: support.SystemCmd,
support.CollectServerLogEnum: support.ServerLog,
support.CollectDaosServerCmdEnum: support.DaosServerCmd,
}

// Default 4 steps of log/conf collection.
progress := support.ProgressBar{
Total: len(LogCollection),
NoDisplay: false,
}

if cmd.Archive {
progress.Total++
}

// Copy custom log folder
if cmd.ExtraLogsDir != "" {
LogCollection[support.CollectExtraLogsDirEnum] = []string{""}
progress.Total++
}

if cmd.TargetFolder == "" {
cmd.TargetFolder = filepath.Join(os.TempDir(), "daos_support_server_logs")
}
cmd.Infof("Support logs will be copied to %s", cmd.TargetFolder)

progress.Steps = 100 / progress.Total
params := support.CollectLogsParams{}
params.Config = cmd.configPath()
params.TargetFolder = cmd.TargetFolder
params.ExtraLogsDir = cmd.ExtraLogsDir
for logFunc, logCmdSet := range LogCollection {
for _, logCmd := range logCmdSet {
cmd.Debugf("Log Function Enum = %d -- Log Collect Cmd = %s ", logFunc, logCmd)
params.LogFunction = logFunc
params.LogCmd = logCmd

err := support.CollectSupportLog(cmd.Logger, params)
if err != nil {
fmt.Println(err)
if cmd.Stop {
return err
}
}
}
fmt.Printf(progress.Display())
}

if cmd.Archive {
cmd.Debugf("Archiving the Log Folder %s", cmd.TargetFolder)
err := support.ArchiveLogs(cmd.Logger, params)
if err != nil {
return err
}

// FIXME: DAOS-13290 Workaround for files held open
for i := 1; i < 3; i++ {
os.RemoveAll(cmd.TargetFolder)
}
}

fmt.Printf(progress.Display())

return nil
}
2 changes: 1 addition & 1 deletion src/control/cmd/dmg/command_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// (C) Copyright 2019-2022 Intel Corporation.
// (C) Copyright 2019-2023 Intel Corporation.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
Expand Down
2 changes: 1 addition & 1 deletion src/control/cmd/dmg/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestDmg_JsonOutput(t *testing.T) {
testArgs := append([]string{"-i", "--json"}, args...)
switch strings.Join(args, " ") {
case "version", "telemetry config", "telemetry run", "config generate",
"manpage", "system set-prop":
"manpage", "system set-prop", "support collect-log":
return
case "storage nvme-rebind":
testArgs = append(testArgs, "-l", "foo.com", "-a",
Expand Down
1 change: 1 addition & 0 deletions src/control/cmd/dmg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ type cliOptions struct {
Config configCmd `command:"config" alias:"cfg" description:"Perform tasks related to configuration of hardware on remote servers"`
System SystemCmd `command:"system" alias:"sys" description:"Perform distributed tasks related to DAOS system"`
Network NetCmd `command:"network" alias:"net" description:"Perform tasks related to network devices attached to remote servers"`
Support supportCmd `command:"support" alias:"supp" description:"Perform debug tasks to help support team"`
Pool PoolCmd `command:"pool" description:"Perform tasks related to DAOS pools"`
Cont ContCmd `command:"container" alias:"cont" description:"Perform tasks related to DAOS containers"`
Version versionCmd `command:"version" description:"Print dmg version"`
Expand Down
Loading