Skip to content
Closed
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
899ec21
Init work with configuration proposition
Aug 12, 2019
6da905d
Added missing dependency
Aug 31, 2019
8eb6f82
Merge branch 'master' into local_reply_mapper
Aug 31, 2019
9bf0e6b
Without passed config
Aug 31, 2019
fc3c545
WIP config
Sep 2, 2019
c9a686e
Response flags added
Sep 3, 2019
4213f2e
Applied changes from code review
Sep 4, 2019
f8df3ae
repeated match
Sep 4, 2019
dac4695
Merge branch 'master' into local_reply_mapper
Sep 7, 2019
052aeeb
WIP local reply formatter with access log reuse
Sep 7, 2019
1499746
Merge branch 'master' into local_reply_mapper
Sep 13, 2019
8f022b6
Added mapper config
Sep 15, 2019
419a59c
Changed to access log filter
Sep 18, 2019
468308a
Merge branch 'master' into local_reply_mapper
Sep 19, 2019
1cce878
Cleanup and initial work docs
Sep 19, 2019
1efc2e3
Cleanup and initial work docs
Sep 19, 2019
7c75f6c
added comments
Sep 20, 2019
2670d0f
Added possibility to define custom format for each mapper
Sep 26, 2019
955bf79
Merge branch 'master' into local_reply_mapper
Sep 26, 2019
cd31254
Extracted new format StringOrJson
Sep 27, 2019
a77c82f
Removed docs and fixed format. I will provide docs file with implemen…
Oct 1, 2019
20abff0
Merge branch 'master' into local_reply_mapper
Oct 2, 2019
9c8d757
Added more docs
Oct 2, 2019
cc55bb4
Merge branch 'master' into local_reply_mapper
Oct 4, 2019
7784130
Code review fix
Oct 4, 2019
31f3cbf
Merge branch 'master' into local_reply_mapper
Oct 10, 2019
5eadeca
Fix build
Oct 11, 2019
199dd43
Merge branch 'master' into local_reply_mapper
Oct 11, 2019
0aee07a
Generated v3 files
Oct 11, 2019
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
2 changes: 2 additions & 0 deletions api/envoy/config/filter/accesslog/v2/accesslog.proto
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ message AccessLog {
}
}

// [#next-major-version: In the v3 API, we should consider renaming
// it to more generic filter]
message AccessLogFilter {
oneof filter_specifier {
option (validate.required) = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ api_proto_library_internal(
"//envoy/api/v2/core:config_source",
"//envoy/api/v2/core:protocol",
"//envoy/config/filter/accesslog/v2:accesslog",
"//envoy/type:format",
"//envoy/type:percent",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import "envoy/api/v2/rds.proto";
import "envoy/api/v2/srds.proto";
import "envoy/config/filter/accesslog/v2/accesslog.proto";
import "envoy/type/percent.proto";
import "envoy/type/format.proto";

import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
Expand All @@ -23,7 +24,7 @@ import "validate/validate.proto";
// [#protodoc-title: HTTP connection manager]
// HTTP connection manager :ref:`configuration overview <config_http_conn_man>`.

// [#comment:next free field: 35]
// [#comment:next free field: 36]
message HttpConnectionManager {
enum CodecType {
// For every new connection, the connection manager will determine which
Expand Down Expand Up @@ -456,6 +457,37 @@ message HttpConnectionManager {
// with `prefix` match set to `/dir`. Defaults to `false`. Note that slash merging is not part of
// `HTTP spec <https://tools.ietf.org/html/rfc3986>` and is provided for convenience.
bool merge_slashes = 33;

// [#not-implemented-hide:]
// Configuration of local reply returned by Envoy. Allows to specify mappings and format of
// response.
LocalReplyConfig local_reply_config = 35;

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.

Should LocalReplyConfig be one-per ResponseMapper? What's the tradeoff here?

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 think LocalReplyConfig should be one by http_conn_manager, but we can define many Mappers. The tradeoff is that you can define only one format per manager. So if you want to define custom format for different response it won't be possible.

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.

If we think that there might be possibly a use case here for multiple custom format, I'd just allow it in the API; the implementation can probably deal with this without too much complexity. I.e. let's be really sure that one format will be sufficient forever if we take the existing design.

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 added possibility to define format for each mapper. I think about implementation: if mapper format is defined then use mapper format else use format from config (or default if not defined)

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.

Given the way you added it, it seems we could punt this until later, if you really want to keep the top-level reply_format. So, I'd either rollback that change or remove the top-level reply_format; I gather you want it though to reduce verbosity if you have many rewriters?

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.

Yes I thought it might be good idea to define one format at top-level and allow to define custom one for each mapper if someone want different format. I can also remove top level mapper but if someone want to change the format of all responses it will require definition of mapper without filter/rewriter.

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.

OK, given that, maybe just completely ignore the above thread and rollback the per-rewriter bits, since they can be added in a non-breaking way later additively. It'll simplify the implementation work at your end. Sorry about the confusion, the PR clarified how this would look, thanks.

}

message LocalReplyConfig {
// Configuration of list of mappers which allows to filter and change local response.
// Code iterate through mappers until first match of filter.

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: "The client will iterate through mappers..`

repeated ResponseMapper mapper = 1;

// Allows to define custom format of local reply.
type.StringOrJson format = 2;
};

message ResponseMapper {
// Filter is used to determine if the response should be changed.
envoy.config.filter.accesslog.v2.AccessLogFilter filter = 1
[(validate.rules).message.required = true];

// Rewriter defines which values in local reply should be changed.
ResponseRewriter rewriter = 2 [(validate.rules).message.required = true];
}

// Configuration of new value for matched local response.
message ResponseRewriter {
// Status code for matched response.
google.protobuf.UInt32Value status_code = 1;

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.

Can this just be uint32?

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 think it will be good to keep this field optional if in future someone want to add e.g: headers, body.


// TODO: add support for GRPC rewrite.
}

message Rds {
Expand Down
6 changes: 6 additions & 0 deletions api/envoy/type/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ api_proto_package(
name = "type",
)

api_proto_library_internal(
name = "format",
srcs = ["format.proto"],
visibility = ["//visibility:public"],
)

api_proto_library_internal(
name = "http_status",
srcs = ["http_status.proto"],
Expand Down
20 changes: 20 additions & 0 deletions api/envoy/type/format.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package envoy.type;

option java_outer_classname = "FormatProto";
option java_multiple_files = true;
option java_package = "io.envoyproxy.envoy.type";

import "google/protobuf/struct.proto";

message StringOrJson {
// Allows to define custom format of returned data.
oneof format {
// Plain text format.

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.

In the final version of the PR can you flesh these docs out to cross-link to the format rules, etc.? It's not super clear how the user is supposed to fill these fields out. Thank you!

/wait

string string_format = 2;

// Json format as dictionary.
google.protobuf.Struct json_format = 3;
}
}
1 change: 1 addition & 0 deletions tools/spelling_dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ resolvers
resync
ret
retriable
rewriter
rpcs
rq
rtrim
Expand Down