-
Notifications
You must be signed in to change notification settings - Fork 310
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
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…
59ba3a0
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
a1a57f9
Adding UNit test code.. (Still WORK IN PROGRESS)
e2360fd
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
f83ba36
Adding option to collect daoe Agent log and config file.
51b59e8
Added Avocado test for support collectlog command.
dc1c5f7
Updating code based on review comments.
b0b2b77
2> Updaing code based on Review comments.
8a39560
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
d24f1a9
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
6b4964b
3> Updating code based on review comments.
794040e
Update src/tests/ftest/control/dmg_support_collectlog.py
cdb94ec
Updated code based on review comments.
f18ea15
Adding partial Rsync option.
c46b120
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
bb2365d
FIx flask8 Error.
1e29b1a
Fix Rsync/Archive code in case of Rsync does not work and we need
e8dde8d
Adding Unit tests for suppor collect-log
94ec075
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
47a8b1d
Fix codespell
ebf03f0
Added unit test code.
d67f78e
Adding Functional tests.
19e8d58
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
3718e0f
Adding Functional tests.
a58a3b4
Added Functional and Unit test code.
16cba5e
Debugging the dmg folder permission issue in Ci.
a6ed89f
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
17c4a13
Fixed the dmg support collect-log which was having issue in Ci.
474b599
Code updated based on review comments.
837c93a
Test-tag: pr control
4048a28
Code updated based on review comments.
62d0207
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
25d4e9c
Test code updated based on review comments.
3e8afea
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
22afee5
code updated based on review comments.
ddb212e
Cleanup target log folder as Avocado cart_logtest.py is failing for t…
f4f0dc8
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
d09903b
Merge branch 'master' into samirrav/Support/DAOS-10625-Final
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
|
||
fmt.Printf(progress.Display()) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
kjacque marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 would you need to do this twice to the same folder?
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.
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.
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 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.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 will open defect.