Skip to content

move route config provider manager to singleton manager registry#1449

Merged
mattklein123 merged 14 commits intomasterfrom
singleton-manager-route-config
Aug 17, 2017
Merged

move route config provider manager to singleton manager registry#1449
mattklein123 merged 14 commits intomasterfrom
singleton-manager-route-config

Conversation

@junr03
Copy link
Copy Markdown
Member

@junr03 junr03 commented Aug 11, 2017

Move the RouteConfigProviderManager singleton from server ownership to shared ownership by HttpConnectionManagers. Registered with the Singleton Manager introduced in #1410.

WIP need to look at asan and tsan failures

static constexpr char route_config_provider_manager_singleton_name[] =
"route_config_provider_manager_singleton_name";
static Registry::RegisterFactory<
Singleton::RegistrationImpl<route_config_provider_manager_singleton_name>,
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.

I wonder if it makes sense to have a macro to avoid the boilerplate when we declare singletons. E.g. make this something more like DEFINE_SINGLETON(route_config_provider_manager);, which then synthesizes the rest. Could clean this up for the date provider too.

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.

that sounds like a good idea.

});

std::shared_ptr<HttpConnectionManagerConfig> http_config(new HttpConnectionManagerConfig(
config, context, *date_provider, *route_config_provider_manager));
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.

Are we losing the reference count here? The singleton manager only has a weak pointer, when route_config_provider_manager goes out of scope above, it will delete the RouteConfigProviderManager.

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.

It's captured in the lambda below. I meant to put a comment on this and I admit it's a little hard to see. I would just add a comment to make it clear.

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.

Also, I haven't looked at your admin change yet, but this change will have implications on that one (not sure exactly what your plan is there) so I would land this one first.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Nice cleanup, thanks.

/**
* @return RouteConfigProviderManager& singleton for use by the entire server.
*/
virtual Router::RouteConfigProviderManager& routeConfigProviderManager() PURE;
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.

I don't see any mock cleanups in this change. Please get those also.

static constexpr char route_config_provider_manager_singleton_name[] =
"route_config_provider_manager_singleton_name";
static Registry::RegisterFactory<
Singleton::RegistrationImpl<route_config_provider_manager_singleton_name>,
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.

that sounds like a good idea.

});

std::shared_ptr<HttpConnectionManagerConfig> http_config(new HttpConnectionManagerConfig(
config, context, *date_provider, *route_config_provider_manager));
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.

It's captured in the lambda below. I meant to put a comment on this and I admit it's a little hard to see. I would just add a comment to make it clear.

});

std::shared_ptr<HttpConnectionManagerConfig> http_config(new HttpConnectionManagerConfig(
config, context, *date_provider, *route_config_provider_manager));
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.

Also, I haven't looked at your admin change yet, but this change will have implications on that one (not sure exactly what your plan is there) so I would land this one first.

Jose Nino added 2 commits August 11, 2017 22:10
@junr03 junr03 mentioned this pull request Aug 15, 2017
3 tasks
@junr03 junr03 force-pushed the singleton-manager-route-config branch 2 times, most recently from a0f7dfb to c590189 Compare August 16, 2017 00:34
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

LGTM other than switching to a macro for defining a singleton per @htuch. Thanks.

htuch
htuch previously approved these changes Aug 16, 2017
Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

LGTM as well modulo singleton macro.

@junr03
Copy link
Copy Markdown
Member Author

junr03 commented Aug 16, 2017

@htuch updated with the macro. I am not sure if it is preferable to have it here on in the manager interface, open to your suggestion.

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

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

Looks good. I'd probably but it in singleton.h, but arguably it's related to both header files but in neither case does it have the set of dependencies actually fully included.


std::shared_ptr<Router::RouteConfigProviderManager> route_config_provider_manager =
context.singletonManager().getTyped<Router::RouteConfigProviderManager>(
route_config_provider_manager_singleton_name, [&context] {
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 should have a macro to get this name, rather than assuming folks know to suffix _singleton_name.

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.

+1 please put in singleton.h and +1 to macro for getting name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread include/envoy/singleton/instance.h Outdated

typedef std::shared_ptr<Instance> InstanceSharedPtr;

/**
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.

nit: IMO this should go in manager.h, but I don't feel that strongly about it if you prefer it here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@mattklein123 Makes sense with the RegistrationImpl being here.

@mattklein123 mattklein123 merged commit fc1097e into master Aug 17, 2017
@mattklein123 mattklein123 deleted the singleton-manager-route-config branch August 17, 2017 01:25
mathetake pushed a commit that referenced this pull request Mar 3, 2026
**Description**

This allows configuring the header where api credentials will be
injected when talking to the upstream MCP servers. Previously, we could
only inject Bearer token credentials, but some MCP servers require them
to be on a different header. With this change users can configure the
header like in the following example:

```yaml
apiVersion: aigateway.envoyproxy.io/v1alpha1
kind: MCPRoute
metadata:
  name: mcp-route
  namespace: default
spec:
  parentRefs:
    - name: aigw-run
      kind: Gateway
      group: gateway.networking.k8s.io
  path: "/mcp"
  backendRefs:
    - name: mcp-backend
      kind: Backend
      group: gateway.envoyproxy.io
      securityPolicy:
        apiKey:
          header: "X-Api-Key"
          secretRef:
            name: apikey-secret

```

**Related Issues/PRs (if applicable)**

N/A

**Special notes for reviewers (if applicable)**

N/A

---------

Signed-off-by: Ignasi Barrera <ignasi@tetrate.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants