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

API: Unready Targets Dump #12554

Merged
merged 78 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
10249c2
init-manager-query-unready-targets
ping-sun Jul 10, 2020
1de879e
init-manager-query-unready-targets
ping-sun Jul 10, 2020
5a7c308
init-manager-query-unready-targets
ping-sun Jul 10, 2020
562cc49
update: unordered_map->flat_hash_map; const std::string->absl:string_…
ping-sun Jul 10, 2020
a023f16
init-manager-query-unready-targets
ping-sun Jul 10, 2020
e7ac416
init-manager-query-unready-targets
ping-sun Jul 11, 2020
b7fb8d8
add dumpUnreadyTargetsConfig; remove checkUnreadyTargets()
ping-sun Jul 14, 2020
c20129d
add dumpUnreadyTargetsConfigs()
ping-sun Jul 14, 2020
6458f27
add dumpUnreadyTargetsConfigs()
ping-sun Jul 14, 2020
452a264
add dumpUnreadyTargetsConfigs()
ping-sun Jul 14, 2020
dc362e2
Merge branch 'master' of github.com:envoyproxy/envoy into exp
ping-sun Jul 14, 2020
0b7b75f
add extra constructor
ping-sun Jul 15, 2020
80af9b5
add extra constructor
ping-sun Jul 15, 2020
2653323
add WatcherImpl constructors
ping-sun Jul 15, 2020
9e2263c
remove useless string_view parameter
ping-sun Jul 15, 2020
6428f5e
remove usesless string_view parameter
ping-sun Jul 15, 2020
6dbadd5
add warming/active listeners config dump
ping-sun Jul 15, 2020
83a7435
add warming/active listeners config dump
ping-sun Jul 15, 2020
dc4a1d4
add warming/active listeners config dump
ping-sun Jul 15, 2020
4539ee5
Merge remote-tracking branch 'upstream/master' into init-manager-quer…
ping-sun Jul 15, 2020
8cd7fd6
update stats_integration_test memory usage
ping-sun Jul 16, 2020
4f7900d
update variable name and comments
ping-sun Jul 16, 2020
27b6ca5
update mem usage stats
ping-sun Jul 16, 2020
fd5cbf4
update mem usage stats
ping-sun Jul 17, 2020
ef32968
Merge branch 'init-manager-query-unready-targets' of github.com:ASOPV…
ping-sun Jul 17, 2020
f4409df
update mem usage stats
ping-sun Jul 17, 2020
031f585
update comment
ping-sun Jul 17, 2020
c4bf9a5
update comment
ping-sun Jul 17, 2020
e8e66ff
update comments
ping-sun Jul 17, 2020
17ae201
add comments about the usage of WatcherImpl's ctor
ping-sun Jul 22, 2020
ea93b6b
add comments about the usage of WatcherImpl's ctor
ping-sun Jul 22, 2020
e359fcc
add comments about the usage of WatcherImpl's ctor
ping-sun Jul 22, 2020
30bc756
introduce ManagerWatcher for watcher inside init manager; update prot…
ping-sun Jul 31, 2020
e794914
merge dump active/warming listeners config
ping-sun Jul 31, 2020
3ab3c1a
Rename: ManagerWatcher -> TargetAwareWatcher
ping-sun Jul 31, 2020
4a7d10e
Rename: ManagerWatcher -> TargetAwareWatcher
ping-sun Jul 31, 2020
638c687
solve integration stats conflict
ping-sun Jul 31, 2020
2756e2e
solve integration stats conflict
ping-sun Jul 31, 2020
f1d9129
retry pre-submit test
ping-sun Aug 1, 2020
b92eff1
retry pre-submit test
ping-sun Aug 1, 2020
695a745
remove TargetAwareWatcher; add 2 Ctors for watcherImpl
ping-sun Aug 1, 2020
1794f68
Merge branch 'master' of github.com:envoyproxy/envoy into init-manage…
ping-sun Aug 1, 2020
76aa72b
update integration stats
ping-sun Aug 1, 2020
c2af7fe
delete add string_view param into ManagerImpl::onTargetReady(); gener…
ping-sun Aug 5, 2020
0d3269b
Merge branch 'master' of github.com:envoyproxy/envoy into init-manage…
ping-sun Aug 5, 2020
19b2cdd
target-aware-watcher
ping-sun Aug 5, 2020
5b08552
remove/update comments
ping-sun Aug 6, 2020
cbe2ea4
move ++target_names_count[name] pos
ping-sun Aug 7, 2020
788179f
unready-targets-config-dump
ping-sun Aug 7, 2020
e87b700
merge master
ping-sun Aug 7, 2020
a1be8d2
merge master
ping-sun Aug 7, 2020
baddc2e
add comment
ping-sun Aug 8, 2020
181af8a
Merge branch 'master' of github.com:envoyproxy/envoy into unready-tar…
ping-sun Aug 8, 2020
94b9b97
merge conflict remove warmingListeners()
ping-sun Aug 10, 2020
a814e1c
add dumpUnreadyTargetsConfig in init::manager
ping-sun Aug 12, 2020
187a38b
add dumpUnreadyTargetsConfig in init::manager
ping-sun Aug 12, 2020
274f6b1
add dumpUnreadyTargetsConfig inside init::manager
ping-sun Aug 12, 2020
da33c4f
add description for virtual functions; dump everything by default
ping-sun Aug 14, 2020
2e0bcbd
make message nested
ping-sun Aug 21, 2020
2182397
Merge branch 'master' of github.com:envoyproxy/envoy into unready-tar…
ping-sun Aug 21, 2020
bda0a89
make sub message nested
ping-sun Aug 21, 2020
a9d3771
adding test for unready targets config dump; add initManager() for Li…
ping-sun Aug 28, 2020
face786
Merge branch 'master' of github.com:envoyproxy/envoy into unready-tar…
ping-sun Aug 28, 2020
096cb60
fix deleted file
ping-sun Aug 28, 2020
37f69d2
merge
ping-sun Sep 1, 2020
3dc8ab6
fix merge
ping-sun Sep 1, 2020
c0038fd
Merge branch 'master' of github.com:envoyproxy/envoy into unready-tar…
ping-sun Sep 2, 2020
064b5cc
Merge branch 'master' of github.com:envoyproxy/envoy into unready-tar…
ping-sun Sep 3, 2020
8c8c1e4
merge conflict
ping-sun Sep 3, 2020
f4d523d
dumps for unready targets; introduce new init_dump
ping-sun Sep 4, 2020
1313edd
api change: init dump using '/init_dump' to dump unready targets
ping-sun Sep 8, 2020
54ccd99
api change: init dump using '/init_dump' to dump unready targets
ping-sun Sep 8, 2020
06f355c
api change: init dump using '/init_dump' to dump unready targets
ping-sun Sep 8, 2020
7001271
Merge branch 'master' of github.com:envoyproxy/envoy into unready-tar…
ping-sun Sep 8, 2020
5950e54
merge conflict
ping-sun Sep 8, 2020
1ce686e
api change: init dump using '/init_dump' to dump unready targets
ping-sun Sep 8, 2020
8ef10ff
introduce init_dump_handler_lib
ping-sun Sep 9, 2020
9bd7dee
remove unused using
ping-sun Sep 10, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions api/envoy/admin/v3/init_dump.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
syntax = "proto3";

package envoy.admin.v3;

import "udpa/annotations/status.proto";
import "udpa/annotations/versioning.proto";

option java_package = "io.envoyproxy.envoy.admin.v3";
option java_outer_classname = "InitDumpProto";
option java_multiple_files = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE;

// [#protodoc-title: InitDump]

// Dumps of unready targets of envoy init managers. Envoy's admin fills this message with init managers,
// which provides the information of their unready targets.
// The :ref:`/init_dump <operations_admin_interface_init_dump>` will dump all unready targets information.
message UnreadyTargetsDumps {
// Message of unready targets information of an init manager.
message UnreadyTargetsDump {
// Name of the init manager. Example: "init_manager_xxx".
string name = 1;

// Names of unready targets of the init manager. Example: "target_xxx".
repeated string target_names = 2;
}

// You can choose specific component to dump unready targets with mask query parameter.
// See :ref:`/init_dump?mask={} <operations_admin_interface_init_dump_by_mask>` for more information.
// The dumps of unready targets of all init managers.
repeated UnreadyTargetsDump unready_targets_dumps = 1;
}
37 changes: 37 additions & 0 deletions api/envoy/admin/v4alpha/init_dump.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions docs/root/operations/admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,24 @@ modify different aspects of the server:

See :option:`--hot-restart-version`.

.. _operations_admin_interface_init_dump:

.. http:get:: /init_dump

Dump currently information of unready targets of various Envoy components as JSON-serialized proto
messages. See the :ref:`response definition <envoy_v3_api_msg_admin.v3.UnreadyTargetsDumps>` for more
information.

.. _operations_admin_interface_init_dump_by_mask:

.. http:get:: /init_dump?mask={}

When mask query parameters is specified, the mask value is the desired component to dump unready targets.
The mask is parsed as a ``ProtobufWkt::FieldMask``.

For example, get the unready targets of all listeners with
``/init_dump?mask=listener``

.. _operations_admin_interface_listeners:

.. http:get:: /listeners
Expand Down
1 change: 1 addition & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ New Features
* access log: added support for :ref:`%DOWNSTREAM_PEER_FINGERPRINT_1% <config_access_log_format_response_flags>` as a response flag.
* access log: added support for nested objects in :ref:`JSON logging mode <config_access_log_format_dictionaries>`.
* access log: added :ref:`omit_empty_values<envoy_v3_api_field_config.core.v3.SubstitutionFormatString.omit_empty_values>` option to omit unset value from formatted log.
* admin: added the ability to dump init manager unready targets information :ref:`/init_dump <operations_admin_interface_init_dump>` and :ref:`/init_dump?mask={} <operations_admin_interface_init_dump_by_mask>`.
* build: enable building envoy :ref:`arm64 images <arm_binaries>` by buildx tool in x86 CI platform.
* cluster: added new :ref:`connection_pool_per_downstream_connection <envoy_v3_api_field_config.cluster.v3.Cluster.connection_pool_per_downstream_connection>` flag, which enable creation of a new connection pool for each downstream connection.
* decompressor filter: reports compressed and uncompressed bytes in trailers.
Expand Down
32 changes: 32 additions & 0 deletions generated_api_shadow/envoy/admin/v3/init_dump.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions generated_api_shadow/envoy/admin/v4alpha/init_dump.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions include/envoy/init/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ envoy_cc_library(
deps = [
":target_interface",
":watcher_interface",
"@envoy_api//envoy/admin/v3:pkg_cc_proto",
],
)
13 changes: 13 additions & 0 deletions include/envoy/init/manager.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#pragma once

#include "envoy/admin/v3/init_dump.pb.h"
#include "envoy/common/pure.h"
#include "envoy/init/target.h"
#include "envoy/init/watcher.h"

#include "absl/container/flat_hash_map.h"

namespace Envoy {
namespace Init {

Expand Down Expand Up @@ -73,6 +76,16 @@ struct Manager {
* @param watcher the watcher to notify when initialization is complete.
*/
virtual void initialize(const Watcher& watcher) PURE;

/**
* @return the unready targets of the manager.
*/
virtual const absl::flat_hash_map<std::string, uint32_t>& unreadyTargets() const PURE;

/**
* Add unready targets information into the config dump.
*/
virtual void dumpUnreadyTargets(envoy::admin::v3::UnreadyTargetsDumps& dumps) PURE;
};

} // namespace Init
Expand Down
1 change: 1 addition & 0 deletions include/envoy/network/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ envoy_cc_library(
":udp_packet_writer_handler_interface",
"//include/envoy/access_log:access_log_interface",
"//include/envoy/common:resource_interface",
"//include/envoy/init:manager_interface",
"//include/envoy/stats:stats_interface",
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
],
Expand Down
6 changes: 6 additions & 0 deletions include/envoy/network/listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "envoy/common/exception.h"
#include "envoy/common/resource.h"
#include "envoy/config/core/v3/base.pb.h"
#include "envoy/init/manager.h"
#include "envoy/network/connection.h"
#include "envoy/network/connection_balancer.h"
#include "envoy/network/listen_socket.h"
Expand Down Expand Up @@ -166,6 +167,11 @@ class ListenerConfig {
* @return pending connection backlog for TCP listeners.
*/
virtual uint32_t tcpBacklogSize() const PURE;

/**
* @return init manager of the listener.
*/
virtual Init::Manager& initManager() PURE;
};

/**
Expand Down
5 changes: 5 additions & 0 deletions include/envoy/server/listener_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ class ListenerManager {
* @return the server's API Listener if it exists, nullopt if it does not.
*/
virtual ApiListenerOptRef apiListener() PURE;

/*
* @return TRUE if the worker has started or FALSE if not.
*/
virtual bool isWorkerStarted() PURE;
ping-sun marked this conversation as resolved.
Show resolved Hide resolved
};

