Skip to content

Improve export logs user experience - #7549

Open
hgreebe wants to merge 8 commits into
aws:developfrom
hgreebe:develop
Open

Improve export logs user experience#7549
hgreebe wants to merge 8 commits into
aws:developfrom
hgreebe:develop

Conversation

@hgreebe

@hgreebe hgreebe commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description of changes

  • Add the following improvements to export-logs:
    • Progress reporting: During the export, add await poll that emits a line to stderr every 15s.
    • Parallel download: There is no native boto3 "download folder" boto3 API. Therefore, we have to use a Python thread pool over download_file boto3 API. Objects are grouped to be handled sequentially in different workers.
    • Track an existing running CloudWatch log export task: If the running task matches the same log group, track it to completion, instead of failing. A different log group's task yields a clear "please wait" failure message.
    • Support export logs from deleted clusters: To export logs from a deleted cluster, ARN of the CloudFormation needs to be provided.
  • Added unit tests to cover improvements

Tests

  • Ran export logs in multiple scenarios (output added below)
  • Added unit tests

Output when running export logs:

pcluster export-cluster-logs --cluster-name {name}
Exporting 10326 log stream(s) from log group /aws/parallelcluster/{name}...
Started CloudWatch Logs export task XXXX-XXXX. Waiting for it to complete... (CloudWatch buffers logs and usually writes them to S3 near the end of the task, so the exported size may stay at 0 for several minutes.)
Exporting logs from CloudWatch: no data written to S3 yet (elapsed 15s)
...
Exporting logs from CloudWatch: 85.3 MB exported so far (elapsed 124s)
Export task XXXX-XXXX finished after 138s.
Downloading 9387 log object(s) (106.5 MB) from S3...
...
Downloaded 8819/9387 log object(s)... (elapsed 346s)
Downloaded 9387 of 9387 log object(s) (106.5 MB). (elapsed 357s)
CloudWatch logs export complete.
{
  "url": "{url}"
}

Output when another export on different cluster is running:

pcluster export-cluster-logs --cluster-name {name}
Exporting 10 log stream(s) from log group /aws/parallelcluster/{name}
ERROR: Unable to export cluster's logs.
Unexpected error when exporting cluster's logs: Another CloudWatch Logs export task is already running for this account (task XXXX-XXXX, log group '/aws/parallelcluster/{other_cluster}', started at 2026-08-12 15:38:20.354000+00:00). CloudWatch Logs allows only one export task at a time; please wait for it to complete before retrying.

Output when another export is running on the same cluster:

pcluster export-cluster-logs --cluster-name {name}
Exporting 10326 log stream(s) from log group /aws/parallelcluster/{name}...
An export task for log group '/aws/parallelcluster/{name}' is already running (task XXXX-XXXX, started at 2026-08-12 15:38:20.354000+00:00). Tracking it instead of starting a new one.
Started CloudWatch Logs export task XXXX-XXXX. Waiting for it to complete... (CloudWatch buffers logs and usually writes them to S3 near the end of the task, so the exported size may stay at 0 for several minutes.)
...

References

Checklist

  • Make sure you are pointing to the right branch.
  • If you're creating a patch for a branch other than develop add the branch name as prefix in the PR title (e.g. [release-3.6]).
  • Check all commits' messages are clear, describing what and why vs how.
  • Make sure to have added unit tests or integration tests to cover the new/modified code.
  • Check if documentation is impacted by this change.

Please review the guidelines for contributing and Pull Request Instructions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@hgreebe
hgreebe marked this pull request as ready for review August 12, 2026 17:05
@hgreebe
hgreebe requested review from a team as code owners August 12, 2026 17:05
hanwen-cluster
hanwen-cluster previously approved these changes Aug 12, 2026
Comment thread cli/src/pcluster/models/common.py Outdated
Comment on lines 473 to 475
AWSApi.instance().s3_resource.download_file(
bucket_name=self.bucket, key=archive_object.key, output=compressed_path
)

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.

We need to use AWSApi.instance().s3.download_file instead of s3_resource because only boto client is thread safe: https://docs.aws.amazon.com/boto3/latest/guide/clients.html:

Multithreading or multiprocessing with clients
Unlike Resources and Sessions, clients are generally thread-safe. There are some caveats, defined below, to be aware of though.

@hanwen-cluster
hanwen-cluster dismissed their stale review August 12, 2026 19:22

Mistakenly approved

Comment thread cli/src/pcluster/models/common.py
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