Skip to content

Commit

Permalink
[1.15.x][CC-4519] Include Consul NodeID in Envoy bootstrap metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
freddygv authored Apr 26, 2023
1 parent 02b980e commit 800d925
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 @@ -14,6 +14,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 @@ -181,6 +184,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 @@ -719,6 +719,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 @@ -1688,6 +1688,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 800d925

Please sign in to comment.