From f7cc7ff5cdf1ba23427c068b044ad6c1019fc629 Mon Sep 17 00:00:00 2001 From: Eric Date: Fri, 4 Mar 2022 16:41:23 -0500 Subject: [PATCH 1/2] Add `Meta` to `ServiceConfigResponse` --- .changelog/12529.txt | 3 +++ agent/consul/config_endpoint.go | 2 ++ agent/consul/config_endpoint_test.go | 3 +++ agent/structs/config_entry.go | 1 + 4 files changed, 9 insertions(+) create mode 100644 .changelog/12529.txt diff --git a/.changelog/12529.txt b/.changelog/12529.txt new file mode 100644 index 0000000000..15368df153 --- /dev/null +++ b/.changelog/12529.txt @@ -0,0 +1,3 @@ +```release-note:feature +server: Ensure that service-defaults `Meta` to is included in `ServiceConfigResponse`. +``` diff --git a/agent/consul/config_endpoint.go b/agent/consul/config_endpoint.go index 3cb93c4d25..063d4412b4 100644 --- a/agent/consul/config_endpoint.go +++ b/agent/consul/config_endpoint.go @@ -591,6 +591,8 @@ func (c *ConfigEntry) computeResolvedServiceConfig( if serviceConf.Mode != structs.ProxyModeDefault { thisReply.Mode = serviceConf.Mode } + + thisReply.Meta = serviceConf.Meta } // First collect all upstreams into a set of seen upstreams. diff --git a/agent/consul/config_endpoint_test.go b/agent/consul/config_endpoint_test.go index b5778b8234..f9e1e310de 100644 --- a/agent/consul/config_endpoint_test.go +++ b/agent/consul/config_endpoint_test.go @@ -1029,10 +1029,12 @@ func TestConfigEntry_ResolveServiceConfig(t *testing.T) { "foo": 1, }, })) + meta := map[string]string{"foo": "bar"} require.NoError(t, state.EnsureConfigEntry(2, &structs.ServiceConfigEntry{ Kind: structs.ServiceDefaults, Name: "foo", Protocol: "http", + Meta: meta, })) require.NoError(t, state.EnsureConfigEntry(2, &structs.ServiceConfigEntry{ Kind: structs.ServiceDefaults, @@ -1058,6 +1060,7 @@ func TestConfigEntry_ResolveServiceConfig(t *testing.T) { "protocol": "grpc", }, }, + Meta: meta, // Don't know what this is deterministically QueryMeta: out.QueryMeta, } diff --git a/agent/structs/config_entry.go b/agent/structs/config_entry.go index 4f7ec4cd77..f7b82d80fd 100644 --- a/agent/structs/config_entry.go +++ b/agent/structs/config_entry.go @@ -985,6 +985,7 @@ type ServiceConfigResponse struct { Expose ExposeConfig `json:",omitempty"` TransparentProxy TransparentProxyConfig `json:",omitempty"` Mode ProxyMode `json:",omitempty"` + Meta map[string]string QueryMeta } From 9d0ec2eec249685c2b78c18d9ea679e871d472b4 Mon Sep 17 00:00:00 2001 From: Eric Haberkorn Date: Mon, 7 Mar 2022 14:35:33 -0500 Subject: [PATCH 2/2] Code review changes --- .changelog/12529.txt | 2 +- agent/consul/config_endpoint_test.go | 5 ++--- agent/structs/config_entry.go | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.changelog/12529.txt b/.changelog/12529.txt index 15368df153..c4ebe87e52 100644 --- a/.changelog/12529.txt +++ b/.changelog/12529.txt @@ -1,3 +1,3 @@ ```release-note:feature -server: Ensure that service-defaults `Meta` to is included in `ServiceConfigResponse`. +server: Ensure that service-defaults `Meta` is returned with the response to the `ConfigEntry.ResolveServiceConfig` RPC. ``` diff --git a/agent/consul/config_endpoint_test.go b/agent/consul/config_endpoint_test.go index f9e1e310de..e5c0b7f6df 100644 --- a/agent/consul/config_endpoint_test.go +++ b/agent/consul/config_endpoint_test.go @@ -1029,12 +1029,11 @@ func TestConfigEntry_ResolveServiceConfig(t *testing.T) { "foo": 1, }, })) - meta := map[string]string{"foo": "bar"} require.NoError(t, state.EnsureConfigEntry(2, &structs.ServiceConfigEntry{ Kind: structs.ServiceDefaults, Name: "foo", Protocol: "http", - Meta: meta, + Meta: map[string]string{"foo": "bar"}, })) require.NoError(t, state.EnsureConfigEntry(2, &structs.ServiceConfigEntry{ Kind: structs.ServiceDefaults, @@ -1060,7 +1059,7 @@ func TestConfigEntry_ResolveServiceConfig(t *testing.T) { "protocol": "grpc", }, }, - Meta: meta, + Meta: map[string]string{"foo": "bar"}, // Don't know what this is deterministically QueryMeta: out.QueryMeta, } diff --git a/agent/structs/config_entry.go b/agent/structs/config_entry.go index f7b82d80fd..4ca0ee6317 100644 --- a/agent/structs/config_entry.go +++ b/agent/structs/config_entry.go @@ -985,7 +985,7 @@ type ServiceConfigResponse struct { Expose ExposeConfig `json:",omitempty"` TransparentProxy TransparentProxyConfig `json:",omitempty"` Mode ProxyMode `json:",omitempty"` - Meta map[string]string + Meta map[string]string `json:",omitempty"` QueryMeta }