Skip to content

Commit

Permalink
[CC-4519] Include Consul NodeID in Envoy bootstrap metadata (#17139)
Browse files Browse the repository at this point in the history
This is being added so that metrics sent to HCP can be augmented with the source node's ID.

Opting not to add this to stats_tag out of caution, since it would increase the cardinality of metrics emitted by Envoy for all users.

There is no functional impact to Envoy expected from this change.
  • Loading branch information
freddygv authored Apr 26, 2023
1 parent 75669ed commit c5c35ec
Show file tree
Hide file tree
Showing 42 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions command/connect/envoy/bootstrap_tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ type BootstrapTplArgs struct {
// the agent to deliver the correct configuration.
ProxyID string

// NodeID is the ID of the node on which the proxy service instance is registered.
NodeID string

// NodeName is the name of the node on which the proxy service instance is registered.
NodeName string

Expand Down Expand Up @@ -184,6 +187,7 @@ const bootstrapTemplate = `{
{{- if .NodeName }}
"node_name": "{{ .NodeName }}",
{{- end }}
"node_id": "{{ .NodeID }}",
"namespace": "{{if ne .Namespace ""}}{{ .Namespace }}{{else}}default{{end}}",
"partition": "{{if ne .Partition ""}}{{ .Partition }}{{else}}default{{end}}"
}
Expand Down
6 changes: 6 additions & 0 deletions command/connect/envoy/envoy.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,12 @@ func (c *cmd) generateConfig() ([]byte, error) {
args.Datacenter = datacenter
}

info, err := c.client.Agent().Self()
if err != nil {
return nil, err
}
args.NodeID, _ = info["Config"]["NodeID"].(string)

if err := generateAccessLogs(c, args); err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/envoy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,7 @@ func testMockAgentSelf(
resp := agent.Self{
Config: map[string]interface{}{
"Datacenter": "dc1",
"NodeID": "7cbef9fc-4fb1-4c84-b100-689db9755449",
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/access-log-path.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/access-logs-enabled.golden
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/defaults-nodemeta.golden
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"id": "test-proxy",
"metadata": {
"node_name": "test-node",
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/defaults.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/existing-ca-file.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/existing-ca-path.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/extra_-multiple.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/extra_-single.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/grpc-addr-env.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/grpc-addr-flag.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/grpc-addr-unix.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/grpc-tls-addr-config.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/hcp-metrics.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "ingress-gateway",
"id": "ingress-gateway",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "ingress-gateway",
"id": "ingress-gateway",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"id": "ingress-gateway-1",
"metadata": {
"node_name": "test-node",
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "my-gateway-123",
"id": "my-gateway-123",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "my-gateway",
"id": "my-gateway",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/ingress-gateway.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "ingress-gateway-1",
"id": "ingress-gateway-1",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/prometheus-metrics.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/token-arg.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/token-env.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/token-file-arg.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/token-file-env.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
1 change: 1 addition & 0 deletions command/connect/envoy/testdata/xds-addr-config.golden
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"cluster": "test",
"id": "test-proxy",
"metadata": {
"node_id": "7cbef9fc-4fb1-4c84-b100-689db9755449",
"namespace": "default",
"partition": "default"
}
Expand Down

0 comments on commit c5c35ec

Please sign in to comment.