-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
network: add socket interface factory and config option #11630
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
388d1f9
network: add socket interface factory
florincoras c241e44
Merge branch 'master' into sock_factory
florincoras cc4d075
updates that try to reflect community conversations
florincoras d77b0a9
address comments
florincoras fdd0e2f
moving back to bootstrap extensions
florincoras 1ca8153
Merge branch 'master' into sock_factory
florincoras 6c34d86
use FactoryRegistry for SocketInterface lookup
florincoras 0f300c8
fix protodoc-title
florincoras 3612cfa
Merge branch 'master' into sock_factory
florincoras af294af
fix socket interface lookup
florincoras 43805c8
move default_socket_interface.proto to extensions
florincoras a02aa41
Merge branch 'master' into sock_factory
florincoras b622854
address comments
florincoras bd1a63d
Merge branch 'master' into sock_factory
florincoras f9cc098
disable integration test on windows
florincoras 97368af
add simple echo test
florincoras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
syntax = "proto3"; | ||
|
||
package envoy.config.core.v3; | ||
|
||
import "udpa/annotations/status.proto"; | ||
import "udpa/annotations/versioning.proto"; | ||
import "validate/validate.proto"; | ||
|
||
option java_package = "io.envoyproxy.envoy.config.core.v3"; | ||
option java_outer_classname = "SocketInterfaceProto"; | ||
option java_multiple_files = true; | ||
option (udpa.annotations.file_status).package_version_status = ACTIVE; | ||
|
||
// [#protodoc-title: Socket Interface Configuration ] | ||
|
||
// Used to select the socket interface implementation to use | ||
message SocketInterfaceConfig { | ||
enum SocketInterfaceType { | ||
// Default, OS dependent, implementation | ||
DEFAULT = 0; | ||
} | ||
|
||
// Implementation to use | ||
SocketInterfaceType type = 1 [(validate.rules).enum = {defined_only: true}]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
generated_api_shadow/envoy/config/core/v3/socket_interface.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
generated_api_shadow/envoy/config/core/v4alpha/socket_interface.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "common/network/socket_interface_factory.h" | ||
|
||
#include "envoy/config/core/v3/socket_interface.pb.h" | ||
#include "envoy/registry/registry.h" | ||
|
||
#include "common/network/socket_interface_impl.h" | ||
|
||
namespace Envoy { | ||
namespace Network { | ||
|
||
class SocketInterfaceExtension : public Server::BootstrapExtension {}; | ||
|
||
Server::BootstrapExtensionPtr | ||
SocketInterfaceFactory::createBootstrapExtension(const Protobuf::Message& config, | ||
Server::Configuration::ServerFactoryContext&) { | ||
const auto* proto = dynamic_cast<const envoy::config::core::v3::SocketInterfaceConfig*>(&config); | ||
switch (proto->type()) { | ||
case envoy::config::core::v3::SocketInterfaceConfig::DEFAULT: | ||
// no need to clear and re-initialize the SocketInterfaceSingleton | ||
break; | ||
default: | ||
break; | ||
} | ||
return std::make_unique<SocketInterfaceExtension>(); | ||
} | ||
|
||
ProtobufTypes::MessagePtr SocketInterfaceFactory::createEmptyConfigProto() { | ||
return std::make_unique<envoy::config::core::v3::SocketInterfaceConfig>(); | ||
} | ||
|
||
REGISTER_FACTORY(SocketInterfaceFactory, Server::Configuration::BootstrapExtensionFactory); | ||
|
||
} // namespace Network | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include "envoy/server/bootstrap_extension_config.h" | ||
|
||
namespace Envoy { | ||
namespace Network { | ||
|
||
class SocketInterfaceFactory : public Server::Configuration::BootstrapExtensionFactory { | ||
public: | ||
Server::BootstrapExtensionPtr | ||
createBootstrapExtension(const Protobuf::Message& config, | ||
Server::Configuration::ServerFactoryContext& context) override; | ||
ProtobufTypes::MessagePtr createEmptyConfigProto() override; | ||
std::string name() const override { return "envoy.bootstrap.socket_interface"; } | ||
}; | ||
|
||
} // namespace Network | ||
} // namespace Envoy |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you envision this to be used? I.e. what other implementations would be defined in the public Envoy API? How is this different from using the
Envoy::Network::SocketInterfaceLoader
to override default SocketInterface?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we want this to be separate from bootstrap extensions, as there is only one of these, right? Or per @yanavlasov do we potentially need to allow multiple that are potentially looked up by the resolver?
I think my general feeling for this is that we should be specifying this by typed config, either directly via a bootstrap extension or as a discrete thing that is also specified in bootstrap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the conversation on #11618, I think that just having the ability to inject a different implementation (bootstrap or not) may be enough. The thing that we're missing is a way to signal to the custom
SocketInterface
that certainAddress::Instance
s should be treated differently.As for the best option to change the
SocketInterface
, I'll let you be the judge of it! :-)My rather naive (and probably wrong) idea was to add to extensions "socket interface shims" that would link to actual implementations, have them imported in
socket_interface_factory.h
and added as options insocket_interface.proto
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be on the
Address
itself, similar to the resolver?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@htuch, that's an interesting idea. My original plan was to have a way of overriding the default
SocketInterface
implementation with a startup conf* because I assumed we wanted only one such interface to be active at a time.Are you thinking about having multiple
SocketInterfaces
in aFactoryRegistry
and then, based onAddress
attributes, retrieve and ask the factory to generate anIoHandle
(or aSocket
if we later decide to merge the two)? It sounds good to me.*side note: just did some testing and realized that bootstrap_extensions are loaded after the
ListenerManager
is initialized. So, this can't work as is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, similar to how we deal with the resolver. One thing to be cautious of is proto bloat, since we may have a lot of addresses in an Envoy config, so having to repeat the opaque config for each extension in each address might be expensive (I think the existing resolver interface suffers from this). So, I actually think I'm more in favor of the tags that @ggreenway suggested; I see this as being somewhat similar to the transport socket matchers that are now used by clusters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this should be a typed config, similar to other extensions configuration. Otherwise you'd have to leak extension specific config into the core API.
I do not have a strong sense whether this should involve addresses or not. I can see someone adding iWARP support in Envoy and it might not involve addresses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would then a hash_map/vector of
Address::Tag
objects (to be defined) inAddress::InstanceBase
that can be updated viaAddress::Instance
apis be enough? Or do you think we need something more generic? (cc @ggreenway , @yanavlasov)This would limit configurability but it should be pretty light weight. It does have the advantage that the resolver can easily pass opaque information to the
SocketInterface
implementation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yanavlasov agreed and apologies, I somehow managed to miss your comment.
To summarize, I guess we now have two issues that need to be solved:
SocketInterface
implementation(s). Should be a typed config. I'm probably confused here, but the original goal ofsocket_interface
was to use it as a typed_config under bootstrap_extensions and to keep on adding types to the enum, afterDEFAULT
, as we add more implementations to extensions. Were you thinking about something else? Even so, this doesn't work as a bootstrap extension because it's initialized afterListenerManager
, i.e., after the addresses are bound. I guess we'll have to move it directly under boostrap.SocketInterface
viaAddress::Instance
s. My previous comment was only concerned with this.