Skip to content
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

fix incorrect combination of lines in flux resource status for expandable fields that differ past the minimum width #6638

Merged
merged 6 commits into from
Feb 14, 2025

Conversation

grondo
Copy link
Contributor

@grondo grondo commented Feb 14, 2025

This PR fixes #6625. Expandable width fields (those with the +: or ?+: prefix sentinel) are passed to the Deduplicator class before the final maximum width is known, so comparison only occurs up to the minimum width. This was causing drain reasons that differ past the 30 character minimum width to be incorrectly combined.

The fix here strips the field widths from expandable fields in the Deduplicator so that the entire field is compared.

Copy link
Member

@garlick garlick left a comment

Choose a reason for hiding this comment

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

LGTM!

@grondo
Copy link
Contributor Author

grondo commented Feb 14, 2025

Thanks! I've set MWP.

Copy link
Contributor

mergify bot commented Feb 14, 2025

This pull request has been removed from the queue for the following reason: pull request manually updated.

The pull request #6638 has been manually updated

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.

If you want to requeue this pull request, you need to post a comment with the text: @mergifyio requeue

Problem: The OutputFormat copy() method takes an except_fields
list of fields to suppress in the copy, but this can leave prefix
sentinels like `+:` and `?:` and extra whitespace in the result.

Suppress extra text from skipped fields if it is all whitespace or
whitespace plus a supperted sentinel prefix.
Problem: The expansion sentinels `+:` and `?+:` allow an output
format field to expand to the maximum width in a given list of
formatted items. However, when a single item is formatted, any minimum
width, as specified in the format spec, will cause the result to be
truncated. This stymies attempts to find identical lines when the
lines are not filtered first.

Add options to the get_format_prepended() and copy() methods to
"nullify" the expansion sentinel by replacing the field without any
width and precision specifiers, i.e. `+:{foo:<3.3}` becomes simply
`{foo}`, which allows the fully rendered width of the field to appear
in any formatted result.
Problem: The Deduplicator class combines lines that would result in
the same result after applying a format string (with some fields
possibly excluded). This doesn't work when the expansion sentinel
`+:` is used, because the Deduplication comes before the expansion,
so the final maximum field width is not known, and instead the minimm
field width is used. This causes unlike lines that differ beyond the
minimum width to be combined.

Pass `nullify_expansion=True` when copying the input format so that the
width is dropped from these fields and deduplication uses the full
width for comparison.

Fixes flux-framework#6625
Problem: There are no unit tests for OutputFormat.copy().

Add some tests to python/t0024-util.py.
Problem: There is no test that ensures `flux resource status` does
not combine dissimilar drain reasons when the reason field has the
expandable `+:` prefix sentinel.

Add a test to t2354-resource-status.t for this purpose.
Problem: The "show truncation" format string suffix character (`+`)
is effectively ignored when the "expandable field" sentinel (`+:`) is
used because the field never will be truncaated. However, some format
strings in `flux-resource.py` use these together, potentially causing
confusion.

Remove the `+` suffix on fields using `+:` in the builtin flux-resource
format strings.
@mergify mergify bot merged commit 5c48b55 into flux-framework:master Feb 14, 2025
35 checks passed
Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.88%. Comparing base (820dd72) to head (5e8c975).
Report is 7 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6638      +/-   ##
==========================================
+ Coverage   83.87%   83.88%   +0.01%     
==========================================
  Files         533      533              
  Lines       88372    88377       +5     
==========================================
+ Hits        74122    74137      +15     
+ Misses      14250    14240      -10     
Files with missing lines Coverage Δ
src/bindings/python/flux/util.py 96.58% <100.00%> (+0.02%) ⬆️
src/cmd/flux-resource.py 95.11% <ø> (ø)

... and 6 files with indirect coverage changes

@grondo grondo deleted the issue#6625 branch February 14, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue: flux resource status is incorrectly merging drain messages with specific field formatting options
2 participants