Skip to content

Conversation

@jrushford
Copy link
Contributor

@jrushford jrushford commented Feb 21, 2022

Modifications to the traffic_ctl host status command and HostStatus

  • modifies traffic_ctl to use JSON-RPC to query host statuses directly from the HostStatus singleton
  • removes the persistent stats creation in HostStatus
  • adds in a new persistent mechanism for HostStatus

Host status will no-longer create persistent stats so now when a host is marked up or down using traffic_ctl, the entire set of HostStatus records will be dumped from memory to var/trafficserver/host_records.yaml so that when ATS restarts, the records are re-loaded. stats_over_http will no-longer show "proxy.process.host_status" stats and are no-longer seen with traffic_ctl metric match.

traffic_ctl host status without any other arguments will list all host status records replacing the metric match usage to list all host records.

@jrushford jrushford added In Progress JSONRPC JSONRPC 2.0 related work. labels Feb 21, 2022
@jrushford jrushford requested a review from brbzull0 February 21, 2022 18:34
@jrushford jrushford requested a review from zwoop as a code owner February 21, 2022 18:34
@jrushford jrushford force-pushed the hoststatus_remove_stats branch from 50bf469 to a2d99b8 Compare February 21, 2022 19:10
@bneradt
Copy link
Contributor

bneradt commented Feb 21, 2022

[approve ci rocky]

@masaori335 masaori335 marked this pull request as draft February 21, 2022 22:34
@brbzull0
Copy link
Contributor

#8694 should fix the autest. Once it's merged into 10-Dev you can rebase.

@jrushford jrushford force-pushed the hoststatus_remove_stats branch from a2d99b8 to 72a1503 Compare February 22, 2022 16:03
@jrushford
Copy link
Contributor Author

[approve ci autest]

@jrushford jrushford force-pushed the hoststatus_remove_stats branch 4 times, most recently from 5e441ef to 7e27dad Compare February 28, 2022 03:12
@jrushford jrushford force-pushed the hoststatus_remove_stats branch 6 times, most recently from 80eac88 to 0aa2f12 Compare March 2, 2022 19:59
@jrushford jrushford force-pushed the hoststatus_remove_stats branch 3 times, most recently from 46bdebd to 5602294 Compare March 3, 2022 18:08
@jrushford
Copy link
Contributor Author

[approve ci fedora]

@jrushford jrushford force-pushed the hoststatus_remove_stats branch 2 times, most recently from 627dd3d to aea5c1d Compare March 3, 2022 23:06
@jrushford jrushford requested a review from rob05c March 4, 2022 05:09
- Updates HostStatus to eliminate stats creation.
- Updates traffic_ctl JSON-RPC to query HostStatus directly.
- adds in a new persistance mechanism for HosStatus.
@jrushford jrushford force-pushed the hoststatus_remove_stats branch from 195567b to 2816009 Compare March 4, 2022 17:23
@jrushford
Copy link
Contributor Author

[approve ci fedora]

@brbzull0
Copy link
Contributor

@jrushford this looks good, just have a question.
Do you think you will be injectingthe host_records.yaml into traffic_server through the JSON-RPC node?(by using traffic_ctl or any other tool). If this is the plan at some point maybe the field names in the rpc request and the dump host_records.yaml file should be the same in order to re-use them.

@jrushford
Copy link
Contributor Author

@jrushford this looks good, just have a question.
Do you think you will be injectingthe host_records.yaml into traffic_server through the JSON-RPC node?(by using traffic_ctl or any other tool). If this is the plan at some point maybe the field names in the rpc request and the dump host_records.yaml file should be the same in order to re-use them.

@brbzull0 I didn't have any plans to use the JSON-RPC node to inject them but, that could be useful. In this PR, the host_records.yaml is loaded at startup by trafficserver. However, I'll take a look and make sure that the names are the same, someone might have a use case for the injection.


std::string
get_method() const
{
Copy link
Contributor

Choose a reason for hiding this comment

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

@brbzull0 it's not clear why this even needs to be a virtual function:

Should derived classes just set the "method" member string?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's not clear why this even needs to be a virtual function

Because of this

json << YAML::Key << "method" << YAML::Value << req.get_method();

Should derived classes just set the "method" member string?

yes they can, in which case JSONRPCRequest::get_method will return it.

I wasn't very concern about the virtual thing in here as this is used by traffic_ctl and traffic_top.

}
}
ts::Rv<YAML::Node> server_get_status(std::string_view const &id, YAML::Node const &params);
ts::Rv<YAML::Node> server_set_status(std::string_view const &id, YAML::Node const &params);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why reference to string_view ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ywkaras okay, will pass by value.

ts::Rv<YAML::Node> server_get_status(std::string_view const &id, YAML::Node const &params);
ts::Rv<YAML::Node> server_set_status(std::string_view const &id, YAML::Node const &params);
ts::Rv<YAML::Node> server_get_status(std::string_view const id, YAML::Node const &params);
ts::Rv<YAML::Node> server_set_status(std::string_view const id, YAML::Node const &params);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's redundant to use 'string_view const' instead of just plain 'string_view' but harmless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ywkaras I'll change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's redundant to use 'string_view const' instead of just plain 'string_view' but harmless.

Totally, but the reason is this:

using MethodHandlerSignature = std::function<ts::Rv<YAML::Node>(std::string_view const &, const YAML::Node &)>;

It is expected to be like this.

--
The reason is const& is becase I wanted to make it clear that this should not mutate despite the fact that you cannot change it if it was only a std::string_view. I always thought that this is ambiguous and if someone try to change it well, good luck. Now kind of I am inclined to remove the const &

@ywkaras
Copy link
Contributor

ywkaras commented Mar 15, 2022

Looks good to me, let's see what Damian says.

@jrushford
Copy link
Contributor Author

[approve ci fedora]

1 similar comment
@jrushford
Copy link
Contributor Author

[approve ci fedora]

@jrushford
Copy link
Contributor Author

[approve ci]

@jrushford
Copy link
Contributor Author

@brbzull0 and @ywkaras any more changes? Are you ok with the const & removal?

@brbzull0
Copy link
Contributor

Looks good to me.

@jrushford jrushford merged commit f273f97 into apache:10-Dev Mar 21, 2022
jrushford added a commit to jrushford/trafficserver that referenced this pull request Apr 5, 2022
HostStatus::createHostStat(), that was removed with PR apache#8689.
jrushford added a commit that referenced this pull request Apr 11, 2022
…8782)

HostStatus::createHostStat(), that was removed with PR #8689.
@zwoop zwoop modified the milestones: 10-Dev, 10.0.0 Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Commands JSONRPC JSONRPC 2.0 related work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants