Skip to content
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
4993962
Introduced a unified mux implementation
Jun 16, 2021
c43f23c
Removed init fetch timeout from the mux
Jul 9, 2021
3308ced
delta mux tests are passing now
Jul 14, 2021
4a66a31
Moved most of mux functionality into the base class
Jul 14, 2021
084a576
Added more mux tests
Jul 14, 2021
b2b5729
Merge remote-tracking branch 'upstream/main' into xds-unification-part-2
Jul 14, 2021
916d8ba
Fixed vuild failure
Jul 14, 2021
6bed794
Fixed formatting
Jul 14, 2021
7289b6e
Fixing formatting
Jul 14, 2021
968b68c
Fixing formatting
Jul 14, 2021
25d7134
Added tests to improve test coverage
Jul 16, 2021
6414bf7
Merge branch 'main' into xds-unification-mux
Jul 21, 2021
8aa55b8
small refactoring
Jul 22, 2021
d9e3966
Added grpc_mux_impl.h to code coverage exceptions with 69.8 coverage
Jul 22, 2021
4947a4b
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Jul 22, 2021
421b56e
Fixed per-extension coverage for xds_mux
Jul 23, 2021
93ea6f5
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Jul 27, 2021
284cdca
Moved grpc_stream_ from concrete classes into the base
Jul 28, 2021
1fd1c36
removed paused() method from mux interface
Jul 28, 2021
a11a2dc
Removed BaseGrpcStream interface
Jul 28, 2021
2450ab8
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Jul 28, 2021
52a2b1a
Ported support for mux shutdown
Jul 28, 2021
d156273
Added comments re: GrpcMuxImpl template parameters
Jul 28, 2021
4fabd09
Adjusted test coverage for xds_mux
Jul 29, 2021
9da89e1
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Jul 29, 2021
026d42d
Reponded to feedback
Aug 3, 2021
c5c8048
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Aug 3, 2021
e094de6
Removed mutex from XdsMux::AllMuxesState
Aug 3, 2021
262f3fc
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Aug 4, 2021
08e71af
Trying to fix failing tests
Aug 4, 2021
f551585
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Aug 4, 2021
c564840
Trying to fix test failures
Aug 4, 2021
b3d0f1c
Fixing tests
Aug 4, 2021
9219521
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Aug 9, 2021
2f169b9
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Aug 16, 2021
a317d84
Fixing build failure: removed v2_link_hacks
Aug 16, 2021
5dd4162
Fixed formatting
Aug 16, 2021
3568c20
Fixing build
Aug 17, 2021
335d7d6
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Aug 17, 2021
533bb6f
trying to fix windows build
Aug 17, 2021
f8178dc
Fixed formatting
Aug 17, 2021
5ac0553
Trying to fix tests under windows
Aug 17, 2021
03f7a7c
Revert "Trying to fix tests under windows"
Aug 17, 2021
de40b51
Trying to fix test failures on Windows
Aug 17, 2021
58837b7
Trying to fix test failures on Windows
Aug 17, 2021
2a7a5af
Trying to fix test failures on Windows
Aug 17, 2021
dfe3515
Revert "Trying to fix test failures on Windows"
Aug 18, 2021
ab0cab5
Revert "Trying to fix test failures on Windows"
Aug 18, 2021
349de21
Revert "Trying to fix test failures on Windows"
Aug 18, 2021
cda496e
Trying to fix test failures under Windows
Aug 18, 2021
3777c61
Revert "Trying to fix test failures under Windows"
Aug 18, 2021
1b5564c
Trying to fix test failures under Windows
Aug 18, 2021
1970420
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Aug 18, 2021
95075f9
Trying to fix test failures under Windows
Aug 18, 2021
1e58a3d
Trying to fix test failures under Windows
Aug 18, 2021
ba094fb
Revert "Trying to fix test failures under Windows"
Aug 18, 2021
e169379
Trying to fix test failures under Windows
Aug 18, 2021
893ce72
Trying to fix test failures under Windows
Aug 18, 2021
1ab61ad
Trying to fix test failures under Windows
Aug 18, 2021
bfde33b
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Aug 18, 2021
cd20489
Merge remote-tracking branch 'upstream/main' into xds-unification-mux
Aug 19, 2021
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
23 changes: 23 additions & 0 deletions envoy/config/grpc_mux.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ struct ControlPlaneStats {
GENERATE_TEXT_READOUT_STRUCT)
};

// TODO (dmitri-d) This forward declaration is needed in order for the unified mux to fulfill legacy
// mux interface. It should be removed together with the rest of legacy mux code when the switch to
// unified mux has been finalized.
struct Watch;

/**
* Handle on a muxed gRPC subscription. The subscription is canceled on destruction.
*/
Expand Down Expand Up @@ -105,6 +110,24 @@ class GrpcMux {

virtual void requestOnDemandUpdate(const std::string& type_url,
const absl::flat_hash_set<std::string>& for_update) PURE;

// Unified mux interface starts here
// Updates the list of resource names watched by the given watch. If an added name is new across
// the whole subscription, or if a removed name has no other watch interested in it, then the
// subscription will enqueue and attempt to send an appropriate discovery request.
virtual void updateWatch(const std::string& type_url, Watch* watch,
Comment thread
dmitri-d marked this conversation as resolved.
Outdated
const absl::flat_hash_set<std::string>& resources,
const SubscriptionOptions& options) PURE;

/**
* Cleanup of a Watch* added by addOrUpdateWatch(). Receiving a Watch* from addOrUpdateWatch()
* makes you responsible for eventually invoking this cleanup.
* @param type_url type URL corresponding to xDS API e.g. type.googleapis.com/envoy.api.v2.Cluster
* @param watch the watch to be cleaned up.
*/
virtual void removeWatch(const std::string& type_url, Watch* watch) PURE;

virtual bool isUnified() const { return false; }
};

using GrpcMuxPtr = std::unique_ptr<GrpcMux>;
Expand Down
10 changes: 10 additions & 0 deletions source/common/config/grpc_mux_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,5 +381,15 @@ void GrpcMuxImpl::drainRequests() {
grpc_stream_.maybeUpdateQueueSizeStat(request_queue_->size());
}

void NullGrpcMuxImpl::updateWatch(const std::string&, Watch*,
const absl::flat_hash_set<std::string>&,
const SubscriptionOptions&) {
throw EnvoyException("ADS must be configured to support an ADS config source");
}

void NullGrpcMuxImpl::removeWatch(const std::string&, Watch*) {
throw EnvoyException("ADS must be configured to support an ADS config source");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: implement these directly in the header file

@dmitri-d dmitri-d Jul 26, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We now have a check that yells if exceptions are being raised in headers, which makes me think that such an approach should be used sparingly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, no exception throwing in headers :) @adisuissa we have an internal requirement around this.


} // namespace Config
} // namespace Envoy
9 changes: 9 additions & 0 deletions source/common/config/grpc_mux_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ class GrpcMuxImpl : public GrpcMux,
void setRetryTimer();
void sendDiscoveryRequest(const std::string& type_url);

void removeWatch(const std::string&, Watch*) override { NOT_IMPLEMENTED_GCOVR_EXCL_LINE; }
void updateWatch(const std::string&, Watch*, const absl::flat_hash_set<std::string>&,
const SubscriptionOptions&) override {
NOT_IMPLEMENTED_GCOVR_EXCL_LINE;
}

struct GrpcMuxWatchImpl : public GrpcMuxWatch {
GrpcMuxWatchImpl(const absl::flat_hash_set<std::string>& resources,
SubscriptionCallbacks& callbacks, OpaqueResourceDecoder& resource_decoder,
Expand Down Expand Up @@ -216,6 +222,9 @@ class NullGrpcMuxImpl : public GrpcMux,
ExceptionUtil::throwEnvoyException("ADS must be configured to support an ADS config source");
}

void updateWatch(const std::string&, Watch*, const absl::flat_hash_set<std::string>&,
const SubscriptionOptions&) override;
void removeWatch(const std::string&, Watch*) override;
void requestOnDemandUpdate(const std::string&, const absl::flat_hash_set<std::string>&) override {
NOT_IMPLEMENTED_GCOVR_EXCL_LINE;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this not implemented and the other methods throw an exception (ADS must be configured)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I don't feel strongly about this; my thinking was that requestOnDemandUpdate only makes sense for a delta mux, so all other implementations panic. I can throw an exception here if you think it's easier to understand/read.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We shouldn't assume that delta implies ADS though if that's what is suggested.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I do think the original message in the exception is weird (see also here: https://github.com/envoyproxy/envoy/blob/main/source/common/config/grpc_mux_impl.h#L215). Perhaps a simple panic would suffice in those places? I could a separate PR to update the message in legacy mux implementation.

}
Expand Down
4 changes: 2 additions & 2 deletions source/common/config/new_grpc_mux_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ class NewGrpcMuxImpl
const SubscriptionOptions options_;
};

void removeWatch(const std::string& type_url, Watch* watch);
void removeWatch(const std::string& type_url, Watch* watch) override;

// Updates the list of resource names watched by the given watch. If an added name is new across
// the whole subscription, or if a removed name has no other watch interested in it, then the
// subscription will enqueue and attempt to send an appropriate discovery request.
void updateWatch(const std::string& type_url, Watch* watch,
const absl::flat_hash_set<std::string>& resources,
const SubscriptionOptions& options);
const SubscriptionOptions& options) override;

// Adds a subscription for the type_url to the subscriptions map and order list.
void addSubscription(const std::string& type_url, bool use_namespace_matching,
Expand Down
21 changes: 21 additions & 0 deletions source/common/config/xds_mux/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,24 @@ envoy_cc_library(
"@envoy_api//envoy/service/discovery/v3:pkg_cc_proto",
],
)

envoy_cc_library(
name = "grpc_mux_lib",
srcs = ["grpc_mux_impl.cc"],
hdrs = ["grpc_mux_impl.h"],
deps = [
":delta_subscription_state_lib",
":sotw_subscription_state_lib",
"//envoy/event:dispatcher_interface",
"//envoy/grpc:async_client_interface",
"//source/common/config:api_version_lib",
"//source/common/config:decoded_resource_lib",
"//source/common/config:grpc_stream_lib",
"//source/common/config:pausable_ack_queue_lib",
"//source/common/config:watch_map_lib",
"//source/common/config:xds_context_params_lib",
"//source/common/config:xds_resource_lib",
"//source/common/memory:utils_lib",
"@envoy_api//envoy/service/discovery/v3:pkg_cc_proto",
],
)
14 changes: 14 additions & 0 deletions source/common/config/xds_mux/delta_subscription_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ class DeltaSubscriptionState
std::set<std::string> names_removed_;
};

class DeltaSubscriptionStateFactory : public SubscriptionStateFactory<DeltaSubscriptionState> {
public:
DeltaSubscriptionStateFactory(Event::Dispatcher& dispatcher) : dispatcher_(dispatcher) {}
~DeltaSubscriptionStateFactory() override = default;
std::unique_ptr<DeltaSubscriptionState>
makeSubscriptionState(const std::string& type_url, UntypedConfigUpdateCallbacks& callbacks,
OpaqueResourceDecoder&, const bool wildcard) override {
return std::make_unique<DeltaSubscriptionState>(type_url, callbacks, dispatcher_, wildcard);
}

private:
Event::Dispatcher& dispatcher_;
};

} // namespace XdsMux
} // namespace Config
} // namespace Envoy
Loading