Skip to content

flux-job: support attach --tail #6899

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

chu11
Copy link
Member

@chu11 chu11 commented Jun 30, 2025

Built on top of #6880, per discussion in #5035, this supports a new --tail option to flux job attach.

Note that this performs poorly, as we don't presently have a way to "jump forward" in the output eventlog. So all events in the log are forwared to flux job attach, but flux job attach, just saves them off until it knows when to begin outputting "tail" events using the new "initial sentinel" in #6880. The "jump forward" is for a future support.

@chu11 chu11 force-pushed the issue5035_job_attach_tail branch from 22b8359 to 5595fab Compare June 30, 2025 22:25
@chu11 chu11 force-pushed the issue5035_job_attach_tail branch 2 times, most recently from 53b167f to 4ce4fc3 Compare July 10, 2025 16:38
chu11 added 10 commits July 18, 2025 10:00
Problem: A simple assignment to a variable did not have proper
spacing.

Fix the simple whitspace problem.
Problem: In flux-core, function parameters are normally placed
on separate lines if they exceed 80 chars.  Some code in the
libjob did not follow this.

Update code in libjob for consistency.
Problem: When watching appends to a key, it would be convenient if
we knew when the "initial" or "current" data has been fully sent before
waiting / watching for future data.  It would take several RPCs to
accomplish this at the moment.

Support a new KVS_WATCH_APPEND_INITIAL_SENTINEL flag in kvs-watch.
An empty RPC will be sent after all "initial" or "current" data has
read from the KVS and sent to the caller.

Update flux_kvs_lookup_get() and flux_kvs_lookup_get_raw() to return
NULL (or 0) for OUT parameters when a sentinel has been received.
Problem: There are no tests that cover the new
FLUX_KVS_WATCH_APPEND_INITIAL_SENTINEL flag.

Solution: Add tests to t1007-kvs-lookup-watch.t and a helper
test file watch_initial_sentinel.c.
Problem: The new FLUX_KVS_WATCH_APPEND_INITIAL_SENTINEL flag
in libkvs is not documented.

Add documentation in flux_kvs_loopup(3)
Problem: The kvs-watch module recently supported a
FLUX_KVS_WATCH_APPEND_INITIAL_SENTINEL
flag.  The the job-info module does not take advantage of this flag
when watching an eventlog.

Support a new FLUX_JOB_EVENT_WATCH_INITIAL_SENTINEL flag.  Update
flux_job_event_watch_get() to return an empty event if the sentinel
has been reached.

Fixes flux-framework#6872
Problem: There are no tests to cover the new
FLUX_JOB_EVENT_WATCH_INITIAL_SENTINEL flag.

Solution: Add tests to t2231-job-info-eventlog-watch.t and a helper
test file eventlog_watch_initial_sentinel.c.
Problem: Some parameters to a fbuf_read_watcher_create() call
were not indented properly.

Fix invalid indentation.
Problem: If flux job attach is executed on a long running job, it outputs
all job output for that job.  If the job output is extremely long, this
extremely long output can be very annoying to the user.  In many cases,
a user only wants to see the newest output (i.e. current job status, error
message causing the job to fail, etc.).

Support a --tail option.  By default it outputs the last 10 lines of output,
but an optional argument can be specified for additional lines.

Fixes flux-framework#5035
Problem: There are no tests for the new "flux job attach" --tail
option.

Add coverage in t2500-job-attach.t.
@chu11 chu11 force-pushed the issue5035_job_attach_tail branch from 4ce4fc3 to acb3af4 Compare July 18, 2025 17:10
Copy link

codecov bot commented Jul 18, 2025

Codecov Report

Attention: Patch coverage is 86.85714% with 23 lines in your changes missing coverage. Please review.

Project coverage is 83.89%. Comparing base (df3c11c) to head (acb3af4).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/cmd/job/attach.c 77.77% 14 Missing ⚠️
src/modules/kvs-watch/kvs-watch.c 84.21% 3 Missing ⚠️
src/common/libjob/info.c 84.61% 2 Missing ⚠️
src/common/libkvs/kvs_lookup.c 93.93% 2 Missing ⚠️
src/modules/job-info/guest_watch.c 95.23% 1 Missing ⚠️
src/modules/job-info/watch.c 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6899      +/-   ##
==========================================
- Coverage   83.91%   83.89%   -0.02%     
==========================================
  Files         540      540              
  Lines       90610    90769     +159     
==========================================
+ Hits        76033    76152     +119     
- Misses      14577    14617      +40     
Files with missing lines Coverage Δ
src/modules/job-info/guest_watch.c 75.77% <95.23%> (+0.77%) ⬆️
src/modules/job-info/watch.c 69.43% <96.15%> (+2.05%) ⬆️
src/common/libjob/info.c 91.66% <84.61%> (-4.34%) ⬇️
src/common/libkvs/kvs_lookup.c 86.63% <93.93%> (+0.64%) ⬆️
src/modules/kvs-watch/kvs-watch.c 76.83% <84.21%> (+0.18%) ⬆️
src/cmd/job/attach.c 85.10% <77.77%> (-0.86%) ⬇️

... and 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant