Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ GOBIN ?= $(GOPATH)/bin

# Get local ARCH; on Intel Mac, 'uname -m' returns x86_64 which we turn into amd64.
# Not using 'go env GOOS/GOARCH' here so 'make docker' will work without local Go install.
ARCH = $(shell A=$$(uname -m); [ $$A = x86_64 ] && A=amd64; echo $$A)
OS = $(shell uname | tr [[:upper:]] [[:lower:]])
ARCH ?= $(shell A=$$(uname -m); [ $$A = x86_64 ] && A=amd64; echo $$A)
OS ?= $(shell uname | tr [[:upper:]] [[:lower:]])
PLATFORM = $(OS)/$(ARCH)
DIST = dist/$(PLATFORM)
BIN = $(DIST)/$(BIN_NAME)
Expand Down
13 changes: 1 addition & 12 deletions internal/bootstrap/bootstrap_tpl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions pkg/consuldp/testdata/TestBootstrapConfig/basic.golden
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,7 @@
"api_type": "DELTA_GRPC",
"transport_api_version": "V3",
"grpc_services": {
"initial_metadata": [
{
"key": "x-consul-token",
"value": ""
}
],
"initial_metadata": [],
"envoy_grpc": {
"cluster_name": "consul-dataplane"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,7 @@
"api_type": "DELTA_GRPC",
"transport_api_version": "V3",
"grpc_services": {
"initial_metadata": [
{
"key": "x-consul-token",
"value": ""
}
],
"initial_metadata": [],
"envoy_grpc": {
"cluster_name": "consul-dataplane"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,7 @@
"api_type": "DELTA_GRPC",
"transport_api_version": "V3",
"grpc_services": {
"initial_metadata": [
{
"key": "x-consul-token",
"value": ""
}
],
"initial_metadata": [],
"envoy_grpc": {
"cluster_name": "consul-dataplane"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,7 @@
"api_type": "DELTA_GRPC",
"transport_api_version": "V3",
"grpc_services": {
"initial_metadata": [
{
"key": "x-consul-token",
"value": ""
}
],
"initial_metadata": [],
"envoy_grpc": {
"cluster_name": "consul-dataplane"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,7 @@
"api_type": "DELTA_GRPC",
"transport_api_version": "V3",
"grpc_services": {
"initial_metadata": [
{
"key": "x-consul-token",
"value": ""
}
],
"initial_metadata": [],
"envoy_grpc": {
"cluster_name": "consul-dataplane"
}
Expand Down
31 changes: 4 additions & 27 deletions pkg/envoy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import (
"errors"
"fmt"
"io"
"log"
"os"
"os/exec"
"path/filepath"
"strings"
"sync/atomic"
"syscall"
"time"

"github.com/hashicorp/go-hclog"
Expand Down Expand Up @@ -179,40 +179,17 @@ func writeBootstrapConfig(cfg []byte) (string, func() error, error) {
os.TempDir(),
fmt.Sprintf("envoy-%x-bootstrap.json", time.Now().UnixNano()+int64(os.Getpid())),
)
if err := syscall.Mkfifo(path, 0600); err != nil {
return "", nil, err
}

// O_WRONLY causes OpenFile to block until there's a reader (Envoy). Opening
// the pipe with O_RDWR wouldn't block but would result in just sending stuff
// to ourself.
//
// TODO(boxofrad): We don't have a way to cancel this goroutine. If the Envoy
// process never opens the other end of the pipe this will hang forever. The
// workaround we use in `consul connect envoy` is to write to the pipe in a
// subprocess that self-destructs after 10 minutes.
go func() {
file, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND, 0600)
if err != nil {
os.Remove(path)
return
}

_, err = file.Write(cfg)
file.Close()

if err != nil {
os.Remove(path)
}
}()
log.Printf("bootstrap config path: %s", path)
err := os.WriteFile(path, cfg, 0600)

return path, func() error {
err := os.Remove(path)
if err == nil || errors.Is(err, os.ErrNotExist) {
return nil
}
return err
}, nil
}, err
}

// buildCommand builds the exec.Cmd to run Envoy with the relevant arguments
Expand Down