Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix job log tail truncation#4889

Open
nvkevlu wants to merge 2 commits into
NVIDIA:mainfrom
nvkevlu:codex/fix-job-log-tail-truncation
Open

Fix job log tail truncation#4889
nvkevlu wants to merge 2 commits into
NVIDIA:mainfrom
nvkevlu:codex/fix-job-log-tail-truncation

Conversation

@nvkevlu

@nvkevlu nvkevlu commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Fixes job log truncation to preserve the newest content and final error lines.

Description

Updates CLI and server-side log bounding to discard content from the beginning rather than the end, ensuring --tail, --max-bytes, and the server’s 5 MiB cap retain final stack traces and errors. Adds regression coverage for live, stored, client, and oversized single-line logs.

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Quick tests passed locally by running ./runtest.sh.
  • In-line docstrings updated.
  • Documentation updated.

Copilot AI review requested due to automatic review settings July 10, 2026 20:11
@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR changes job log truncation to keep the newest log content.

  • Server log reads now seek to the end before applying the 5 MiB cap.
  • Server decoding now prefixes a tail-truncation marker and keeps final bytes.
  • CLI --max-bytes now keeps the last bytes after tail filtering.
  • Tests now cover live, stored, client, and oversized single-line log tails.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
nvflare/private/fed/server/job_cmds.py Server-side log bounding now reads and decodes the capped tail for live files and workspace zip logs.
nvflare/tool/job/job_cli.py CLI byte truncation now returns the last requested bytes and handles a zero-byte cap explicitly.
tests/unit_test/private/fed/server/job_cmds_test.py Server tests now assert that truncation preserves final log content.
tests/unit_test/tool/job/job_logs_test.py CLI tests now assert tail-first byte truncation and final error preservation.

Reviews (1): Last reviewed commit: "Merge branch 'main' into codex/fix-job-l..." | Re-trigger Greptile

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

This pull request updates job log truncation on both the CLI and server to retain the newest log content (tail) rather than discarding the end, improving the likelihood that final stack traces and error lines are preserved.

Changes:

  • CLI: change byte-based truncation to keep the last --max-bytes bytes (and add a tail+bytes regression test).
  • Server: read and return the tail of live and stored logs up to the server cap, and update truncation messaging accordingly.
  • Tests: add coverage for tail-preserving truncation across live logs, stored workspace logs, and oversized single-line logs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
nvflare/tool/job/job_cli.py Keep the last max_bytes bytes when bounding CLI job logs.
nvflare/private/fed/server/job_cmds.py Read/decode and cap log output from the end (tail) for live and stored logs.
tests/unit_test/tool/job/job_logs_test.py Add CLI regression coverage to ensure final error lines are preserved under tail+bytes bounds.
tests/unit_test/private/fed/server/job_cmds_test.py Add server-side regression tests for tail-preserving truncation (live, stored, client, oversized line).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 984 to +986
truncated = len(raw_data) > self.MAX_RETURNED_JOB_LOG_BYTES
if truncated:
raw_data = raw_data[: self.MAX_RETURNED_JOB_LOG_BYTES]
raw_data = raw_data[-self.MAX_RETURNED_JOB_LOG_BYTES :]
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.77%. Comparing base (d85cbaa) to head (162daca).

Files with missing lines Patch % Lines
nvflare/tool/job/job_cli.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4889      +/-   ##
==========================================
+ Coverage   60.76%   60.77%   +0.01%     
==========================================
  Files         977      977              
  Lines       93206    93203       -3     
==========================================
+ Hits        56633    56646      +13     
+ Misses      36573    36557      -16     
Flag Coverage Δ
unit-tests 60.77% <94.11%> (+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.

3 participants