Skip to content

Commit 97489e6

Browse files
authored
Cleanup strategy debug logs (#8656)
- fixes parent_select plugin to only have 1 debug tag - clarifies a misleading debug log about parent selection - changes parent_select plugin to not unnecessarily call nextHopExists
1 parent c04ccc8 commit 97489e6

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

plugins/experimental/parent_select/parent_select.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ handle_send_request(TSHttpTxn txnp, StrategyTxn *strategyTxn)
8787
strategy->next(txnp, strategyTxn->txn, ra.hostname, ra.hostname_len, ra.port, &ra.hostname, &ra.hostname_len, &ra.port,
8888
&ra.is_retry, &ra.no_cache);
8989

90-
ra.nextHopExists = strategy->nextHopExists(txnp);
90+
ra.nextHopExists = ra.hostname_len != 0;
9191
ra.fail = !ra.nextHopExists; // failed is whether to fail and return to the client. failed=false means to retry the parent we set
9292
// in the response_action
9393

@@ -256,7 +256,7 @@ handle_os_dns(TSHttpTxn txnp, StrategyTxn *strategyTxn)
256256

257257
ra.fail = ra.hostname == nullptr; // failed is whether to immediately fail and return the client a 502. In this case: whether or
258258
// not we found another parent.
259-
ra.nextHopExists = strategy->nextHopExists(txnp);
259+
ra.nextHopExists = ra.hostname_len != 0;
260260
ra.responseIsRetryable = strategy->responseIsRetryable(strategyTxn->request_count, STATUS_CONNECTION_FAILURE);
261261
ra.goDirect = strategy->goDirect();
262262
ra.parentIsProxy = strategy->parentIsProxy();

plugins/experimental/parent_select/strategy.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,10 @@ PLNextHopSelectionStrategy::nextHopExists(TSHttpTxn txnp)
287287
for (auto &hh : host_groups[gg]) {
288288
PLHostRecord *p = hh.get();
289289
if (p->available) {
290-
PL_NH_Debug(PL_NH_DEBUG_TAG, "[%" PRIu64 "] found available next hop %.*s", sm_id, int(p->hostname.size()),
291-
p->hostname.c_str());
290+
PL_NH_Debug(PL_NH_DEBUG_TAG,
291+
"[%" PRIu64 "] found available next hop %.*s (this is NOT necessarily the parent which will be selected, just "
292+
"the first available parent found)",
293+
sm_id, int(p->hostname.size()), p->hostname.c_str());
292294
return true;
293295
}
294296
}

plugins/experimental/parent_select/strategy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// TODO rename, move to respective sub-plugins
3737
#define PLUGIN_NAME "pparent_select"
3838

39-
constexpr const char *PL_NH_DEBUG_TAG = "plugin_nexthop";
39+
constexpr const char *PL_NH_DEBUG_TAG = PLUGIN_NAME;
4040

4141
// ring mode strings
4242
extern const std::string_view alternate_rings;

proxy/http/remap/NextHopSelectionStrategy.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,10 @@ NextHopSelectionStrategy::nextHopExists(TSHttpTxn txnp, void *ih)
278278
for (auto &hh : host_groups[gg]) {
279279
HostRecord *p = hh.get();
280280
if (p->available.load()) {
281-
NH_Debug(NH_DEBUG_TAG, "[%" PRIu64 "] found available next hop %s", sm_id, p->hostname.c_str());
281+
NH_Debug(NH_DEBUG_TAG,
282+
"[%" PRIu64 "] found available next hop %s (this is NOT necessarily the parent which will be selected, just the "
283+
"first available parent found)",
284+
sm_id, p->hostname.c_str());
282285
return true;
283286
}
284287
}

tests/gold_tests/pluginTest/parent_select/parent_select_peer.test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080

8181
ts.Disk.records_config.update({
8282
'proxy.config.diags.debug.enabled': 1,
83-
'proxy.config.diags.debug.tags': 'http|dns|parent|next_hop|host_statuses|hostdb|cachekey|plugin_nexthop',
83+
'proxy.config.diags.debug.tags': 'http|dns|parent|next_hop|host_statuses|hostdb|cachekey|pparent_select',
8484
'proxy.config.dns.nameservers': f"127.0.0.1:{dns.Variables.Port}", # Only nameservers if resolv_conf NULL.
8585
'proxy.config.dns.resolv_conf': "NULL", # This defaults to /etc/resvolv.conf (OS namesevers) if not NULL.
8686
'proxy.config.http.cache.http': 1,
@@ -171,7 +171,7 @@
171171
tr = Test.AddTestRun()
172172
tr.Processes.Default.Command = (
173173
"grep -e '^+++' -e '^[A-Z].*TTP/' -e '^.alts. --' -e 'PARENT_SPECIFIED' trace_peer*.log"
174-
" | sed 's/^.*(plugin_nexthop) [^ ]* //' | sed 's/[.][0-9]*$$//'"
174+
" | sed 's/^.*(pparent_select) [^ ]* //' | sed 's/[.][0-9]*$$//'"
175175
)
176176
tr.Processes.Default.Streams.stdout = "peer.trace.gold"
177177
tr.Processes.Default.ReturnCode = 0

tests/gold_tests/pluginTest/parent_select/parent_select_peer2.test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080

8181
ts.Disk.records_config.update({
8282
'proxy.config.diags.debug.enabled': 1,
83-
'proxy.config.diags.debug.tags': 'http|dns|parent|next_hop|host_statuses|hostdb|plugin_nexthop',
83+
'proxy.config.diags.debug.tags': 'http|dns|parent|next_hop|host_statuses|hostdb|pparent_select',
8484
'proxy.config.dns.nameservers': f"127.0.0.1:{dns.Variables.Port}", # Only nameservers if resolv_conf NULL.
8585
'proxy.config.dns.resolv_conf': "NULL", # This defaults to /etc/resvolv.conf (OS namesevers) if not NULL.
8686
'proxy.config.http.cache.http': 1,
@@ -166,7 +166,7 @@
166166
tr = Test.AddTestRun()
167167
tr.Processes.Default.Command = (
168168
"grep -e '^+++' -e '^[A-Z].*TTP/' -e '^.alts. --' -e 'PARENT_SPECIFIED' trace_peer*.log"
169-
" | sed 's/^.*(plugin_nexthop) [^ ]* //' | sed 's/[.][0-9]*$$//' " + normalize_ports
169+
" | sed 's/^.*(pparent_select) [^ ]* //' | sed 's/[.][0-9]*$$//' " + normalize_ports
170170
)
171171
tr.Processes.Default.Streams.stdout = "peer2.trace.gold"
172172
tr.Processes.Default.ReturnCode = 0

0 commit comments

Comments
 (0)