Skip to content

Commit

Permalink
Fix for issue in [PLAT-16550] Improve node agent logging and support …
Browse files Browse the repository at this point in the history
…collection

Summary: Remove redundant check + correct the checks.

Test Plan: Trivial change + support bundle collection manually done.

Reviewers: cwang, amalyshev

Reviewed By: cwang

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D41452
  • Loading branch information
nkhogen committed Jan 24, 2025
1 parent 0f80d46 commit 6e93ac2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
4 changes: 4 additions & 0 deletions managed/node-agent/app/task/shell_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ func (s *ShellTask) Process(ctx context.Context) (*TaskStatus, error) {
if exitErr, ok := err.(*exec.ExitError); ok {
taskStatus.ExitStatus.Code = exitErr.ExitCode()
}
if util.FileLogger().IsDebugEnabled() && s.stdout.Len() > 0 {
util.FileLogger().
Debugf(ctx, "Output for failed command %s - %s", s.name, s.stdout.String())
}
errMsg := fmt.Sprintf("%s: %s", err.Error(), s.stderr.String())
util.FileLogger().Errorf(ctx, "Command %s execution failed - %s", s.name, errMsg)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,29 +113,22 @@ public Map<String, Long> getFilesListWithSizes(
throws Exception {
Map<String, Long> res = new HashMap<>();
if (node.cloudInfo == null || StringUtils.isBlank(node.cloudInfo.private_ip)) {
log.info("Skipping node-agent log download as node IP is not available");
log.info("Skipping node-agent support-bundle download as node IP is not available");
return res;
}
Optional<NodeAgent> optional = NodeAgent.maybeGetByIp(node.cloudInfo.private_ip);
if (!optional.isPresent()) {
log.info("Skipping node-agent log download as node-agent is not installed");
log.info("Skipping node-agent support-bundle download as node-agent is not installed");
return res;
}

Path nodeAgentHome = Paths.get(optional.get().getHome());
Path nodeAgentLogDirPath = nodeAgentHome.resolve("logs");
if (!nodeUniverseManager.checkNodeIfFileExists(
node, universe, nodeAgentLogDirPath.toString())) {
log.info("Skipping node-agent log download as {} does not exists", nodeAgentLogDirPath);
return res;
}
for (String dir : SOURCE_NODE_FILES) {
Path dirPath = nodeAgentHome.resolve(dir);
if (!nodeUniverseManager.checkNodeIfFileExists(
node, universe, nodeAgentLogDirPath.toString())) {
if (!nodeUniverseManager.checkNodeIfFileExists(node, universe, dirPath.toString())) {
log.info("Skipping non-existing node-agent path {}", dirPath);
continue;
}
log.info("Collecting files from node-agent path {}", dirPath);
res.putAll(
nodeUniverseManager.getNodeFilePathAndSizes(
node, universe, dirPath.toString(), /* maxDepth */ 1, /* fileType */ "f"));
Expand Down

0 comments on commit 6e93ac2

Please sign in to comment.