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

Improve YAML compliance of mgr:jobs report #1794

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

Conversation

kinkie
Copy link
Contributor

@kinkie kinkie commented Apr 25, 2024

Improve the report's schema and formatting

@kinkie
Copy link
Contributor Author

kinkie commented Apr 25, 2024

Current master output:

    job5:
        type: 'Http1::Server'
        status: [ job5]
    job6:
        type: 'ClientHttpRequest'
        status: [ job6]
        started: false
    job4:
        type: 'Comm::TcpAcceptor'
        status: FD 15, [::] [ job4]

notice the unnecessary indent, and confusing array for most "status" fields

Proposed output:

job6:
  type: ClientHttpRequest
  started: No
job5:
  type: Http1::Server
  started: Yes
job4:
  type: Comm::TcpAcceptor
  status:  FD 15, [::]
  started: Yes

Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

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

This PR requires a lot more work.

src/base/AsyncJob.cc Outdated Show resolved Hide resolved
src/base/AsyncJob.cc Show resolved Hide resolved
src/BodyPipe.cc Outdated Show resolved Hide resolved
src/HappyConnOpener.cc Show resolved Hide resolved
if (job->stopReason)
os << indent << indent << "stopped: '" << job->stopReason << "'\n";
os << job->id << ":\n";
os << indent << "type: " << job->typeName << '\n';
Copy link
Contributor

Choose a reason for hiding this comment

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

You may want to review discussions that led to this recently added code. Did we make a mistake when deciding that typeName should be quoted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In yaml, quoting is optional unless there's a risk of
misinterpreting the element's type. I removed the quotes
as I don't think there is such a risk, but I can just add it back

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added back

{
static MemBuf buf;
buf.reset();

buf.append(" [", 2);
Copy link
Contributor

Choose a reason for hiding this comment

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

A PR changing many (all?) AsyncJob::status() implementations should fix that API to allow for compounded base+kid+gradkid status reports. We probably want to split that API into two because the current status() is used in many debugs() messages where output requirements are rather different (this PR probably breaks some of those use cases).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is possible that it breaks some use cases by missing out on spacing, I've fixed what I could find.
I'm not convinced that it's necessary to have two different functions to report status, in the end the only difference is formatting, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

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

the only difference is formatting, isn't it?

No, it is not, not for any reasonable definition of "formatting" in this context.

debugs() status():

  • target audience: developers (that can easily decipher cryptic output by reading Squid code)
  • should be very compact -- often added to many (already long) debugs() lines
  • should be fairly fast -- used often when debugging at level 3+

job state reported inside a mgr:jobs report:

  • target audience: admins (humans that do not read Squid code) and their tools
  • output size is not a concern; new lines and such are very useful for readability
  • output speed is not a significant concern

@kinkie
Copy link
Contributor Author

kinkie commented Apr 30, 2024

I think all outstanding requests for change are addressed

@kinkie kinkie requested review from rousskov and yadij April 30, 2024 15:22
@kinkie kinkie added the S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box label Apr 30, 2024
@rousskov rousskov removed their request for review April 30, 2024 20:09
@kinkie kinkie added the M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels label May 3, 2024
Copy link
Contributor

@yadij yadij left a comment

Choose a reason for hiding this comment

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

just some polish now.

@@ -133,12 +133,12 @@ BodyPipe::BodyPipe(Producer *aProducer): theBodySize(-1),
// TODO: teach MemBuf to start with zero minSize
// TODO: limit maxSize by theBodySize, when known?
theBuf.init(2*1024, MaxCapacity);
debugs(91,7, "created BodyPipe" << status());
debugs(91,7, "created BodyPipe " << status());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please take advantage of the touch to make this produce the log pattern detected by the scripts/find-alive.pl:

Suggested change
debugs(91,7, "created BodyPipe " << status());
debugs(91,7, "construct, this=" << static_cast<void*>(this) << ", " << status());

}

BodyPipe::~BodyPipe()
{
debugs(91,7, "destroying BodyPipe" << status());
debugs(91,7, "destroying BodyPipe " << status());
Copy link
Contributor

Choose a reason for hiding this comment

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

Please take advantage of the touch to make this produce the log pattern detected by the scripts/find-alive.pl:

Suggested change
debugs(91,7, "destroying BodyPipe " << status());
debugs(91,7, "destruct, this=" << static_cast<void*>(this) << ", " << status());

@@ -708,7 +708,7 @@ void Adaptation::Icap::ModXact::bypassFailure()
reuseConnection = false; // be conservative
cancelRead(); // may not work; and we cannot stop connecting either
if (!doneWithIo())
debugs(93, 7, "Warning: bypass failed to stop I/O" << status());
debugs(93, 7, "Warning: bypass failed to stop I/O " << status());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
debugs(93, 7, "Warning: bypass failed to stop I/O " << status());
debugs(93, 7, "WARNING: bypass failed to stop I/O " << status());

@@ -1292,7 +1292,7 @@ Adaptation::Icap::ModXact::~ModXact()
// internal cleanup
void Adaptation::Icap::ModXact::swanSong()
{
debugs(93, 5, "swan sings" << status());
debugs(93, 5, "swan sings " << status());
Copy link
Contributor

Choose a reason for hiding this comment

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

method name "swanSong" makes the content text redundant.

Suggested change
debugs(93, 5, "swan sings " << status());
debugs(93, 5, status());

if (job->stopReason)
os << indent << indent << "stopped: '" << job->stopReason << "'\n";
os << indent << "stopped: \'" << job->stopReason << "'\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

single quote should not need to be escaped within double-quoted string:

Suggested change
os << indent << "stopped: \'" << job->stopReason << "'\n";
os << indent << "stopped: '" << job->stopReason << "'\n";

@yadij yadij added S-waiting-for-author author action is expected (and usually required) and removed S-waiting-for-reviewer ready for review: Set this when requesting a (re)review using GitHub PR Reviewers box labels Jun 5, 2024
@yadij yadij requested a review from rousskov June 5, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-ignored-by-merge-bots https://github.com/measurement-factory/anubis/blob/master/README.md#pull-request-labels S-waiting-for-author author action is expected (and usually required)
Projects
None yet
3 participants