[CC-4361] Add HCPMetricsBindSocketDir to Envoy bootstrap config#90
Conversation
959a65e to
c6f02df
Compare
|
As we try to add support for VMs to consul-dataplane in the future, I believe using a Unix socket going to be problematic for Windows. Is this a cause for concern? |
|
After some discussion, it looks like Envoy only supports at least Windows 10, see here, which supports unix sockets, here is the go support. We'd like to move forward with this, revisit and test as needed when Windows support is in the works. We can always provide an alternative configuration mode for Windows in the worst case if the need arises. |
hashi-derek
left a comment
There was a problem hiding this comment.
This looks good after having a discussion with Freddy about the feature. Just putting some minor nits here that you don't necessarily have to address.
| {{- if .StatsSinksJSON }} | ||
| "stats_sinks": {{ .StatsSinksJSON }}, | ||
| "stats_sinks": [ | ||
| {{ .StatsSinksJSON }} |
There was a problem hiding this comment.
Rather than defining this as a single value and worrying about concatenating commas in the go code, couldn't we make this variable a slice of strings and do the , joining in the template?
There was a problem hiding this comment.
Yeah I agree the current state isn't ideal... I'd prefer to park this scope-wise!
I believe I'd have to convert the actual BootstrapConfig StatsConfigJSON to a list internally due to these lines
consul-dataplane/internal/bootstrap/bootstrap_config.go
Lines 194 to 196 in dc0da3c
These changes would also affect most test and quite a few areas of the code in bootstrap_config.go and boostrap_config_test.go.
My initial thought seeing this package was maybe there might be a better cleanup that could be done here using marshalling/unmarshalling, although this introduces with defining structs/models, it might reduce the code logic complexity and cleanup a most of these handlings in the code.
But yeah I totally agree the newline handling etc. is not super pretty, I'm also happy to maybe make a follow up PR if that works?
| dir += "/" | ||
| } | ||
|
|
||
| path := fmt.Sprintf("%s%s_%s.sock",dir,args.Namespace,args.ProxyID) |
There was a problem hiding this comment.
After testing locally with @freddygv , looks like the Namespace is always default, so we remove the if statement.
We discussed having a safety check to that normalizes to default (e.g. Consul equivalent) but removed it for code simplicity.
This PR is very similar to hashicorp/consul#16511 in
consulBackground
The HCP Cloud team is working on enabling observability metrics in HCP.
In particular, we want to forward Envoy metrics.
This PR aims to allow Envoy bootstrap configuration of
envoy_hcp_metrics_bind_socket_dir, a directory where a unix socket will be created with the name<namespace>_<proxy_id>.sockto forward Envoy metrics.Code changes
internal/bootstrap/bootstrap_config.go: Add aHCPMetricsBindSocketDirstring type in theBootstrapConfigstruct and a functionappendHCPMetricsConfigto generate the socket name, configure the stats sink and cluster for metrics forwarding.internal/bootstrap/bootstrap_config_test.go: add relevant tests to the abovepkg/consuldp/bootstrap_test.go: Add a test to generate a golden test fileinternal/bootstrap/bootstrap_tpl.go: small change to move brackets[]into the template instead, which facilitates config generationNext Steps
There will be a follow-up PR to generate a listener and cluster dynamically that will be listening on this socket
That listener and cluster will be configured to route to collector instances through the service mesh.
Caveat: we needed to add this local listener indirection as a workaround due to this issue