From bc445153f043f80448bf7657c01e004d7b82a0ba Mon Sep 17 00:00:00 2001 From: Dhia Ayachi Date: Thu, 29 Aug 2024 17:45:14 +0000 Subject: [PATCH] backport of commit a81f54b74c9a0d60ea5944bb47816b7f70d86012 --- .changelog/565.txt | 3 - .changelog/571.txt | 9 - .changelog/595.txt | 7 - .github/workflows/build.yml | 4 +- .github/workflows/security-scan.yml | 5 +- CHANGELOG.md | 7 + Makefile | 1 - cmd/consul-dataplane/config.go | 3 - cmd/consul-dataplane/config_test.go | 10 - cmd/consul-dataplane/main.go | 24 +-- go.mod | 15 +- go.sum | 40 ++-- integration-tests/go.mod | 1 + integration-tests/go.sum | 4 +- .../mocks/pbdnsmock/dns_service_client.go | 6 +- .../mocks/pbdnsmock/dns_service_server.go | 6 +- .../is_cloning_dns_service_client.go | 6 +- .../pbdnsmock/unsafe_dns_service_server.go | 2 +- .../is_cloning_resource_service_client.go | 6 +- .../pbresourcemock/is_watch_event__event.go | 29 --- .../resource_service__watch_list_client.go | 30 +-- .../resource_service__watch_list_server.go | 26 +-- .../pbresourcemock/resource_service_client.go | 34 +-- .../pbresourcemock/resource_service_server.go | 34 +-- .../mocks/pbresourcemock/server_stream.go | 30 +-- .../unsafe_resource_service_server.go | 2 +- pkg/consuldp/bootstrap.go | 70 ++++-- pkg/consuldp/bootstrap_test.go | 119 ++++++++++- pkg/consuldp/config.go | 17 +- pkg/consuldp/consul_dataplane.go | 75 ++----- pkg/consuldp/consul_dataplane_test.go | 200 ++---------------- pkg/consuldp/xds.go | 2 +- pkg/dns/dns.go | 6 - pkg/version/version.go | 2 +- 34 files changed, 270 insertions(+), 565 deletions(-) delete mode 100644 .changelog/565.txt delete mode 100644 .changelog/571.txt delete mode 100644 .changelog/595.txt delete mode 100644 internal/mocks/pbresourcemock/is_watch_event__event.go diff --git a/.changelog/565.txt b/.changelog/565.txt deleted file mode 100644 index 48a1e3db..00000000 --- a/.changelog/565.txt +++ /dev/null @@ -1,3 +0,0 @@ -```release-note:feature -Removes the dependence on the v2 catalog and "resource-apis" experiment. -``` diff --git a/.changelog/571.txt b/.changelog/571.txt deleted file mode 100644 index 34ec25f5..00000000 --- a/.changelog/571.txt +++ /dev/null @@ -1,9 +0,0 @@ -```release-note:feature -Added the ability to set the `-mode` flag. Options available are `sidecar` and `dns-proxy`. The system defaults to `sidecar`. -When set to `sidecar`: -- DNS Server, xDS Server, and Envoy are enabled. -- The system validates that `-consul-dns-bind-addr` and equivalent environment variable must be set to the loopback address. -When set to `dns-proxy`: -- Only DNS Server is enabled. xDS Server and Envoy are disabled. -- `consul-dns-bind-addr` and equivalent environment variable can be set to other values besides the loopback address. -``` \ No newline at end of file diff --git a/.changelog/595.txt b/.changelog/595.txt deleted file mode 100644 index 677ff862..00000000 --- a/.changelog/595.txt +++ /dev/null @@ -1,7 +0,0 @@ -```release-note:enhancement -Update `github.com/hashicorp/consul-server-connection-manager` to v0.1.9. -``` - -```release-note:enhancement -Update `github.com/hashicorp/go-hclog` to v1.5.0. -``` \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 42b38b49..2faf128b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -335,12 +335,12 @@ jobs: server: - version: v1.15.0-dev image: hashicorppreview/consul:1.15-dev + - version: v1.17.0-dev + image: hashicorppreview/consul:1.17-dev - version: v1.18.0-dev image: hashicorppreview/consul:1.18-dev - version: v1.19.0-dev image: hashicorppreview/consul:1.19-dev - - version: v1.20.0-dev - image: hashicorppreview/consul:1.20-dev dataplane: - image_suffix: "" docker_target: "release-default" diff --git a/.github/workflows/security-scan.yml b/.github/workflows/security-scan.yml index bb1da12c..6bacdfd5 100644 --- a/.github/workflows/security-scan.yml +++ b/.github/workflows/security-scan.yml @@ -46,7 +46,8 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 with: repository: hashicorp/security-scanner - token: ${{ secrets.HASHIBOT_PRODSEC_GITHUB_TOKEN }} + #TODO: replace w/ HASHIBOT_PRODSEC_GITHUB_TOKEN once provisioned + token: ${{ secrets.ELEVATED_GITHUB_TOKEN }} path: security-scanner ref: main @@ -65,4 +66,4 @@ jobs: - name: Upload SARIF file uses: github/codeql-action/upload-sarif@c4fb451437765abf5018c6fbf22cce1a7da1e5cc # codeql-bundle-v2.17.1 with: - sarif_file: results.sarif + sarif_file: results.sarif \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 98e15868..49289561 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.5.1 (July 15, 2024) + +SECURITY: + +* Upgrade envoy version to 1.29.7 to address [CVE-2024-39305](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-39305) [[GH-578](https://github.com/hashicorp/consul-dataplane/pull/578)] +* Upgrade go version to address [CVE-2024-24791](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-24791) [[GH-573](https://github.com/hashicorp/consul-dataplane/pull/573)] + ## 1.5.0 (June 12, 2024) IMPROVEMENTS: diff --git a/Makefile b/Makefile index 0bb2e2bc..ada7c187 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,6 @@ docker-run: docker ## run the image of $(TAG) .PHONY: dev-docker dev-docker: docker ## build docker image and tag the image to local - echo '$(ARCH)' docker tag '$(PRODUCT_NAME):$(VERSION)' '$(PRODUCT_NAME):local' ##@ Testing diff --git a/cmd/consul-dataplane/config.go b/cmd/consul-dataplane/config.go index 3db53e3c..1823ddd4 100644 --- a/cmd/consul-dataplane/config.go +++ b/cmd/consul-dataplane/config.go @@ -21,7 +21,6 @@ type FlagOpts struct { } type DataplaneConfigFlags struct { - Mode *string `json:"mode,omitempty"` Consul ConsulFlags `json:"consul,omitempty"` Service ServiceFlags `json:"service,omitempty"` Proxy ProxyFlags `json:"proxy,omitempty"` @@ -210,7 +209,6 @@ func (f *FlagOpts) buildConfigFromFile() (DataplaneConfigFlags, error) { func buildDefaultConsulDPFlags() (DataplaneConfigFlags, error) { data := ` { - "mode": "sidecar", "consul": { "grpcPort": 8502, "serverWatchDisabled": false, @@ -318,7 +316,6 @@ func constructRuntimeConfig(cfg DataplaneConfigFlags, extraArgs []string) (*cons InsecureSkipVerify: boolVal(cfg.Consul.TLS.InsecureSkipVerify), }, }, - Mode: consuldp.ModeType(stringVal(cfg.Mode)), Proxy: &proxyCfg, Logging: &consuldp.LoggingConfig{ Name: DefaultLogName, diff --git a/cmd/consul-dataplane/config_test.go b/cmd/consul-dataplane/config_test.go index 01553f67..25859065 100644 --- a/cmd/consul-dataplane/config_test.go +++ b/cmd/consul-dataplane/config_test.go @@ -33,7 +33,6 @@ func TestConfigGeneration(t *testing.T) { }, makeExpectedCfg: func(flagOpts *FlagOpts) *consuldp.Config { return &consuldp.Config{ - Mode: consuldp.ModeTypeSidecar, Consul: &consuldp.ConsulConfig{ Addresses: stringVal(flagOpts.dataplaneConfig.Consul.Addresses), GRPCPort: intVal(flagOpts.dataplaneConfig.Consul.GRPCPort), @@ -112,7 +111,6 @@ func TestConfigGeneration(t *testing.T) { }, makeExpectedCfg: func(flagOpts *FlagOpts) *consuldp.Config { return &consuldp.Config{ - Mode: consuldp.ModeTypeSidecar, Consul: &consuldp.ConsulConfig{ Addresses: stringVal(flagOpts.dataplaneConfig.Consul.Addresses), GRPCPort: intVal(flagOpts.dataplaneConfig.Consul.GRPCPort), @@ -191,7 +189,6 @@ func TestConfigGeneration(t *testing.T) { if err != nil { return nil, err } - opts.dataplaneConfig.Mode = strReference("dns-proxy") opts.dataplaneConfig.Consul.Credentials.Login.BearerTokenPath = strReference("/consul/bearertokenpath/") opts.dataplaneConfig.Consul.Credentials.Login.Datacenter = strReference("dc100") opts.dataplaneConfig.Consul.Credentials.Login.Meta = map[string]string{ @@ -209,7 +206,6 @@ func TestConfigGeneration(t *testing.T) { }, makeExpectedCfg: func(flagOpts *FlagOpts) *consuldp.Config { return &consuldp.Config{ - Mode: consuldp.ModeTypeDNSProxy, Consul: &consuldp.ConsulConfig{ Addresses: stringVal(flagOpts.dataplaneConfig.Consul.Addresses), GRPCPort: intVal(flagOpts.dataplaneConfig.Consul.GRPCPort), @@ -314,7 +310,6 @@ func TestConfigGeneration(t *testing.T) { }, makeExpectedCfg: func(flagOpts *FlagOpts) *consuldp.Config { return &consuldp.Config{ - Mode: consuldp.ModeTypeSidecar, Consul: &consuldp.ConsulConfig{ Addresses: stringVal(flagOpts.dataplaneConfig.Consul.Addresses), GRPCPort: intVal(flagOpts.dataplaneConfig.Consul.GRPCPort), @@ -413,7 +408,6 @@ func TestConfigGeneration(t *testing.T) { }, makeExpectedCfg: func(flagOpts *FlagOpts) *consuldp.Config { return &consuldp.Config{ - Mode: consuldp.ModeTypeSidecar, Consul: &consuldp.ConsulConfig{ Addresses: stringVal(flagOpts.dataplaneConfig.Consul.Addresses), GRPCPort: intVal(flagOpts.dataplaneConfig.Consul.GRPCPort), @@ -527,7 +521,6 @@ func TestConfigGeneration(t *testing.T) { }, makeExpectedCfg: func(flagOpts *FlagOpts) *consuldp.Config { return &consuldp.Config{ - Mode: consuldp.ModeTypeSidecar, Consul: &consuldp.ConsulConfig{ Addresses: "consul_server.dc1", GRPCPort: 8502, @@ -634,7 +627,6 @@ func TestConfigGeneration(t *testing.T) { }, makeExpectedCfg: func(flagOpts *FlagOpts) *consuldp.Config { return &consuldp.Config{ - Mode: consuldp.ModeTypeSidecar, Consul: &consuldp.ConsulConfig{ Addresses: stringVal(flagOpts.dataplaneConfig.Consul.Addresses), GRPCPort: intVal(flagOpts.dataplaneConfig.Consul.GRPCPort), @@ -714,7 +706,6 @@ func TestConfigGeneration(t *testing.T) { desc: "test whether CLI flag values override the file values with proxy flags", flagOpts: func() (*FlagOpts, error) { opts, err := generateFlagOptsWithProxyFlags() - opts.dataplaneConfig.Mode = strReference("dns-proxy") if err != nil { return nil, err } @@ -763,7 +754,6 @@ func TestConfigGeneration(t *testing.T) { }, makeExpectedCfg: func(flagOpts *FlagOpts) *consuldp.Config { return &consuldp.Config{ - Mode: consuldp.ModeTypeDNSProxy, Consul: &consuldp.ConsulConfig{ Addresses: stringVal(flagOpts.dataplaneConfig.Consul.Addresses), GRPCPort: intVal(flagOpts.dataplaneConfig.Consul.GRPCPort), diff --git a/cmd/consul-dataplane/main.go b/cmd/consul-dataplane/main.go index 9afac615..ca74a195 100644 --- a/cmd/consul-dataplane/main.go +++ b/cmd/consul-dataplane/main.go @@ -27,10 +27,6 @@ func init() { flagOpts = &FlagOpts{} flags.BoolVar(&flagOpts.printVersion, "version", false, "Prints the current version of consul-dataplane.") - StringVar(flags, &flagOpts.dataplaneConfig.Mode, "mode", "DP_MODE", "dataplane mode. Value can be:\n"+ - "1. sidecar - used when running as a sidecar to Consul services with xDS Server, Envoy, and DNS Server running; OR\n"+ - "2. dns-proxy - used when running as a standalone application where DNS Server runs, but Envoy and xDS Server are enabled.\n") - StringVar(flags, &flagOpts.dataplaneConfig.Consul.Addresses, "addresses", "DP_CONSUL_ADDRESSES", "Consul server gRPC addresses. Value can be:\n"+ "1. A DNS name that resolves to server addresses or the DNS name of a load balancer in front of the Consul servers; OR\n"+ "2. An executable command in the format, 'exec='. The executable\n"+ @@ -61,17 +57,21 @@ func init() { "[Deprecated; use -proxy-partition instead] The Consul Enterprise partition in which the proxy service instance is registered.") StringVar(flags, &flagOpts.dataplaneConfig.Proxy.NodeName, "proxy-node-name", "DP_PROXY_NODE_NAME", - "The name of the Consul node to which the proxy service instance is registered.") + "The name of the Consul node to which the proxy service instance is registered."+ + "In Consul's V2 Catalog API, this value is ignored.") StringVar(flags, &flagOpts.dataplaneConfig.Proxy.NodeID, "proxy-node-id", "DP_PROXY_NODE_ID", - "The ID of the Consul node to which the proxy service instance is registered.") + "The ID of the Consul node to which the proxy service instance is registered."+ + "In Consul's V2 Catalog API, this value is ignored.") StringVar(flags, &flagOpts.dataplaneConfig.Proxy.ID, "proxy-id", "DP_PROXY_ID", - "In Consul's V1 Catalog API, the proxy service instance's ID.") + "In Consul's V1 Catalog API, the proxy service instance's ID."+ + "In Consul's V2 Catalog API, the workload ID associated with the proxy.") StringVar(flags, &flagOpts.dataplaneConfig.Proxy.IDPath, "proxy-id-path", "DP_PROXY_ID_PATH", - "In Consul's V1 Catalog API, the path to a file containing the proxy service instance's ID.") + "In Consul's V1 Catalog API, the path to a file containing the proxy service instance's ID."+ + "In Consul's V2 Catalog API, the path to a file containing the workload ID associated with the proxy.") StringVar(flags, &flagOpts.dataplaneConfig.Proxy.Namespace, "proxy-namespace", "DP_PROXY_NAMESPACE", - "The Consul Enterprise namespace in which the proxy service instance is registered.") + "The Consul Enterprise namespace in which the proxy service instance (V1 API) or workload (V2 API) is registered.") StringVar(flags, &flagOpts.dataplaneConfig.Proxy.Partition, "proxy-partition", "DP_PROXY_PARTITION", - "The Consul Enterprise partition in which the proxy service instance is registered.") + "The Consul Enterprise partition in which the proxy service instance (V1 API) or workload (V2 API) is registered.") StringVar(flags, &flagOpts.dataplaneConfig.Consul.Credentials.Type, "credential-type", "DP_CREDENTIAL_TYPE", "The type of credentials, either static or login, used to authenticate with Consul servers.") StringVar(flags, &flagOpts.dataplaneConfig.Consul.Credentials.Static.Token, "static-token", "DP_CREDENTIAL_STATIC_TOKEN", "The ACL token used to authenticate requests to Consul servers when -credential-type is set to static.") @@ -111,8 +111,8 @@ func init() { StringVar(flags, &flagOpts.dataplaneConfig.Consul.TLS.ServerName, "tls-server-name", "DP_TLS_SERVER_NAME", "The hostname to expect in the server certificate's subject. This is required if -addresses is not a DNS name.") BoolVar(flags, &flagOpts.dataplaneConfig.Consul.TLS.InsecureSkipVerify, "tls-insecure-skip-verify", "DP_TLS_INSECURE_SKIP_VERIFY", "Do not verify the server's certificate. Useful for testing, but not recommended for production.") - StringVar(flags, &flagOpts.dataplaneConfig.DNSServer.BindAddr, "consul-dns-bind-addr", "DP_CONSUL_DNS_BIND_ADDR", "The address that will be bound to the consul dns listener.") - IntVar(flags, &flagOpts.dataplaneConfig.DNSServer.BindPort, "consul-dns-bind-port", "DP_CONSUL_DNS_BIND_PORT", "The port the consul dns listener will listen on. By default -1 disables the dns listener.") + StringVar(flags, &flagOpts.dataplaneConfig.DNSServer.BindAddr, "consul-dns-bind-addr", "DP_CONSUL_DNS_BIND_ADDR", "The address that will be bound to the consul dns proxy.") + IntVar(flags, &flagOpts.dataplaneConfig.DNSServer.BindPort, "consul-dns-bind-port", "DP_CONSUL_DNS_BIND_PORT", "The port the consul dns proxy will listen on. By default -1 disables the dns proxy") // Default is false because it will generally be configured appropriately by Helm // configuration or pod annotation. diff --git a/go.mod b/go.mod index c2e3bdea..c1902546 100644 --- a/go.mod +++ b/go.mod @@ -6,14 +6,14 @@ require ( dario.cat/mergo v1.0.0 github.com/armon/go-metrics v0.4.1 github.com/hashi-derek/grpc-proxy v0.0.0-20231207191910-191266484d75 - github.com/hashicorp/consul-server-connection-manager v0.1.9 + github.com/hashicorp/consul-server-connection-manager v0.1.6 github.com/hashicorp/consul/proto-public v0.6.2 - github.com/hashicorp/go-hclog v1.5.0 + github.com/hashicorp/go-hclog v1.2.2 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-rootcerts v1.0.2 github.com/mitchellh/mapstructure v1.5.0 github.com/prometheus/client_golang v1.13.0 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.8.4 google.golang.org/grpc v1.56.3 google.golang.org/protobuf v1.33.0 ) @@ -24,21 +24,22 @@ require ( github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/fatih/color v1.16.0 // indirect + github.com/fatih/color v1.13.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-immutable-radix v1.0.0 // indirect github.com/hashicorp/go-netaddrs v0.1.0 // indirect + github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/golang-lru v0.5.1 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-colorable v0.1.12 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.37.0 // indirect github.com/prometheus/procfs v0.8.0 // indirect - github.com/stretchr/objx v0.5.2 // indirect + github.com/stretchr/objx v0.5.0 // indirect golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect golang.org/x/net v0.24.0 // indirect golang.org/x/sync v0.3.0 // indirect diff --git a/go.sum b/go.sum index e5f4e6ec..2893bab1 100644 --- a/go.sum +++ b/go.sum @@ -72,9 +72,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= -github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -146,17 +145,19 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/hashi-derek/grpc-proxy v0.0.0-20231207191910-191266484d75 h1:V5Uqf7VoWMd6UhNf/5EMA8LMPUm95GYvk2YF5SzT24o= github.com/hashi-derek/grpc-proxy v0.0.0-20231207191910-191266484d75/go.mod h1:5eEnHfK72jOkp4gC1dI/Q/E9MFNOM/ewE/vql5ijV3g= -github.com/hashicorp/consul-server-connection-manager v0.1.9 h1:jHO10v0Hk/WE05qz1gnUDd9WPQEFf5e2bP1Gs+s56rA= -github.com/hashicorp/consul-server-connection-manager v0.1.9/go.mod h1:rsVRioiTxfyh4yXcEnm1Lb9RrzJl0Lz08+nLgdlZR2I= +github.com/hashicorp/consul-server-connection-manager v0.1.6 h1:ktj8Fi+dRXn9hhM+FXsfEJayhzzgTqfH08Ne5M6Fmug= +github.com/hashicorp/consul-server-connection-manager v0.1.6/go.mod h1:HngMIv57MT+pqCVeRQMa1eTB5dqnyMm8uxjyv+Hn8cs= +github.com/hashicorp/consul/proto-public v0.6.1 h1:+uzH3olCrksXYWAYHKqK782CtK9scfqH+Unlw3UHhCg= +github.com/hashicorp/consul/proto-public v0.6.1/go.mod h1:cXXbOg74KBNGajC+o8RlA502Esf0R9prcoJgiOX/2Tg= github.com/hashicorp/consul/proto-public v0.6.2 h1:+DA/3g/IiKlJZb88NBn0ZgXrxJp2NlvCZdEyl+qxvL0= github.com/hashicorp/consul/proto-public v0.6.2/go.mod h1:cXXbOg74KBNGajC+o8RlA502Esf0R9prcoJgiOX/2Tg= -github.com/hashicorp/consul/sdk v0.16.1 h1:V8TxTnImoPD5cj0U9Spl0TUxcytjcbbJeADFF07KdHg= +github.com/hashicorp/consul/sdk v0.13.0 h1:lce3nFlpv8humJL8rNrrGHYSKc3q+Kxfeg3Ii1m6ZWU= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= +github.com/hashicorp/go-hclog v1.2.2 h1:ihRI7YFwcZdiSD7SIenIhHfQH3OuDvWerAUBZbeQS3M= +github.com/hashicorp/go-hclog v1.2.2/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= @@ -167,7 +168,8 @@ github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= @@ -192,14 +194,11 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -257,16 +256,19 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= -github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -420,8 +422,6 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/integration-tests/go.mod b/integration-tests/go.mod index 4c9471ba..ee237a56 100644 --- a/integration-tests/go.mod +++ b/integration-tests/go.mod @@ -35,6 +35,7 @@ require ( github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/serf v0.10.1 // indirect github.com/klauspost/compress v1.11.13 // indirect + github.com/kr/text v0.2.0 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect diff --git a/integration-tests/go.sum b/integration-tests/go.sum index 3302dd74..d2d6eb54 100644 --- a/integration-tests/go.sum +++ b/integration-tests/go.sum @@ -26,6 +26,7 @@ github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp github.com/containerd/containerd v1.6.18 h1:qZbsLvmyu+Vlty0/Ex5xc0z2YtKpIsb5n45mAMI+2Ns= github.com/containerd/containerd v1.6.18/go.mod h1:1RdCUu95+gc2v9t3IL+zIlpClSmew7/0YS8O5eQZrOw= github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -117,8 +118,9 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= diff --git a/internal/mocks/pbdnsmock/dns_service_client.go b/internal/mocks/pbdnsmock/dns_service_client.go index cdde7e82..dbdfb3fa 100644 --- a/internal/mocks/pbdnsmock/dns_service_client.go +++ b/internal/mocks/pbdnsmock/dns_service_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbdnsmock @@ -28,10 +28,6 @@ func (_m *DNSServiceClient) Query(ctx context.Context, in *pbdns.QueryRequest, o _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for Query") - } - var r0 *pbdns.QueryResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbdns.QueryRequest, ...grpc.CallOption) (*pbdns.QueryResponse, error)); ok { diff --git a/internal/mocks/pbdnsmock/dns_service_server.go b/internal/mocks/pbdnsmock/dns_service_server.go index c4cb5013..705aaf63 100644 --- a/internal/mocks/pbdnsmock/dns_service_server.go +++ b/internal/mocks/pbdnsmock/dns_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbdnsmock @@ -18,10 +18,6 @@ type DNSServiceServer struct { func (_m *DNSServiceServer) Query(_a0 context.Context, _a1 *pbdns.QueryRequest) (*pbdns.QueryResponse, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 0 { - panic("no return value specified for Query") - } - var r0 *pbdns.QueryResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbdns.QueryRequest) (*pbdns.QueryResponse, error)); ok { diff --git a/internal/mocks/pbdnsmock/is_cloning_dns_service_client.go b/internal/mocks/pbdnsmock/is_cloning_dns_service_client.go index 6f655bb5..3f817f10 100644 --- a/internal/mocks/pbdnsmock/is_cloning_dns_service_client.go +++ b/internal/mocks/pbdnsmock/is_cloning_dns_service_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbdnsmock @@ -13,10 +13,6 @@ type IsCloningDNSServiceClient struct { func (_m *IsCloningDNSServiceClient) IsCloningDNSServiceClient() bool { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for IsCloningDNSServiceClient") - } - var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/internal/mocks/pbdnsmock/unsafe_dns_service_server.go b/internal/mocks/pbdnsmock/unsafe_dns_service_server.go index 3592b56b..1c385ee7 100644 --- a/internal/mocks/pbdnsmock/unsafe_dns_service_server.go +++ b/internal/mocks/pbdnsmock/unsafe_dns_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbdnsmock diff --git a/internal/mocks/pbresourcemock/is_cloning_resource_service_client.go b/internal/mocks/pbresourcemock/is_cloning_resource_service_client.go index 0cb2619a..65d590f2 100644 --- a/internal/mocks/pbresourcemock/is_cloning_resource_service_client.go +++ b/internal/mocks/pbresourcemock/is_cloning_resource_service_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbresourcemock @@ -13,10 +13,6 @@ type IsCloningResourceServiceClient struct { func (_m *IsCloningResourceServiceClient) IsCloningResourceServiceClient() bool { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for IsCloningResourceServiceClient") - } - var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() diff --git a/internal/mocks/pbresourcemock/is_watch_event__event.go b/internal/mocks/pbresourcemock/is_watch_event__event.go deleted file mode 100644 index 91e3a5ec..00000000 --- a/internal/mocks/pbresourcemock/is_watch_event__event.go +++ /dev/null @@ -1,29 +0,0 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. - -package pbresourcemock - -import mock "github.com/stretchr/testify/mock" - -// isWatchEvent_Event is an autogenerated mock type for the isWatchEvent_Event type -type isWatchEvent_Event struct { - mock.Mock -} - -// isWatchEvent_Event provides a mock function with given fields: -func (_m *isWatchEvent_Event) isWatchEvent_Event() { - _m.Called() -} - -// newIsWatchEvent_Event creates a new instance of isWatchEvent_Event. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func newIsWatchEvent_Event(t interface { - mock.TestingT - Cleanup(func()) -}) *isWatchEvent_Event { - mock := &isWatchEvent_Event{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/internal/mocks/pbresourcemock/resource_service__watch_list_client.go b/internal/mocks/pbresourcemock/resource_service__watch_list_client.go index b2f4e63c..b1b89a9d 100644 --- a/internal/mocks/pbresourcemock/resource_service__watch_list_client.go +++ b/internal/mocks/pbresourcemock/resource_service__watch_list_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbresourcemock @@ -20,10 +20,6 @@ type ResourceService_WatchListClient struct { func (_m *ResourceService_WatchListClient) CloseSend() error { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for CloseSend") - } - var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -38,10 +34,6 @@ func (_m *ResourceService_WatchListClient) CloseSend() error { func (_m *ResourceService_WatchListClient) Context() context.Context { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Context") - } - var r0 context.Context if rf, ok := ret.Get(0).(func() context.Context); ok { r0 = rf() @@ -58,10 +50,6 @@ func (_m *ResourceService_WatchListClient) Context() context.Context { func (_m *ResourceService_WatchListClient) Header() (metadata.MD, error) { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Header") - } - var r0 metadata.MD var r1 error if rf, ok := ret.Get(0).(func() (metadata.MD, error)); ok { @@ -88,10 +76,6 @@ func (_m *ResourceService_WatchListClient) Header() (metadata.MD, error) { func (_m *ResourceService_WatchListClient) Recv() (*pbresource.WatchEvent, error) { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Recv") - } - var r0 *pbresource.WatchEvent var r1 error if rf, ok := ret.Get(0).(func() (*pbresource.WatchEvent, error)); ok { @@ -118,10 +102,6 @@ func (_m *ResourceService_WatchListClient) Recv() (*pbresource.WatchEvent, error func (_m *ResourceService_WatchListClient) RecvMsg(m interface{}) error { ret := _m.Called(m) - if len(ret) == 0 { - panic("no return value specified for RecvMsg") - } - var r0 error if rf, ok := ret.Get(0).(func(interface{}) error); ok { r0 = rf(m) @@ -136,10 +116,6 @@ func (_m *ResourceService_WatchListClient) RecvMsg(m interface{}) error { func (_m *ResourceService_WatchListClient) SendMsg(m interface{}) error { ret := _m.Called(m) - if len(ret) == 0 { - panic("no return value specified for SendMsg") - } - var r0 error if rf, ok := ret.Get(0).(func(interface{}) error); ok { r0 = rf(m) @@ -154,10 +130,6 @@ func (_m *ResourceService_WatchListClient) SendMsg(m interface{}) error { func (_m *ResourceService_WatchListClient) Trailer() metadata.MD { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Trailer") - } - var r0 metadata.MD if rf, ok := ret.Get(0).(func() metadata.MD); ok { r0 = rf() diff --git a/internal/mocks/pbresourcemock/resource_service__watch_list_server.go b/internal/mocks/pbresourcemock/resource_service__watch_list_server.go index 2ff3cd3a..661f2e03 100644 --- a/internal/mocks/pbresourcemock/resource_service__watch_list_server.go +++ b/internal/mocks/pbresourcemock/resource_service__watch_list_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbresourcemock @@ -20,10 +20,6 @@ type ResourceService_WatchListServer struct { func (_m *ResourceService_WatchListServer) Context() context.Context { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Context") - } - var r0 context.Context if rf, ok := ret.Get(0).(func() context.Context); ok { r0 = rf() @@ -40,10 +36,6 @@ func (_m *ResourceService_WatchListServer) Context() context.Context { func (_m *ResourceService_WatchListServer) RecvMsg(m interface{}) error { ret := _m.Called(m) - if len(ret) == 0 { - panic("no return value specified for RecvMsg") - } - var r0 error if rf, ok := ret.Get(0).(func(interface{}) error); ok { r0 = rf(m) @@ -58,10 +50,6 @@ func (_m *ResourceService_WatchListServer) RecvMsg(m interface{}) error { func (_m *ResourceService_WatchListServer) Send(_a0 *pbresource.WatchEvent) error { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for Send") - } - var r0 error if rf, ok := ret.Get(0).(func(*pbresource.WatchEvent) error); ok { r0 = rf(_a0) @@ -76,10 +64,6 @@ func (_m *ResourceService_WatchListServer) Send(_a0 *pbresource.WatchEvent) erro func (_m *ResourceService_WatchListServer) SendHeader(_a0 metadata.MD) error { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for SendHeader") - } - var r0 error if rf, ok := ret.Get(0).(func(metadata.MD) error); ok { r0 = rf(_a0) @@ -94,10 +78,6 @@ func (_m *ResourceService_WatchListServer) SendHeader(_a0 metadata.MD) error { func (_m *ResourceService_WatchListServer) SendMsg(m interface{}) error { ret := _m.Called(m) - if len(ret) == 0 { - panic("no return value specified for SendMsg") - } - var r0 error if rf, ok := ret.Get(0).(func(interface{}) error); ok { r0 = rf(m) @@ -112,10 +92,6 @@ func (_m *ResourceService_WatchListServer) SendMsg(m interface{}) error { func (_m *ResourceService_WatchListServer) SetHeader(_a0 metadata.MD) error { ret := _m.Called(_a0) - if len(ret) == 0 { - panic("no return value specified for SetHeader") - } - var r0 error if rf, ok := ret.Get(0).(func(metadata.MD) error); ok { r0 = rf(_a0) diff --git a/internal/mocks/pbresourcemock/resource_service_client.go b/internal/mocks/pbresourcemock/resource_service_client.go index f136cbd1..3cbb1c8b 100644 --- a/internal/mocks/pbresourcemock/resource_service_client.go +++ b/internal/mocks/pbresourcemock/resource_service_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbresourcemock @@ -28,10 +28,6 @@ func (_m *ResourceServiceClient) Delete(ctx context.Context, in *pbresource.Dele _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for Delete") - } - var r0 *pbresource.DeleteResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.DeleteRequest, ...grpc.CallOption) (*pbresource.DeleteResponse, error)); ok { @@ -65,10 +61,6 @@ func (_m *ResourceServiceClient) List(ctx context.Context, in *pbresource.ListRe _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for List") - } - var r0 *pbresource.ListResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.ListRequest, ...grpc.CallOption) (*pbresource.ListResponse, error)); ok { @@ -102,10 +94,6 @@ func (_m *ResourceServiceClient) ListByOwner(ctx context.Context, in *pbresource _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for ListByOwner") - } - var r0 *pbresource.ListByOwnerResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.ListByOwnerRequest, ...grpc.CallOption) (*pbresource.ListByOwnerResponse, error)); ok { @@ -139,10 +127,6 @@ func (_m *ResourceServiceClient) MutateAndValidate(ctx context.Context, in *pbre _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for MutateAndValidate") - } - var r0 *pbresource.MutateAndValidateResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.MutateAndValidateRequest, ...grpc.CallOption) (*pbresource.MutateAndValidateResponse, error)); ok { @@ -176,10 +160,6 @@ func (_m *ResourceServiceClient) Read(ctx context.Context, in *pbresource.ReadRe _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for Read") - } - var r0 *pbresource.ReadResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.ReadRequest, ...grpc.CallOption) (*pbresource.ReadResponse, error)); ok { @@ -213,10 +193,6 @@ func (_m *ResourceServiceClient) WatchList(ctx context.Context, in *pbresource.W _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for WatchList") - } - var r0 pbresource.ResourceService_WatchListClient var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.WatchListRequest, ...grpc.CallOption) (pbresource.ResourceService_WatchListClient, error)); ok { @@ -250,10 +226,6 @@ func (_m *ResourceServiceClient) Write(ctx context.Context, in *pbresource.Write _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for Write") - } - var r0 *pbresource.WriteResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.WriteRequest, ...grpc.CallOption) (*pbresource.WriteResponse, error)); ok { @@ -287,10 +259,6 @@ func (_m *ResourceServiceClient) WriteStatus(ctx context.Context, in *pbresource _ca = append(_ca, _va...) ret := _m.Called(_ca...) - if len(ret) == 0 { - panic("no return value specified for WriteStatus") - } - var r0 *pbresource.WriteStatusResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.WriteStatusRequest, ...grpc.CallOption) (*pbresource.WriteStatusResponse, error)); ok { diff --git a/internal/mocks/pbresourcemock/resource_service_server.go b/internal/mocks/pbresourcemock/resource_service_server.go index 2cbf4c84..f82d9d9c 100644 --- a/internal/mocks/pbresourcemock/resource_service_server.go +++ b/internal/mocks/pbresourcemock/resource_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbresourcemock @@ -18,10 +18,6 @@ type ResourceServiceServer struct { func (_m *ResourceServiceServer) Delete(_a0 context.Context, _a1 *pbresource.DeleteRequest) (*pbresource.DeleteResponse, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 0 { - panic("no return value specified for Delete") - } - var r0 *pbresource.DeleteResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.DeleteRequest) (*pbresource.DeleteResponse, error)); ok { @@ -48,10 +44,6 @@ func (_m *ResourceServiceServer) Delete(_a0 context.Context, _a1 *pbresource.Del func (_m *ResourceServiceServer) List(_a0 context.Context, _a1 *pbresource.ListRequest) (*pbresource.ListResponse, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 0 { - panic("no return value specified for List") - } - var r0 *pbresource.ListResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.ListRequest) (*pbresource.ListResponse, error)); ok { @@ -78,10 +70,6 @@ func (_m *ResourceServiceServer) List(_a0 context.Context, _a1 *pbresource.ListR func (_m *ResourceServiceServer) ListByOwner(_a0 context.Context, _a1 *pbresource.ListByOwnerRequest) (*pbresource.ListByOwnerResponse, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 0 { - panic("no return value specified for ListByOwner") - } - var r0 *pbresource.ListByOwnerResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.ListByOwnerRequest) (*pbresource.ListByOwnerResponse, error)); ok { @@ -108,10 +96,6 @@ func (_m *ResourceServiceServer) ListByOwner(_a0 context.Context, _a1 *pbresourc func (_m *ResourceServiceServer) MutateAndValidate(_a0 context.Context, _a1 *pbresource.MutateAndValidateRequest) (*pbresource.MutateAndValidateResponse, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 0 { - panic("no return value specified for MutateAndValidate") - } - var r0 *pbresource.MutateAndValidateResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.MutateAndValidateRequest) (*pbresource.MutateAndValidateResponse, error)); ok { @@ -138,10 +122,6 @@ func (_m *ResourceServiceServer) MutateAndValidate(_a0 context.Context, _a1 *pbr func (_m *ResourceServiceServer) Read(_a0 context.Context, _a1 *pbresource.ReadRequest) (*pbresource.ReadResponse, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 0 { - panic("no return value specified for Read") - } - var r0 *pbresource.ReadResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.ReadRequest) (*pbresource.ReadResponse, error)); ok { @@ -168,10 +148,6 @@ func (_m *ResourceServiceServer) Read(_a0 context.Context, _a1 *pbresource.ReadR func (_m *ResourceServiceServer) WatchList(_a0 *pbresource.WatchListRequest, _a1 pbresource.ResourceService_WatchListServer) error { ret := _m.Called(_a0, _a1) - if len(ret) == 0 { - panic("no return value specified for WatchList") - } - var r0 error if rf, ok := ret.Get(0).(func(*pbresource.WatchListRequest, pbresource.ResourceService_WatchListServer) error); ok { r0 = rf(_a0, _a1) @@ -186,10 +162,6 @@ func (_m *ResourceServiceServer) WatchList(_a0 *pbresource.WatchListRequest, _a1 func (_m *ResourceServiceServer) Write(_a0 context.Context, _a1 *pbresource.WriteRequest) (*pbresource.WriteResponse, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 0 { - panic("no return value specified for Write") - } - var r0 *pbresource.WriteResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.WriteRequest) (*pbresource.WriteResponse, error)); ok { @@ -216,10 +188,6 @@ func (_m *ResourceServiceServer) Write(_a0 context.Context, _a1 *pbresource.Writ func (_m *ResourceServiceServer) WriteStatus(_a0 context.Context, _a1 *pbresource.WriteStatusRequest) (*pbresource.WriteStatusResponse, error) { ret := _m.Called(_a0, _a1) - if len(ret) == 0 { - panic("no return value specified for WriteStatus") - } - var r0 *pbresource.WriteStatusResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *pbresource.WriteStatusRequest) (*pbresource.WriteStatusResponse, error)); ok { diff --git a/internal/mocks/pbresourcemock/server_stream.go b/internal/mocks/pbresourcemock/server_stream.go index a3d576e3..48025fc3 100644 --- a/internal/mocks/pbresourcemock/server_stream.go +++ b/internal/mocks/pbresourcemock/server_stream.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbresourcemock @@ -20,10 +20,6 @@ type serverStream[T protoreflect.ProtoMessage] struct { func (_m *serverStream[T]) CloseSend() error { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for CloseSend") - } - var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -38,10 +34,6 @@ func (_m *serverStream[T]) CloseSend() error { func (_m *serverStream[T]) Context() context.Context { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Context") - } - var r0 context.Context if rf, ok := ret.Get(0).(func() context.Context); ok { r0 = rf() @@ -58,10 +50,6 @@ func (_m *serverStream[T]) Context() context.Context { func (_m *serverStream[T]) Header() (metadata.MD, error) { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Header") - } - var r0 metadata.MD var r1 error if rf, ok := ret.Get(0).(func() (metadata.MD, error)); ok { @@ -88,10 +76,6 @@ func (_m *serverStream[T]) Header() (metadata.MD, error) { func (_m *serverStream[T]) Recv() (T, error) { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Recv") - } - var r0 T var r1 error if rf, ok := ret.Get(0).(func() (T, error)); ok { @@ -116,10 +100,6 @@ func (_m *serverStream[T]) Recv() (T, error) { func (_m *serverStream[T]) RecvMsg(m interface{}) error { ret := _m.Called(m) - if len(ret) == 0 { - panic("no return value specified for RecvMsg") - } - var r0 error if rf, ok := ret.Get(0).(func(interface{}) error); ok { r0 = rf(m) @@ -134,10 +114,6 @@ func (_m *serverStream[T]) RecvMsg(m interface{}) error { func (_m *serverStream[T]) SendMsg(m interface{}) error { ret := _m.Called(m) - if len(ret) == 0 { - panic("no return value specified for SendMsg") - } - var r0 error if rf, ok := ret.Get(0).(func(interface{}) error); ok { r0 = rf(m) @@ -152,10 +128,6 @@ func (_m *serverStream[T]) SendMsg(m interface{}) error { func (_m *serverStream[T]) Trailer() metadata.MD { ret := _m.Called() - if len(ret) == 0 { - panic("no return value specified for Trailer") - } - var r0 metadata.MD if rf, ok := ret.Get(0).(func() metadata.MD); ok { r0 = rf() diff --git a/internal/mocks/pbresourcemock/unsafe_resource_service_server.go b/internal/mocks/pbresourcemock/unsafe_resource_service_server.go index 11c486ee..809a9a73 100644 --- a/internal/mocks/pbresourcemock/unsafe_resource_service_server.go +++ b/internal/mocks/pbresourcemock/unsafe_resource_service_server.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.41.0. DO NOT EDIT. +// Code generated by mockery v2.32.0. DO NOT EDIT. package pbresourcemock diff --git a/pkg/consuldp/bootstrap.go b/pkg/consuldp/bootstrap.go index 41a1a693..d14e28f9 100644 --- a/pkg/consuldp/bootstrap.go +++ b/pkg/consuldp/bootstrap.go @@ -12,6 +12,7 @@ import ( "strings" "github.com/hashicorp/consul/proto-public/pbdataplane" + pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v2beta1" "github.com/mitchellh/mapstructure" "github.com/hashicorp/consul-dataplane/internal/bootstrap" @@ -26,9 +27,10 @@ const ( defaultAdminAccessLogsPath = os.DevNull ) -// getBootstrapParams makes a call using the service client to get the bootstrap params for eventually getting the Envoy bootstrap config. -func (cdp *ConsulDataplane) getBootstrapParams(ctx context.Context) (*pbdataplane.GetEnvoyBootstrapParamsResponse, error) { +// bootstrapConfig generates the Envoy bootstrap config in JSON format. +func (cdp *ConsulDataplane) bootstrapConfig(ctx context.Context) (*bootstrap.BootstrapConfig, []byte, error) { svc := cdp.cfg.Proxy + envoy := cdp.cfg.Envoy req := &pbdataplane.GetEnvoyBootstrapParamsRequest{ ServiceId: svc.ProxyID, @@ -49,17 +51,16 @@ func (cdp *ConsulDataplane) getBootstrapParams(ctx context.Context) (*pbdataplan rsp, err := cdp.dpServiceClient.GetEnvoyBootstrapParams(ctx, req) if err != nil { - return nil, fmt.Errorf("failed to get envoy bootstrap params: %w", err) + return nil, nil, fmt.Errorf("failed to get envoy bootstrap params: %w", err) } - return rsp, nil -} - -// bootstrapConfig generates the Envoy bootstrap config in JSON format. -func (cdp *ConsulDataplane) bootstrapConfig( - bootstrapParams *pbdataplane.GetEnvoyBootstrapParamsResponse) (*bootstrap.BootstrapConfig, []byte, error) { - svc := cdp.cfg.Proxy - envoy := cdp.cfg.Envoy + // store the final resolved service for others to use. + cdp.resolvedProxyConfig = ProxyConfig{ + NodeName: rsp.NodeName, + ProxyID: cdp.cfg.Proxy.ProxyID, + Namespace: rsp.Namespace, + Partition: rsp.Partition, + } prom := cdp.cfg.Telemetry.Prometheus args := &bootstrap.BootstrapTplArgs{ @@ -68,26 +69,26 @@ func (cdp *ConsulDataplane) bootstrapConfig( AgentPort: strconv.Itoa(cdp.cfg.XDSServer.BindPort), AgentTLS: false, }, - ProxyCluster: bootstrapParams.Service, + ProxyCluster: rsp.Service, ProxyID: svc.ProxyID, - NodeName: bootstrapParams.NodeName, - ProxySourceService: bootstrapParams.Service, - AdminAccessLogConfig: bootstrapParams.AccessLogs, + NodeName: rsp.NodeName, + ProxySourceService: rsp.Service, + AdminAccessLogConfig: rsp.AccessLogs, AdminAccessLogPath: defaultAdminAccessLogsPath, AdminBindAddress: envoy.AdminBindAddress, AdminBindPort: strconv.Itoa(envoy.AdminBindPort), LocalAgentClusterName: localClusterName, - Namespace: bootstrapParams.Namespace, - Partition: bootstrapParams.Partition, - Datacenter: bootstrapParams.Datacenter, + Namespace: rsp.Namespace, + Partition: rsp.Partition, + Datacenter: rsp.Datacenter, PrometheusCertFile: prom.CertFile, PrometheusKeyFile: prom.KeyFile, PrometheusScrapePath: prom.ScrapePath, } - if bootstrapParams.Identity != "" { - args.ProxyCluster = bootstrapParams.Identity - args.ProxySourceService = bootstrapParams.Identity + if rsp.Identity != "" { + args.ProxyCluster = rsp.Identity + args.ProxySourceService = rsp.Identity } if cdp.xdsServer.listenerNetwork == "unix" { @@ -116,8 +117,12 @@ func (cdp *ConsulDataplane) bootstrapConfig( } if cdp.cfg.Telemetry.UseCentralConfig { - if err := mapstructure.WeakDecode(bootstrapParams.Config.AsMap(), &bootstrapConfig); err != nil { - return nil, nil, fmt.Errorf("failed parsing Proxy.Config: %w", err) + if rsp.BootstrapConfig != nil { + bootstrapConfig = bootstrapConfigFromCfg(rsp.BootstrapConfig) + } else { + if err := mapstructure.WeakDecode(rsp.Config.AsMap(), &bootstrapConfig); err != nil { + return nil, nil, fmt.Errorf("failed parsing Proxy.Config: %w", err) + } } // Envoy is configured with a listener that proxies metrics from its @@ -136,3 +141,22 @@ func (cdp *ConsulDataplane) bootstrapConfig( cfg, err := bootstrapConfig.GenerateJSON(args, true) return &bootstrapConfig, cfg, err } + +func bootstrapConfigFromCfg(cfg *pbmesh.BootstrapConfig) bootstrap.BootstrapConfig { + return bootstrap.BootstrapConfig{ + StatsdURL: cfg.StatsdUrl, + DogstatsdURL: cfg.DogstatsdUrl, + StatsTags: cfg.StatsTags, + TelemetryCollectorBindSocketDir: cfg.TelemetryCollectorBindSocketDir, + PrometheusBindAddr: cfg.PrometheusBindAddr, + StatsBindAddr: cfg.StatsBindAddr, + ReadyBindAddr: cfg.ReadyBindAddr, + OverrideJSONTpl: cfg.OverrideJsonTpl, + StaticClustersJSON: cfg.StaticClustersJson, + StaticListenersJSON: cfg.StaticListenersJson, + StatsSinksJSON: cfg.StatsSinksJson, + StatsConfigJSON: cfg.StatsConfigJson, + StatsFlushInterval: cfg.StatsFlushInterval, + TracingConfigJSON: cfg.TracingConfigJson, + } +} diff --git a/pkg/consuldp/bootstrap_test.go b/pkg/consuldp/bootstrap_test.go index b0ec5fd4..fe91a6f8 100644 --- a/pkg/consuldp/bootstrap_test.go +++ b/pkg/consuldp/bootstrap_test.go @@ -15,6 +15,7 @@ import ( "testing" "github.com/hashicorp/consul/proto-public/pbdataplane" + pbmesh "github.com/hashicorp/consul/proto-public/pbmesh/v2beta1" "github.com/hashicorp/go-hclog" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -42,6 +43,7 @@ func TestBootstrapConfig(t *testing.T) { testCases := map[string]struct { cfg *Config rsp *pbdataplane.GetEnvoyBootstrapParamsResponse + rspV2 *pbdataplane.GetEnvoyBootstrapParamsResponse resolvedProxyConfig *ProxyConfig }{ "access-logs": { @@ -67,6 +69,14 @@ func TestBootstrapConfig(t *testing.T) { }), AccessLogs: []string{"{\"name\":\"Consul Listener Filter Log\",\"typedConfig\":{\"@type\":\"type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog\",\"logFormat\":{\"jsonFormat\":{\"custom_field\":\"%START_TIME%\"}}}}"}, }, + rspV2: &pbdataplane.GetEnvoyBootstrapParamsResponse{ + Identity: "web", + NodeName: nodeName, + BootstrapConfig: &pbmesh.BootstrapConfig{ + DogstatsdUrl: "this-should-not-appear-in-generated-config", + }, + AccessLogs: []string{"{\"name\":\"Consul Listener Filter Log\",\"typedConfig\":{\"@type\":\"type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog\",\"logFormat\":{\"jsonFormat\":{\"custom_field\":\"%START_TIME%\"}}}}"}, + }, }, "basic": { cfg: &Config{ @@ -90,6 +100,13 @@ func TestBootstrapConfig(t *testing.T) { "envoy_dogstatsd_url": "this-should-not-appear-in-generated-config", }), }, + rspV2: &pbdataplane.GetEnvoyBootstrapParamsResponse{ + Identity: "web", + NodeName: nodeName, + BootstrapConfig: &pbmesh.BootstrapConfig{ + DogstatsdUrl: "this-should-not-appear-in-generated-config", + }, + }, }, "central-telemetry-config": { cfg: &Config{ @@ -113,6 +130,13 @@ func TestBootstrapConfig(t *testing.T) { "envoy_dogstatsd_url": "udp://127.0.0.1:9125", }), }, + rspV2: &pbdataplane.GetEnvoyBootstrapParamsResponse{ + Identity: "web", + NodeName: nodeName, + BootstrapConfig: &pbmesh.BootstrapConfig{ + DogstatsdUrl: "udp://127.0.0.1:9125", + }, + }, }, "hcp-metrics": { cfg: &Config{ @@ -138,6 +162,14 @@ func TestBootstrapConfig(t *testing.T) { "envoy_telemetry_collector_bind_socket_dir": "/tmp/consul/hcp-metrics", }), }, + rspV2: &pbdataplane.GetEnvoyBootstrapParamsResponse{ + Identity: "web", + Namespace: "default", + NodeName: nodeName, + BootstrapConfig: &pbmesh.BootstrapConfig{ + TelemetryCollectorBindSocketDir: "/tmp/consul/hcp-metrics", + }, + }, }, "custom-prometheus-scrape-path": { cfg: &Config{ @@ -165,6 +197,13 @@ func TestBootstrapConfig(t *testing.T) { "envoy_prometheus_bind_addr": "0.0.0.0:20200", }), }, + rspV2: &pbdataplane.GetEnvoyBootstrapParamsResponse{ + Identity: "web", + NodeName: nodeName, + BootstrapConfig: &pbmesh.BootstrapConfig{ + PrometheusBindAddr: "0.0.0.0:20200", + }, + }, }, "custom-prometheus-scrape-path-with-query": { cfg: &Config{ @@ -193,6 +232,13 @@ func TestBootstrapConfig(t *testing.T) { "envoy_prometheus_bind_addr": "0.0.0.0:20200", }), }, + rspV2: &pbdataplane.GetEnvoyBootstrapParamsResponse{ + Identity: "web", + NodeName: nodeName, + BootstrapConfig: &pbmesh.BootstrapConfig{ + PrometheusBindAddr: "0.0.0.0:20200", + }, + }, }, "non-default tenancy": { cfg: &Config{ @@ -219,6 +265,15 @@ func TestBootstrapConfig(t *testing.T) { Namespace: "test-namespace", Partition: "test-partition", }, + rspV2: &pbdataplane.GetEnvoyBootstrapParamsResponse{ + Identity: "web", + NodeName: nodeName, + BootstrapConfig: &pbmesh.BootstrapConfig{ + DogstatsdUrl: "this-should-not-appear-in-generated-config", + }, + Namespace: "test-namespace", + Partition: "test-partition", + }, // We want to ensure cdp is configured with the resolved tenancy resolvedProxyConfig: &ProxyConfig{ NodeName: nodeName, @@ -248,6 +303,10 @@ func TestBootstrapConfig(t *testing.T) { Service: "web", NodeName: nodeName, }, + rspV2: &pbdataplane.GetEnvoyBootstrapParamsResponse{ + Identity: "web", + NodeName: nodeName, + }, }, "unix-socket-xds-server": { cfg: &Config{ @@ -271,10 +330,17 @@ func TestBootstrapConfig(t *testing.T) { "envoy_dogstatsd_url": "this-should-not-appear-in-generated-config", }), }, + rspV2: &pbdataplane.GetEnvoyBootstrapParamsResponse{ + Identity: "web", + NodeName: nodeName, + BootstrapConfig: &pbmesh.BootstrapConfig{ + DogstatsdUrl: "this-should-not-appear-in-generated-config", + }, + }, }, } for desc, tc := range testCases { - t.Run(desc, func(t *testing.T) { + t.Run(desc+"-v1", func(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) t.Cleanup(cancel) @@ -300,23 +366,51 @@ func TestBootstrapConfig(t *testing.T) { dp.xdsServer = &xdsServer{listenerAddress: fmt.Sprintf("127.0.0.1:%d", xdsBindPort)} } - params, err := dp.getBootstrapParams(ctx) + _, bsCfg, err := dp.bootstrapConfig(ctx) require.NoError(t, err) - _, bsCfg, err := dp.bootstrapConfig(params) + golden(t, bsCfg) + validateBootstrapConfig(t, bsCfg) + + if tc.resolvedProxyConfig != nil { + require.Equal(t, *tc.resolvedProxyConfig, dp.resolvedProxyConfig) + } + }) + + t.Run(desc+"-v2", func(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + t.Cleanup(cancel) + + client := NewMockDataplaneServiceClient(t) + client.EXPECT(). + GetEnvoyBootstrapParams(mock.Anything, &pbdataplane.GetEnvoyBootstrapParamsRequest{ + NodeSpec: &pbdataplane.GetEnvoyBootstrapParamsRequest_NodeName{NodeName: tc.cfg.Proxy.NodeName}, + ServiceId: tc.cfg.Proxy.ProxyID, + ProxyId: tc.cfg.Proxy.ProxyID, + Namespace: tc.cfg.Proxy.Namespace, + }).Call. + Return(tc.rspV2, nil) + + dp := &ConsulDataplane{ + cfg: tc.cfg, + dpServiceClient: client, + logger: hclog.NewNullLogger(), + } + + if strings.HasPrefix(tc.cfg.XDSServer.BindAddress, "unix://") { + dp.xdsServer = &xdsServer{listenerAddress: socketPath, listenerNetwork: "unix"} + } else { + dp.xdsServer = &xdsServer{listenerAddress: fmt.Sprintf("127.0.0.1:%d", xdsBindPort)} + } + + _, bsCfg, err := dp.bootstrapConfig(ctx) require.NoError(t, err) golden(t, bsCfg) validateBootstrapConfig(t, bsCfg) if tc.resolvedProxyConfig != nil { - proxyCfg := ProxyConfig{ - NodeName: params.NodeName, - ProxyID: dp.cfg.Proxy.ProxyID, - Namespace: params.Namespace, - Partition: params.Partition, - } - require.Equal(t, *tc.resolvedProxyConfig, proxyCfg) + require.Equal(t, *tc.resolvedProxyConfig, dp.resolvedProxyConfig) } }) } @@ -325,7 +419,10 @@ func TestBootstrapConfig(t *testing.T) { func golden(t *testing.T, actual []byte) { t.Helper() - goldenPath := filepath.Join("testdata", t.Name()+".golden") + fileName := strings.TrimSuffix(t.Name(), "-v1") + fileName = strings.TrimSuffix(fileName, "-v2") + + goldenPath := filepath.Join("testdata", fileName+".golden") if *update { require.NoError(t, os.WriteFile(goldenPath, actual, 0644)) diff --git a/pkg/consuldp/config.go b/pkg/consuldp/config.go index 83b7852e..b3177bfe 100644 --- a/pkg/consuldp/config.go +++ b/pkg/consuldp/config.go @@ -135,18 +135,6 @@ const ( CredentialsTypeLogin CredentialsType = "login" ) -// CredentialsType identifies the type of credentials provided. -type ModeType string - -const ( - // ModeTypeSidecar indicates that consul-dataplane is running in sidecar - // mode where DNS Server, xDS Server, and Envoy are all enabled. - ModeTypeSidecar ModeType = "sidecar" - // ModeTypeDNSProxy indicates that consul-dataplane is running in DNS Proxy - // mode where DNS Server is running but xDSServer and Envoy are disabled. - ModeTypeDNSProxy ModeType = "dns-proxy" -) - // StaticCredentialsConfig contains the static ACL token that will be used to // authenticate requests and streams to the Consul servers. type StaticCredentialsConfig struct { @@ -224,10 +212,10 @@ type LoggingConfig struct { // ProxyConfig contains details of the proxy service instance. type ProxyConfig struct { // NodeName is the name of the node to which the proxy service instance is - // registered. + // registered. Ignored in Consul Catalog V2. NodeName string // NodeName is the ID of the node to which the proxy service instance is - // registered. + // registered. Ignored in Consul Catalog V2. NodeID string // ProxyID is the ID of the proxy service instance or workload. ProxyID string @@ -328,7 +316,6 @@ type XDSServer struct { // Config is the configuration used by consul-dataplane, consolidated // from various sources - CLI flags, env vars, config file settings. type Config struct { - Mode ModeType DNSServer *DNSServerConfig Consul *ConsulConfig Proxy *ProxyConfig diff --git a/pkg/consuldp/consul_dataplane.go b/pkg/consuldp/consul_dataplane.go index 76df0b99..f822a984 100644 --- a/pkg/consuldp/consul_dataplane.go +++ b/pkg/consuldp/consul_dataplane.go @@ -47,6 +47,8 @@ type ConsulDataplane struct { aclToken string metricsConfig *metricsConfig lifecycleConfig *lifecycleConfig + + resolvedProxyConfig ProxyConfig } // NewConsulDP creates a new instance of ConsulDataplane @@ -77,26 +79,24 @@ func validateConfig(cfg *Config) error { return errors.New("consul addresses not specified") case cfg.Consul.GRPCPort == 0: return errors.New("consul server gRPC port not specified") - case cfg.Mode == ModeTypeSidecar && cfg.Proxy == nil: + case cfg.Proxy == nil: return errors.New("proxy details not specified") - case cfg.Mode == ModeTypeSidecar && cfg.Proxy.ProxyID == "": + case cfg.Proxy.ProxyID == "": return errors.New("proxy ID not specified") - case cfg.Mode == ModeTypeSidecar && cfg.Envoy == nil: + case cfg.Envoy == nil: return errors.New("envoy settings not specified") - case cfg.Mode == ModeTypeSidecar && cfg.Envoy.AdminBindAddress == "": + case cfg.Envoy.AdminBindAddress == "": return errors.New("envoy admin bind address not specified") - case cfg.Mode == ModeTypeSidecar && cfg.Envoy.AdminBindPort == 0: + case cfg.Envoy.AdminBindPort == 0: return errors.New("envoy admin bind port not specified") case cfg.Logging == nil: return errors.New("logging settings not specified") - case cfg.Mode == ModeTypeSidecar && cfg.XDSServer.BindAddress == "": + case cfg.XDSServer.BindAddress == "": return errors.New("envoy xDS bind address not specified") - case cfg.Mode == ModeTypeSidecar && !strings.HasPrefix(cfg.XDSServer.BindAddress, "unix://") && !net.ParseIP(cfg.XDSServer.BindAddress).IsLoopback(): + case !strings.HasPrefix(cfg.XDSServer.BindAddress, "unix://") && !net.ParseIP(cfg.XDSServer.BindAddress).IsLoopback(): return errors.New("non-local xDS bind address not allowed") - case cfg.Mode == ModeTypeSidecar && cfg.DNSServer.Port != -1 && !net.ParseIP(cfg.DNSServer.BindAddr).IsLoopback(): - return errors.New("non-local DNS proxy bind address not allowed when running as a sidecar") - case cfg.Mode == ModeTypeDNSProxy && cfg.Proxy != nil && !(cfg.Proxy.Namespace == "" || cfg.Proxy.Namespace == "default"): - return errors.New("namespace must be empty or set to 'default' when running in dns-proxy mode") + case cfg.DNSServer.Port != -1 && !net.ParseIP(cfg.DNSServer.BindAddr).IsLoopback(): + return errors.New("non-local DNS proxy bind address not allowed") } creds := cfg.Consul.Credentials @@ -129,7 +129,6 @@ func validateConfig(cfg *Config) error { func (cdp *ConsulDataplane) Run(ctx context.Context) error { ctx = hclog.WithContext(ctx, cdp.logger) cdp.logger.Info("started consul-dataplane process") - cdp.logger.Info(fmt.Sprintf("consul-dataplane mode: %s", cdp.cfg.Mode)) // At startup we need to cache metrics until we have information from the bootstrap envoy config // that the consumer wants metrics enabled. Until then we will set our own light weight metrics @@ -179,54 +178,24 @@ func (cdp *ConsulDataplane) Run(ctx context.Context) error { cdp.aclToken = state.Token cdp.dpServiceClient = pbdataplane.NewDataplaneServiceClient(state.GRPCConn) - doneCh := make(chan error) - - // if running as DNS PRoxy, xDS Server and Envoy are disabled, so - // return before configuring them. - if cdp.cfg.Mode == ModeTypeDNSProxy { - // start up DNS server with the configuration from the consul-dataplane flags / environment variables since - // envoy bootstrapping is bypassed. - if err = cdp.startDNSProxy(ctx, cdp.cfg.DNSServer, cdp.cfg.Proxy.Namespace, cdp.cfg.Proxy.Partition); err != nil { - cdp.logger.Error("failed to start the dns proxy", "error", err) - return err - } - // Wait for context to be done in a more simplified goroutine dns-proxy mode. - go func() { - <-ctx.Done() - doneCh <- nil - }() - return <-doneCh - } - - // Configure xDS and Envoy configuration continues here when running in sidecar mode. - cdp.logger.Info("configuring xDS and Envoy") err = cdp.setupXDSServer() if err != nil { return err } go cdp.startXDSServer(ctx) - bootstrapParams, err := cdp.getBootstrapParams(ctx) + bootstrapCfg, cfg, err := cdp.bootstrapConfig(ctx) if err != nil { - cdp.logger.Error("failed to get bootstrap params", "error", err) + cdp.logger.Error("failed to get bootstrap config", "error", err) return fmt.Errorf("failed to get bootstrap config: %w", err) } - cdp.logger.Debug("generated envoy bootstrap params", "params", bootstrapParams) + cdp.logger.Debug("generated envoy bootstrap config", "config", string(cfg)) - // start up DNS server with envoy bootstrap params. - if err = cdp.startDNSProxy(ctx, cdp.cfg.DNSServer, bootstrapParams.Namespace, bootstrapParams.Partition); err != nil { + if err = cdp.startDNSProxy(ctx); err != nil { cdp.logger.Error("failed to start the dns proxy", "error", err) return err } - bootstrapCfg, cfg, err := cdp.bootstrapConfig(bootstrapParams) - if err != nil { - cdp.logger.Error("failed to get bootstrap config", "error", err) - return fmt.Errorf("failed to get bootstrap config: %w", err) - } - cdp.logger.Debug("generated envoy bootstrap config", "config", string(cfg)) - - cdp.logger.Info("configuring envoy and xDS") proxy, err := envoy.NewProxy(cdp.envoyProxyConfig(cfg)) if err != nil { cdp.logger.Error("failed to create new proxy", "error", err) @@ -249,6 +218,7 @@ func (cdp *ConsulDataplane) Run(ctx context.Context) error { return err } + doneCh := make(chan error) go func() { select { case <-ctx.Done(): @@ -283,21 +253,20 @@ func (cdp *ConsulDataplane) Run(ctx context.Context) error { return <-doneCh } -func (cdp *ConsulDataplane) startDNSProxy(ctx context.Context, - dnsConfig *DNSServerConfig, namespace, partition string) error { +func (cdp *ConsulDataplane) startDNSProxy(ctx context.Context) error { dnsClientInterface := pbdns.NewDNSServiceClient(cdp.serverConn) dnsServer, err := dns.NewDNSServer(dns.DNSServerParams{ - BindAddr: dnsConfig.BindAddr, - Port: dnsConfig.Port, + BindAddr: cdp.cfg.DNSServer.BindAddr, + Port: cdp.cfg.DNSServer.Port, Client: dnsClientInterface, Logger: cdp.logger, - Partition: partition, - Namespace: namespace, + Partition: cdp.resolvedProxyConfig.Partition, + Namespace: cdp.resolvedProxyConfig.Namespace, Token: cdp.aclToken, }) if err == dns.ErrServerDisabled { - cdp.logger.Info("dns server disabled: configure the Consul DNS port to enable") + cdp.logger.Info("dns proxy disabled: configure the Consul DNS port to enable") return nil } else if err != nil { return fmt.Errorf("failed to create dns server: %w", err) diff --git a/pkg/consuldp/consul_dataplane_test.go b/pkg/consuldp/consul_dataplane_test.go index f7a5102d..d4d6d37a 100644 --- a/pkg/consuldp/consul_dataplane_test.go +++ b/pkg/consuldp/consul_dataplane_test.go @@ -10,9 +10,8 @@ import ( "github.com/stretchr/testify/require" ) -func validConfig(mode ModeType) *Config { +func validConfig() *Config { return &Config{ - Mode: mode, Consul: &ConsulConfig{ Addresses: "consul.servers.dns.com", GRPCPort: 1234, @@ -55,7 +54,7 @@ func validConfig(mode ModeType) *Config { } func TestNewConsulDP(t *testing.T) { - cfg := validConfig(ModeTypeSidecar) + cfg := validConfig() consulDP, err := NewConsulDP(cfg) require.NoError(t, err) require.NotNil(t, consulDP) @@ -70,121 +69,101 @@ func TestNewConsulDPError(t *testing.T) { name string modFn func(*Config) expectErr string - mode ModeType } testCases := []testCase{ - // Side car test cases { - name: "sidecar mode - missing consul config", - mode: ModeTypeSidecar, + name: "missing consul config", modFn: func(c *Config) { c.Consul = nil }, expectErr: "consul addresses not specified", }, { - name: "sidecar mode - missing consul addresses", - mode: ModeTypeSidecar, + name: "missing consul addresses", modFn: func(c *Config) { c.Consul.Addresses = "" }, expectErr: "consul addresses not specified", }, { - name: "sidecar mode - missing consul server grpc port", - mode: ModeTypeSidecar, + name: "missing consul server grpc port", modFn: func(c *Config) { c.Consul.GRPCPort = 0 }, expectErr: "consul server gRPC port not specified", }, { - name: "sidecar mode - missing proxy config", - mode: ModeTypeSidecar, + name: "missing proxy config", modFn: func(c *Config) { c.Proxy = nil }, expectErr: "proxy details not specified", }, { - name: "sidecar mode - missing proxy id", - mode: ModeTypeSidecar, + name: "missing proxy id", modFn: func(c *Config) { c.Proxy.ProxyID = "" }, expectErr: "proxy ID not specified", }, { - name: "sidecar mode - missing envoy config", - mode: ModeTypeSidecar, + name: "missing envoy config", modFn: func(c *Config) { c.Envoy = nil }, expectErr: "envoy settings not specified", }, { - name: "sidecar mode - missing envoy admin bind address", - mode: ModeTypeSidecar, + name: "missing envoy admin bind address", modFn: func(c *Config) { c.Envoy.AdminBindAddress = "" }, expectErr: "envoy admin bind address not specified", }, { - name: "sidecar mode - missing envoy admin bind port", - mode: ModeTypeSidecar, + name: "missing envoy admin bind port", modFn: func(c *Config) { c.Envoy.AdminBindPort = 0 }, expectErr: "envoy admin bind port not specified", }, { - name: "sidecar mode - missing logging config", - mode: ModeTypeSidecar, + name: "missing logging config", modFn: func(c *Config) { c.Logging = nil }, expectErr: "logging settings not specified", }, { - name: "sidecar mode - missing prometheus ca certs path", - mode: ModeTypeSidecar, + name: "missing prometheus ca certs path", modFn: func(c *Config) { c.Telemetry.Prometheus.CACertsPath = "" }, expectErr: "Must provide -telemetry-prom-ca-certs-path, -telemetry-prom-cert-file, and -telemetry-prom-key-file to enable TLS for prometheus metrics", }, { - name: "sidecar mode - missing prometheus key file", - mode: ModeTypeSidecar, + name: "missing prometheus key file", modFn: func(c *Config) { c.Telemetry.Prometheus.KeyFile = "" }, expectErr: "Must provide -telemetry-prom-ca-certs-path, -telemetry-prom-cert-file, and -telemetry-prom-key-file to enable TLS for prometheus metrics", }, { - name: "sidecar mode - missing prometheus cert file", - mode: ModeTypeSidecar, + name: "missing prometheus cert file", modFn: func(c *Config) { c.Telemetry.Prometheus.CertFile = "" }, expectErr: "Must provide -telemetry-prom-ca-certs-path, -telemetry-prom-cert-file, and -telemetry-prom-key-file to enable TLS for prometheus metrics", }, { - name: "sidecar mode - missing prometheus retention time", - mode: ModeTypeSidecar, + name: "missing prometheus retention time", modFn: func(c *Config) { c.Telemetry.Prometheus.RetentionTime = 0 }, expectErr: "-telemetry-prom-retention-time must be greater than zero", }, { - name: "sidecar mode - missing prometheus scrape path", - mode: ModeTypeSidecar, + name: "missing prometheus scrape path", modFn: func(c *Config) { c.Telemetry.Prometheus.ScrapePath = "" }, expectErr: "-telemetry-prom-scrape-path must not be empty", }, { - name: "sidecar mode - missing xds bind address", - mode: ModeTypeSidecar, + name: "missing xds bind address", modFn: func(c *Config) { c.XDSServer.BindAddress = "" }, expectErr: "envoy xDS bind address not specified", }, { - name: "sidecar mode - non-local xds bind address", - mode: ModeTypeSidecar, + name: "non-local xds bind address", modFn: func(c *Config) { c.XDSServer.BindAddress = "1.2.3.4" }, expectErr: "non-local xDS bind address not allowed", }, { - name: "sidecar mode - non-local xds bind address", - mode: ModeTypeSidecar, + name: "non-local xds bind address", modFn: func(c *Config) { c.DNSServer.BindAddr = "1.2.3.4" c.DNSServer.Port = 1 }, - expectErr: "non-local DNS proxy bind address not allowed when running as a sidecar", + expectErr: "non-local DNS proxy bind address not allowed", }, { - name: "sidecar mode - no bearer token or path given", - mode: ModeTypeSidecar, + name: "no bearer token or path given", modFn: func(c *Config) { c.Consul.Credentials.Type = CredentialsTypeLogin c.Consul.Credentials.Login = LoginCredentialsConfig{} @@ -192,147 +171,12 @@ func TestNewConsulDPError(t *testing.T) { expectErr: "bearer token (or path to a file containing a bearer token) is required for login", }, } - - dnsProxyTestCases := []testCase{ - // dns proxy test cases - { - name: "dns-proxy mode - missing consul config", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Consul = nil }, - expectErr: "consul addresses not specified", - }, - { - name: "dns-proxy mode - missing consul addresses", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Consul.Addresses = "" }, - expectErr: "consul addresses not specified", - }, - { - name: "dns-proxy mode - missing consul server grpc port", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Consul.GRPCPort = 0 }, - expectErr: "consul server gRPC port not specified", - }, - { - name: "dns-proxy mode - no error when missing proxy config", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Proxy = nil }, - expectErr: "", - }, - { - name: "dns-proxy mode - no error when missing proxy id", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Proxy.ProxyID = "" }, - expectErr: "", - }, - { - name: "dns-proxy mode - no error when missing envoy config", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Envoy = nil }, - expectErr: "", - }, - { - name: "dns-proxy mode - no error when missing envoy admin bind address", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Envoy.AdminBindAddress = "" }, - expectErr: "", - }, - { - name: "dns-proxy mode - no error when missing envoy admin bind port", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Envoy.AdminBindPort = 0 }, - expectErr: "", - }, - { - name: "dns-proxy mode - missing logging config", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Logging = nil }, - expectErr: "logging settings not specified", - }, - { - name: "dns-proxy mode - missing prometheus ca certs path", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Telemetry.Prometheus.CACertsPath = "" }, - expectErr: "Must provide -telemetry-prom-ca-certs-path, -telemetry-prom-cert-file, and -telemetry-prom-key-file to enable TLS for prometheus metrics", - }, - { - name: "dns-proxy mode - missing prometheus key file", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Telemetry.Prometheus.KeyFile = "" }, - expectErr: "Must provide -telemetry-prom-ca-certs-path, -telemetry-prom-cert-file, and -telemetry-prom-key-file to enable TLS for prometheus metrics", - }, - { - name: "dns-proxy mode - missing prometheus cert file", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Telemetry.Prometheus.CertFile = "" }, - expectErr: "Must provide -telemetry-prom-ca-certs-path, -telemetry-prom-cert-file, and -telemetry-prom-key-file to enable TLS for prometheus metrics", - }, - { - name: "dns-proxy mode - missing prometheus retention time", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Telemetry.Prometheus.RetentionTime = 0 }, - expectErr: "-telemetry-prom-retention-time must be greater than zero", - }, - { - name: "dns-proxy mode - missing prometheus scrape path", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.Telemetry.Prometheus.ScrapePath = "" }, - expectErr: "-telemetry-prom-scrape-path must not be empty", - }, - { - name: "dns-proxy mode - no error when missing xds bind address", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { c.XDSServer.BindAddress = "" }, - expectErr: "", - }, - { - name: "dns-proxy mode - no error when non-local xds bind address", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { - c.XDSServer.BindAddress = "1.2.3.4" - }, - expectErr: "", - }, - { - name: "dns-proxy mode - non-local xds bind address", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { - c.DNSServer.BindAddr = "1.2.3.4" - c.DNSServer.Port = 1 - }, - expectErr: "", - }, - { - name: "dns-proxy mode - no bearer token or path given", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { - c.Consul.Credentials.Type = CredentialsTypeLogin - c.Consul.Credentials.Login = LoginCredentialsConfig{} - }, - expectErr: "bearer token (or path to a file containing a bearer token) is required for login", - }, - { - name: "dns-proxy mode - namespace set to non empty or default value", - mode: ModeTypeDNSProxy, - modFn: func(c *Config) { - c.Proxy.Namespace = "test" - }, - expectErr: "namespace must be empty or set to 'default' when running in dns-proxy mode", - }, - } - - testCases = append(testCases, dnsProxyTestCases...) - for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - cfg := validConfig(tc.mode) + cfg := validConfig() tc.modFn(cfg) _, err := NewConsulDP(cfg) - if tc.expectErr == "" { - require.NoError(t, err) - return - } require.EqualError(t, err, tc.expectErr) }) } diff --git a/pkg/consuldp/xds.go b/pkg/consuldp/xds.go index f3cb564f..e85e1de9 100644 --- a/pkg/consuldp/xds.go +++ b/pkg/consuldp/xds.go @@ -28,7 +28,7 @@ const ( func (cdp *ConsulDataplane) director(ctx context.Context, fullMethodName string) (context.Context, *grpc.ClientConn, error) { // check to ensure other unknown/unregistered RPCs are not proxied to the target consul server. if !strings.Contains(fullMethodName, envoyADSMethodName) { - return ctx, nil, status.Errorf(codes.Unimplemented, "Unknown method %s", fullMethodName) + return ctx, nil, status.Errorf(codes.Unimplemented, fmt.Sprintf("Unknown method %s", fullMethodName)) } var mdCopy metadata.MD diff --git a/pkg/dns/dns.go b/pkg/dns/dns.go index 39880b2f..93d7f8ba 100644 --- a/pkg/dns/dns.go +++ b/pkg/dns/dns.go @@ -106,8 +106,6 @@ func (d *DNSServer) Start(ctx context.Context) error { d.lock.Lock() defer d.lock.Unlock() - d.logger.Debug("starting DNS proxy", "partition", d.partition, "namespace", d.namespace) - if d.running { return ErrServerRunning } @@ -217,8 +215,6 @@ func (d *DNSServer) queryConsulAndRespondUDP(buf []byte, addr net.Addr) { "x-consul-token", d.token, ) - logger.Debug("querying through udp", "partition", d.partition, "namespace", d.namespace) - resp, err := d.client.Query(ctx, req) if err != nil { logger.Error("error resolving consul request", "error", err) @@ -305,8 +301,6 @@ func (d *DNSServer) proxyTCPAcceptedConn(ctx context.Context, conn net.Conn, cli "x-consul-token", d.token, ) - logger.Debug("querying through tcp", "partition", d.partition, "namespace", d.namespace) - resp, err := client.Query(ctx, req) if err != nil { logger.Error("error resolving consul request", "error", err) diff --git a/pkg/version/version.go b/pkg/version/version.go index 3bd1170c..223ac42c 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -17,7 +17,7 @@ var ( // // Version must conform to the format expected by github.com/hashicorp/go-version // for tests to work. - Version = "1.6.0" + Version = "1.5.2" // A pre-release marker for the version. If this is "" (empty string) // then it means that it is a final release. Otherwise, this is a pre-release