bneradt commented on code in PR #14066:
URL: https://github.com/apache/trafficserver/pull/14066#discussion_r4593483464
##########
src/proxy/HostStatus.cc:
##########
@@ -281,14 +328,35 @@ HostStatus::setHostStatus(const std::string_view name,
TSHostStatus status, cons
host_stat->status = status;
Dbg(dbg_ctl_host_statuses, "reasons: %d, status: %s",
host_stat->reasons, HostStatusNames[host_stat->status]);
}
+ effective_status = host_stat->status;
+ remaining_reasons = host_stat->reasons;
+ }
+
+ // Requested reasons are logged apart from the host's full set because
down_time applies only to the
+ // requested ones, and an UP request clears only those, so the host recovers
only when none remain.
+ auto reason_name = Reason::getReasonName(reason);
+ auto remaining_name = Reason::getReasonName(remaining_reasons);
+
+ // Bits outside the tracked set match no branch above, so they change no
state.
+ if (const unsigned int untracked = reason & ~Reason::ALL; untracked != 0) {
+ Warning("Host %.*s status request carries untracked reason bits 0x%x; they
were ignored.", int(name.size()), name.data(),
+ untracked);
}
- // log it.
if (status == TSHostStatus::TS_HOST_STATUS_DOWN) {
- Note("Host %.*s has been marked down, down_time: %d - %s.",
int(name.size()), name.data(), down_time,
- down_time == 0 ? "indefinitely." : "seconds.");
+ char down_time_text[32];
+ if (down_time == 0) {
+ std::snprintf(down_time_text, sizeof(down_time_text), "indefinitely");
+ } else {
+ std::snprintf(down_time_text, sizeof(down_time_text), "%u seconds",
down_time);
+ }
+ Note("Host %.*s has been marked down, down_time: %s, reasons: %s, all
reasons: %s.", int(name.size()), name.data(),
+ down_time_text, reason_name.c_str(), remaining_name.c_str());
+ } else if (effective_status == TSHostStatus::TS_HOST_STATUS_UP) {
+ Note("Host %.*s has been marked up, cleared reasons: %s.",
int(name.size()), name.data(), reason_name.c_str());
} else {
- Note("Host %.*s has been marked up.", int(name.size()), name.data());
+ Note("Host %.*s is still down, cleared reasons: %s, remaining reasons:
%s.", int(name.size()), name.data(), reason_name.c_str(),
Review Comment:
The unit test covers `getReasonName()`, but nothing exercises the down /
still-down / marked-up branching here, which is the user-visible part of this
change. Could you add a urtest, modeled on
`tests/uranium_tests/cache/test_host_down_range_recursion.py` (it already
drives `Request.admin_host_set_status`)? It would mark a host down with
`active`, then `manual`, then up with `active`, and assert that diags.log has
`is still down, cleared reasons: active, remaining reasons: manual`. A final up
with `manual` should then give `has been marked up`. Covering the expiry path
in `getStatus()`, which calls `setHostStatus()` once per expired reason, would
also need a case that marks a reason down with a short `--time` and waits for
it to expire.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]