Skip to content

script: allow collecting management server and kvm agent logs - #13982

Draft
shwstppr wants to merge 1 commit into
apache:mainfrom
shwstppr:script-log-collect
Draft

script: allow collecting management server and kvm agent logs#13982
shwstppr wants to merge 1 commit into
apache:mainfrom
shwstppr:script-log-collect

Conversation

@shwstppr

Copy link
Copy Markdown
Contributor

Description

Adds a utility script to collect CloudStack logs for troubleshooting.

  • Collects management server and KVM agent logs.
  • Supports collecting logs for a specific date.
  • Discovers management servers and KVM hosts using CloudMonkey, with database fallback.
  • Supports limiting collection to specified KVM hosts.
  • Packages collected logs into a compressed archive.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Adds a utility script to collect CloudStack logs for troubleshooting.

* Collects management server and KVM agent logs.
* Supports collecting logs for a specific date.
* Discovers management servers and KVM hosts using CloudMonkey, with database fallback.
* Supports limiting collection to specified KVM hosts.
* Packages collected logs into a compressed archive.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Copilot AI lite review requested due to automatic review settings August 26, 2026 12:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new troubleshooting utility script to collect Apache CloudStack management server and KVM agent logs, optionally filtered to a specific date and/or a subset of KVM hosts, and packages the results into a tarball.

Changes:

  • Introduces cloudstack-collect-logs.sh to detect node type (management vs KVM) and collect the relevant logs.
  • Implements discovery of management servers and KVM hosts via CloudMonkey (with jq), with a MySQL/database fallback via db.properties.
  • Supports date-scoped extraction across rotated logs and produces a compressed archive with a small info.txt manifest.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +23 to +26
SSH_USER="${SSH_USER:-root}"
REQUESTED_HOSTS=()
SSH_OPTS="${SSH_OPTS:--o BatchMode=yes -o ConnectTimeout=10 -o StrictHostKeyChecking=no}"

Comment on lines +333 to +343
get_property() {
local property="$1"

awk -F= -v property="$property" '
$1 == property {
sub(/^[^=]*=/, "")
print
exit
}
' "$DB_PROPERTIES"
}
Comment on lines +367 to +374
MYSQL_PWD="$db_password" mysql \
--batch \
--skip-column-names \
-h "$db_host" \
-P "$db_port" \
-u "$db_user" \
"$db_name" \
-e "$query"
Comment on lines +448 to +451
collect_local_log \
"$AGENT_LOG_DIR" \
"$AGENT_LOG" \
"$WORKDIR/kvm/$host_name/$AGENT_LOG"
Comment on lines +538 to +540
log "Creating archive $ARCHIVE"
tar -czf "$ARCHIVE" "$WORKDIR"
rm -rf "$WORKDIR"
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 19.73%. Comparing base (158fe4f) to head (7e3f813).

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13982      +/-   ##
============================================
- Coverage     19.74%   19.73%   -0.01%     
+ Complexity    19960    19957       -3     
============================================
  Files          6371     6371              
  Lines        575784   575784              
  Branches      70478    70478              
============================================
- Hits         113665   113635      -30     
- Misses       449765   449797      +32     
+ Partials      12354    12352       -2     
Flag Coverage Δ
uitests 3.41% <ø> (ø)
unittests 21.01% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants