Skip to content

rds: allow v1 rds config to use a v2 subscription#1583

Merged
htuch merged 3 commits intomasterfrom
configurable-config-source
Sep 1, 2017
Merged

rds: allow v1 rds config to use a v2 subscription#1583
htuch merged 3 commits intomasterfrom
configurable-config-source

Conversation

@junr03
Copy link
Copy Markdown
Member

@junr03 junr03 commented Aug 31, 2017

Right now if envoy is configured with a v1 base configuration, the xDS APIs are only enabled to use a v1 REST subscription. This change allows a v1 rds configuration to get a v2 subscription (both REST and gRPC).

@junr03
Copy link
Copy Markdown
Member Author

junr03 commented Aug 31, 2017

@htuch per your recommendation the change is not documented, as to not push folks to start using V2.

Also in terms of testing this change, should I move the translateApiConfigSource function into the Utility namespace, make it static, and create a test for it?

@mattklein123
Copy link
Copy Markdown
Member

Please add this to v1 docs. It doesn't need to be verbose but you can link to proto in envoy-api repo.

@mattklein123
Copy link
Copy Markdown
Member

If we don't want to add docs, then please add a TODO for yourself to doc later.

@htuch
Copy link
Copy Markdown
Member

htuch commented Aug 31, 2017 via email

@mattklein123
Copy link
Copy Markdown
Member

Yup that's fine. Let's just add TODO for missing docs.

envoy::api::v2::ConfigSource& eds_config) {
translateApiConfigSource(json_config.getObject("cluster")->getString("name"),
json_config.getInteger("refresh_delay_ms", 30000),
json_config.getString("api_type", "REST_LEGACY"),
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.

Make "REST_LEGACY" a const somewhere. And also yes please make the above some static utility function w/ tests.

@junr03
Copy link
Copy Markdown
Member Author

junr03 commented Sep 1, 2017

@mattklein123 @htuch updated.

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.

looks good, small nit.

return {ALL_SUBSCRIPTION_STATS(POOL_COUNTER(scope))};
}

static const std::string REST_LEGACY;
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: This should use the const singleton pattern. See Http::Headers

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.

Sorry, I am confused about this. If declare and initialize like in source/common/http/headers.h with curly brace initialization the compiler complains about in-class initialization of static data member of non-literal type, but of course I can't make them non-static because I would be using the variable in a static member function. What am I missing?

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.

You create a class with non-static members, and then access it via the static get() in https://github.com/lyft/envoy/blob/master/source/common/common/singleton.h.

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.

ah gotcha, that pattern!

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.

Nice this makes it better. I knew I had seen this as the Const counter part to the mutable singleton, should have scrolled to the end of the file. Another tool in the toolshed 👍

htuch
htuch previously approved these changes Sep 1, 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 with the exception of outstanding comments.

api_config_source.set_api_type(envoy::api::v2::ApiConfigSource::REST_LEGACY);
} else if (api_type == REST) {
api_config_source.set_api_type(envoy::api::v2::ApiConfigSource::REST);
} else if (api_type == GRPC) {
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.

This should probably be:

} else {
  ASERT(api_type == GRPC);
  ...
}

since the JSON schema knows this is an enum and has validated.

@junr03
Copy link
Copy Markdown
Member Author

junr03 commented Sep 1, 2017

@mattklein123 @htuch should be ready.

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. thanks

@htuch htuch merged commit f8dbb06 into master Sep 1, 2017
@htuch htuch deleted the configurable-config-source branch September 1, 2017 20:55
htuch pushed a commit that referenced this pull request Nov 22, 2017
cds: allow v1 config to define api_type in the json-schema

Description: #1583 enabled v1 bootstrap configs to define the api type of the management server. This PR adds that constraint to the CDS definition schema.

Risk Level: Low

Testing: existing utility tests test the translation; existing tests test that a v2 grpc cds server can be used.

Signed-off-by: Jose Nino <jnino@lyft.com>
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: API for addDnsQueryTimeoutSeconds to configure behavior introduced in #1580
Risk Level: low - optional builder API
Testing: updated suite.
Docs Changes: added

Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Description: API for addDnsQueryTimeoutSeconds to configure behavior introduced in #1580
Risk Level: low - optional builder API
Testing: updated suite.
Docs Changes: added

Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.com>
mathetake added a commit that referenced this pull request Mar 3, 2026
…tor (#1583)

**Description**

This moves translator.LLMTokenUsage struct into metrics package from
translator package to make sure that all call site of metrics interface
uses the same signature by simply passing the cost info from translator.
This will help unify all the per-endpoint implementation detail.

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

Preparation for #90

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
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