// overload operator| to allow ListenerManager::listeners(ListenerState) to be called using a
Expand Down
8 changes: 8 additions & 0 deletions source/common/init/manager_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ const absl::flat_hash_map<std::string, uint32_t>& ManagerImpl::unreadyTargets()
return target_names_count_;
}

void ManagerImpl::dumpUnreadyTargets(envoy::admin::v3::UnreadyTargetsDumps& unready_targets_dumps) {
auto& message = *unready_targets_dumps.mutable_unready_targets_dumps()->Add();
message.set_name(name_);
for (const auto& [target_name, count] : target_names_count_) {
message.add_target_names(target_name);
}
}

void ManagerImpl::onTargetReady(absl::string_view target_name) {
// If there are no remaining targets and one mysteriously calls us back, this manager is haunted.
ASSERT(count_ != 0,
Expand Down
5 changes: 2 additions & 3 deletions source/common/init/manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ class ManagerImpl : public Manager, Logger::Loggable<Logger::Id::init> {
State state() const override;
void add(const Target& target) override;
void initialize(const Watcher& watcher) override;

// Expose the const reference of target_names_count_ hash map to public.
const absl::flat_hash_map<std::string, uint32_t>& unreadyTargets() const;
const absl::flat_hash_map<std::string, uint32_t>& unreadyTargets() const override;
void dumpUnreadyTargets(envoy::admin::v3::UnreadyTargetsDumps& dumps) override;

private:
// Callback function with an additional target_name parameter, decrease unready targets count by
Expand Down
17 changes: 17 additions & 0 deletions source/server/admin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ envoy_cc_library(
":clusters_handler_lib",
":config_dump_handler_lib",
":config_tracker_lib",
":init_dump_handler_lib",
":listeners_handler_lib",
":logs_handler_lib",
":profiling_handler_lib",
Expand Down Expand Up @@ -63,6 +64,7 @@ envoy_cc_library(
"//source/common/router:scoped_config_lib",
"//source/common/stats:isolated_store_lib",
"//source/extensions/access_loggers/file:file_access_log_lib",
"//source/server:listener_manager_lib",
],
)

Expand Down Expand Up @@ -259,6 +261,21 @@ envoy_cc_library(
],
)

envoy_cc_library(
name = "init_dump_handler_lib",
srcs = ["init_dump_handler.cc"],
hdrs = ["init_dump_handler.h"],
deps = [
":handler_ctx_lib",
":utils_lib",
"//include/envoy/server:admin_interface",
"//include/envoy/server:instance_interface",
"//source/common/http:codes_lib",
"//source/common/http:header_map_lib",
"@envoy_api//envoy/admin/v3:pkg_cc_proto",
],
)

envoy_cc_library(
name = "utils_lib",
srcs = ["utils.cc"],
Expand Down
10 changes: 7 additions & 3 deletions source/server/admin/admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "common/router/config_impl.h"

#include "server/admin/utils.h"
#include "server/listener_impl.h"

#include "extensions/access_loggers/file/file_access_log_impl.h"

Expand Down Expand Up @@ -154,9 +155,10 @@ AdminImpl::AdminImpl(const std::string& profile_path, Server::Instance& server)
Http::ConnectionManagerImpl::generateTracingStats("http.admin.", no_op_store_)),
route_config_provider_(server.timeSource()),
scoped_route_config_provider_(server.timeSource()), clusters_handler_(server),
config_dump_handler_(config_tracker_, server), stats_handler_(server), logs_handler_(server),
profiling_handler_(profile_path), runtime_handler_(server), listeners_handler_(server),
server_cmd_handler_(server), server_info_handler_(server),
config_dump_handler_(config_tracker_, server), init_dump_handler_(server),
stats_handler_(server), logs_handler_(server), profiling_handler_(profile_path),
runtime_handler_(server), listeners_handler_(server), server_cmd_handler_(server),
server_info_handler_(server),
// TODO(jsedgwick) add /runtime_reset endpoint that removes all admin-set values
handlers_{
{"/", "Admin home page", MAKE_ADMIN_HANDLER(handlerAdminHome), false, false},
Expand All @@ -166,6 +168,8 @@ AdminImpl::AdminImpl(const std::string& profile_path, Server::Instance& server)
MAKE_ADMIN_HANDLER(clusters_handler_.handlerClusters), false, false},
{"/config_dump", "dump current Envoy configs (experimental)",
MAKE_ADMIN_HANDLER(config_dump_handler_.handlerConfigDump), false, false},
{"/init_dump", "dump current Envoy init manager information (experimental)",
MAKE_ADMIN_HANDLER(init_dump_handler_.handlerInitDump), false, false},
{"/contention", "dump current Envoy mutex contention stats (if enabled)",
MAKE_ADMIN_HANDLER(stats_handler_.handlerContention), false, false},
{"/cpuprofiler", "enable/disable the CPU profiler",
Expand Down
8 changes: 7 additions & 1 deletion source/server/admin/admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "server/admin/clusters_handler.h"
#include "server/admin/config_dump_handler.h"
#include "server/admin/config_tracker_impl.h"
#include "server/admin/init_dump_handler.h"
#include "server/admin/listeners_handler.h"
#include "server/admin/logs_handler.h"
#include "server/admin/profiling_handler.h"
Expand Down Expand Up @@ -287,6 +288,7 @@ class AdminImpl : public Admin,
Http::Code handlerAdminHome(absl::string_view path_and_query,
Http::ResponseHeaderMap& response_headers, Buffer::Instance& response,
AdminStream&);

Http::Code handlerHelp(absl::string_view path_and_query,
Http::ResponseHeaderMap& response_headers, Buffer::Instance& response,
AdminStream&);
Expand Down Expand Up @@ -320,7 +322,8 @@ class AdminImpl : public Admin,
public:
AdminListener(AdminImpl& parent, Stats::ScopePtr&& listener_scope)
: parent_(parent), name_("admin"), scope_(std::move(listener_scope)),
stats_(Http::ConnectionManagerImpl::generateListenerStats("http.admin.", *scope_)) {}
stats_(Http::ConnectionManagerImpl::generateListenerStats("http.admin.", *scope_)),
init_manager_(nullptr) {}

// Network::ListenerConfig
Network::FilterChainManager& filterChainManager() override { return parent_; }
Expand Down Expand Up @@ -351,6 +354,7 @@ class AdminImpl : public Admin,
return empty_access_logs_;
}
uint32_t tcpBacklogSize() const override { return ENVOY_TCP_BACKLOG_SIZE; }
Init::Manager& initManager() override { return *init_manager_; }

AdminImpl& parent_;
const std::string name_;
Expand All @@ -361,6 +365,7 @@ class AdminImpl : public Admin,

private:
const std::vector<AccessLog::InstanceSharedPtr> empty_access_logs_;
std::unique_ptr<Init::Manager> init_manager_;
};
using AdminListenerPtr = std::unique_ptr<AdminListener>;

Expand Down Expand Up @@ -398,6 +403,7 @@ class AdminImpl : public Admin,
NullScopedRouteConfigProvider scoped_route_config_provider_;
Server::ClustersHandler clusters_handler_;
Server::ConfigDumpHandler config_dump_handler_;
Server::InitDumpHandler init_dump_handler_;
Server::StatsHandler stats_handler_;
Server::LogsHandler logs_handler_;
Server::ProfilingHandler profiling_handler_;
Expand Down
Loading