Skip to content

Commit

Permalink
backport of commit d03729c
Browse files Browse the repository at this point in the history
  • Loading branch information
DanStough committed May 12, 2023
1 parent 8fd981f commit 19e514a
Show file tree
Hide file tree
Showing 45 changed files with 42 additions and 165 deletions.
3 changes: 3 additions & 0 deletions .changelog/106.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
Fix a bug that threw an error when trying to use `$HOST_IP` with metrics URLs.
```
3 changes: 0 additions & 3 deletions .changelog/97.txt

This file was deleted.

3 changes: 3 additions & 0 deletions .changelog/98.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:security
Update to Go 1.20.4 and Envoy 1.25.6 within the Dockerfile.
```
27 changes: 0 additions & 27 deletions .github/workflows/backport-assistant.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/bot-auto-approve.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@ jobs:
image: docker.mirror.hashicorp.services/hashicorp/consul:1.14.4
- version: v1.15.0-dev
image: hashicorppreview/consul:1.15-dev
- version: v1.16.0-dev
image: hashicorppreview/consul:1.16-dev
dataplane:
- image_suffix: "dev"
docker_target: "release-default"
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/consul-dataplane-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ name: consul-dataplane-checks
on:
push:
branches:
- main
- 'release/*.*.x'
main
pull_request:

jobs:
Expand Down Expand Up @@ -58,4 +57,4 @@ jobs:
go-version: ${{ needs.get-go-version.outputs.go-version }}
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v3
3 changes: 0 additions & 3 deletions .release/ci.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

schema = "1"

project "consul-dataplane" {
Expand Down
3 changes: 0 additions & 3 deletions .release/release-metadata.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

url_docker_registry_dockerhub = "https://hub.docker.com/r/hashicorp/consul-dataplane"
url_docker_registry_ecr = "https://gallery.ecr.aws/hashicorp/consul-dataplane"
url_source_repository = "https://github.com/hashicorp/consul-dataplane"
Expand Down
3 changes: 0 additions & 3 deletions .release/security-scan.hcl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

container {
dependencies = true
alpine_secdb = true
Expand Down
5 changes: 1 addition & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

# This Dockerfile contains multiple targets.
# Use 'docker build --target=<name> .' to build one.
#
Expand All @@ -9,7 +6,7 @@

# envoy-binary pulls in the latest Envoy binary, as Envoy don't publish
# prebuilt binaries in any other form.
FROM envoyproxy/envoy-distroless:v1.26.1 as envoy-binary
FROM envoyproxy/envoy-distroless:v1.25.6 as envoy-binary

# go-discover builds the discover binary (which we don't currently publish
# either).
Expand Down
3 changes: 0 additions & 3 deletions build-scripts/version.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/env bash
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0


version_file=$1
version=$(awk '$1 == "Version" && $2 == "=" { gsub(/"/, "", $3); print $3 }' < "${version_file}")
Expand Down
3 changes: 0 additions & 3 deletions cmd/consul-dataplane/env.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package main

import (
Expand Down
3 changes: 0 additions & 3 deletions cmd/consul-dataplane/flags.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package main

// This file contains flag wrappers that support reading from an environment
Expand Down
3 changes: 0 additions & 3 deletions cmd/consul-dataplane/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package main

import (
Expand Down
3 changes: 0 additions & 3 deletions cmd/consul-dataplane/map_flag.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package main

import (
Expand Down
3 changes: 0 additions & 3 deletions cmd/consul-dataplane/map_flag_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package main

import (
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/helpers/auth_method.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package helpers

import (
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/helpers/dataplane.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package helpers

import (
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/helpers/helpers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package helpers

import (
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/helpers/pod.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package helpers

import (
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/helpers/server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package helpers

import (
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/helpers/service.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package helpers

import (
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/helpers/suite.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package helpers

import (
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/helpers/tls.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package helpers

import (
Expand Down
3 changes: 0 additions & 3 deletions integration-tests/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package integrationtests

import (
Expand Down
3 changes: 0 additions & 3 deletions internal/bootstrap/helpers_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package bootstrap

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/consuldp/bootstrap.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/consuldp/bootstrap_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/consuldp/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/consuldp/config_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/consuldp/consul_dataplane.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/consuldp/consul_dataplane_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import (
Expand Down
22 changes: 19 additions & 3 deletions pkg/consuldp/metrics.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import (
Expand All @@ -9,6 +6,7 @@ import (
"io"
"net/http"
"net/url"
"os"
"strconv"
"sync"
"time"
Expand Down Expand Up @@ -108,6 +106,18 @@ func NewMetricsConfig(cfg *Config, cacheSink *metricscache.Sink) *metricsConfig
}
}

func statsSinkEnvMapping(s string) string {
allowedStatsSinkEnvVars := map[string]bool{
"HOST_IP": true,
}

if !allowedStatsSinkEnvVars[s] {
// if the specified env var isn't explicitly allowed, unexpand it
return fmt.Sprintf("${%s}", s)
}
return os.Getenv(s)
}

func (m *metricsConfig) startMetrics(ctx context.Context, bcfg *bootstrap.BootstrapConfig) error {
m.mu.Lock()
defer m.mu.Unlock()
Expand Down Expand Up @@ -360,6 +370,12 @@ func (m *metricsConfig) runPrometheusCDPServer(gather prom.Gatherer) {
}

func parseSinkAddr(addr string, s Stats) (string, error) {
if len(addr) > 2 && addr[0] == '$' {
addr = os.Getenv(addr[1:])
} else {
addr = os.Expand(addr, statsSinkEnvMapping)
}

u, err := url.Parse(addr)
if err != nil {
return "", fmt.Errorf("failed to parse address %s", addr)
Expand Down
15 changes: 12 additions & 3 deletions pkg/consuldp/metrics_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import (
Expand Down Expand Up @@ -465,7 +462,19 @@ func TestParseAddr(t *testing.T) {
s: Dogstatsd,
expectedErr: errors.New("unsupported addr: tcp://0.0.0.0:1234 for sink type: dogstatsD"),
},
"dogstatsd HOST_IP": {
addr: "udp://${HOST_IP}:1234",
s: Dogstatsd,
expectedAddr: "1.2.3.4:1234",
},
"dogstatsd bad env var": {
addr: "udp://${NOT_SUPPORTED}:1234",
s: Dogstatsd,
expectedErr: errors.New("failed to parse address udp://${NOT_SUPPORTED}:1234"),
},
}

t.Setenv("HOST_IP", "1.2.3.4")
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
addr, err := parseSinkAddr(tc.addr, tc.s)
Expand Down
3 changes: 0 additions & 3 deletions pkg/consuldp/stats.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import "github.com/armon/go-metrics/prometheus"
Expand Down
3 changes: 0 additions & 3 deletions pkg/consuldp/xds.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/consuldp/xds_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package consuldp

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/dns/dns.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package dns

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/dns/dns_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package dns

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/envoy/proxy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package envoy

import (
Expand Down
3 changes: 0 additions & 3 deletions pkg/envoy/proxy_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package envoy

import (
Expand Down
Loading

0 comments on commit 19e514a

Please sign in to comment.