Skip to content

Commit

Permalink
Merge pull request #82 from supabase/da/consul-upgrades
Browse files Browse the repository at this point in the history
Revert consul-template to latest upstream
  • Loading branch information
HeavyHorst authored Feb 26, 2022
2 parents cafbbf0 + b4f2536 commit fff7b7a
Show file tree
Hide file tree
Showing 2,356 changed files with 312 additions and 777,263 deletions.
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

BIN_NAME := bin/remco

GOARCH ?= amd64

VERSION := 0.12.1
GIT_COMMIT := $(shell git rev-parse HEAD)
GIT_DIRTY := $(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
Expand All @@ -20,11 +22,11 @@ GO_TEST_SRC := $(shell find ./ -type f -name '*_test.go')

GO := go

GO_OPTS := -mod=vendor
GO_OPTS := -mod=mod

OS_LIST := linux darwin windows

OUT_RELEASE_ZIP := $(addsuffix _amd64.zip, $(addprefix bin/remco_$(VERSION)_, $(OS_LIST)))
OUT_RELEASE_ZIP := $(addsuffix _$(GOARCH).zip, $(addprefix bin/remco_$(VERSION)_, $(OS_LIST)))

default: build

Expand Down Expand Up @@ -98,7 +100,7 @@ tag:
release: $(OUT_RELEASE_ZIP)

$(OUT_RELEASE_ZIP): $(GO_SRC)
CGO_ENABLED=0 GOOS=$(subst bin/remco_${VERSION}_,,$(subst _amd64.zip,,$@)) \
GOARCH=$(GOARCH) CGO_ENABLED=0 GOOS=$(subst bin/remco_${VERSION}_,,$(subst _$(GOARCH).zip,,$@)) \
$(MAKE) build \
BIN_NAME=$(subst ${VERSION}_,,$(subst _amd64.zip,,$@))
cd bin && zip -r $(shell basename $@) $(shell basename $(subst ${VERSION}_,,$(subst _amd64.zip,,$@)))
BIN_NAME=$(subst ${VERSION}_,,$(subst _$(GOARCH).zip,,$@))
cd bin && zip -r $(shell basename $@) $(shell basename $(subst ${VERSION}_,,$(subst _$(GOARCH).zip,,$@)))
18 changes: 4 additions & 14 deletions cmd/remco/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/HeavyHorst/remco/pkg/telemetry"
"github.com/HeavyHorst/remco/pkg/template"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

// BackendConfigs holds every individually backend config.
Expand Down Expand Up @@ -141,9 +140,9 @@ func NewConfiguration(path string) (Configuration, error) {
if strings.HasSuffix(file.Name(), ".toml") {
fp := filepath.Join(c.IncludeDir, file.Name())

log.WithFields(logrus.Fields{
"path": fp,
}).Info("loading resource configuration")
log.WithFields(
"path", fp,
).Info("loading resource configuration")

buf, err := readFileAndExpandEnv(fp)
if err != nil {
Expand Down Expand Up @@ -180,14 +179,5 @@ func NewConfiguration(path string) (Configuration, error) {
// configureLogger configures the global logger.
// It sets the log level and log formatting.
func (c *Configuration) configureLogger() {
err := log.SetLevel(c.LogLevel)
if err != nil {
log.Error(err)
}
log.SetFormatter(c.LogFormat)

err = log.SetOutput(c.LogFile)
if err != nil {
log.Error(err)
}
log.InitializeLogging(c.LogFormat, c.LogLevel)
}
11 changes: 5 additions & 6 deletions cmd/remco/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/HeavyHorst/remco/pkg/log"
"github.com/hashicorp/consul-template/signals"
"github.com/hashicorp/go-reap"
"github.com/sirupsen/logrus"
)

var (
Expand All @@ -46,7 +45,7 @@ func run() int32 {

cfg, err := NewConfiguration(configPath)
if err != nil {
log.Fatal(err)
log.Fatal("failed to read config", err)
}

if onetime {
Expand Down Expand Up @@ -79,12 +78,12 @@ func run() int32 {
case s := <-signalChan:
switch s {
case syscall.SIGHUP:
log.WithFields(logrus.Fields{
"file": configPath,
}).Info("loading new config")
log.WithFields(
"file", configPath,
).Info("loading new config")
newConf, err := NewConfiguration(configPath)
if err != nil {
log.Error(err)
log.Error("failed to read config", err)
continue
}
run.Reload(newConf)
Expand Down
18 changes: 9 additions & 9 deletions cmd/remco/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/HeavyHorst/remco/pkg/template"
"github.com/pborman/uuid"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

type reloadSignal struct {
Expand Down Expand Up @@ -62,7 +61,7 @@ func NewSupervisor(cfg Configuration, reapLock *sync.RWMutex, done chan struct{}
pid := os.Getpid()
err := w.writePid(pid)
if err != nil {
log.WithFields(logrus.Fields{"pid_file": w.pidFile}).Error(err)
log.WithFields("pid_file", w.pidFile).Error("failed to write pidfile", err)
}

stopChan := make(chan struct{})
Expand All @@ -87,12 +86,12 @@ func NewSupervisor(cfg Configuration, reapLock *sync.RWMutex, done chan struct{}
if rs.c.PidFile != w.pidFile {
err := w.deletePid()
if err != nil {
log.WithFields(logrus.Fields{"pid_file": w.pidFile}).Error(err)
log.WithFields("pid_file", w.pidFile).Error("failed to delete pidfile", err)
}
w.pidFile = rs.c.PidFile
err = w.writePid(pid)
if err != nil {
log.WithFields(logrus.Fields{"pid_file": w.pidFile}).Error(err)
log.WithFields("pid_file", w.pidFile).Error("failed to write pidfile", err)
}
}
err = w.telemetry.Stop()
Expand Down Expand Up @@ -214,7 +213,7 @@ func (ru *Supervisor) runResource(r []Resource, stop, stopped chan struct{}) {
}
res, err := template.NewResourceFromResourceConfig(ctx, ru.reapLock, rsc)
if err != nil {
log.Error(err)
log.Error("failed to create new resource", err)
ru.incResourceError()
return
}
Expand All @@ -240,9 +239,10 @@ func (ru *Supervisor) runResource(r []Resource, stop, stopped chan struct{}) {
go func() {
// try to restart the resource after a random amount of time
rn := rand.Int63n(30)
log.WithFields(logrus.Fields{
"resource": r.Name,
}).Error(fmt.Sprintf("resource execution failed, restarting after %d seconds", rn))
log.WithFields(
"resource", r.Name,
"restartDelay", rn,
).Error("resource execution failed, restarting after delay")
time.Sleep(time.Duration(rn) * time.Second)
select {
case <-ctx.Done():
Expand Down Expand Up @@ -297,7 +297,7 @@ func (ru *Supervisor) Stop() int32 {
// remove the pidfile
err := ru.deletePid()
if err != nil {
log.WithFields(logrus.Fields{"pid_file": ru.pidFile}).Error(err)
log.WithFields("pid_file", ru.pidFile).Error("failed to delete pidfile", err)
}
return ru.getNumResourceErrors()
}
88 changes: 80 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,34 +1,106 @@
module github.com/HeavyHorst/remco

go 1.16
go 1.17

require (
github.com/BurntSushi/toml v0.3.1
github.com/HeavyHorst/consul-template v0.17.0
github.com/HeavyHorst/easykv v1.2.7
github.com/HeavyHorst/memkv v1.0.1
github.com/HeavyHorst/pongo2 v3.3.0+incompatible
github.com/armon/go-metrics v0.3.10
github.com/dlclark/regexp2 v1.2.0 // indirect
github.com/dop251/goja v0.0.0-20190912223329-aa89e6a4c733
github.com/go-sourcemap/sourcemap v2.1.2+incompatible // indirect
github.com/hashicorp/consul-template v0.22.0
github.com/hashicorp/consul-template v0.27.3-0.20220208002550-14a926e0b74a
github.com/hashicorp/go-hclog v1.0.0
github.com/hashicorp/go-reap v0.0.0-20170704170343-bf58d8a43e7b
github.com/juju/errors v0.0.0-20190930114154-d42613fe1ab9 // indirect
github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8 // indirect
github.com/juju/testing v0.0.0-20191001232224-ce9dec17d28b // indirect
github.com/mattn/go-shellwords v1.0.6
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/natefinch/pie v0.0.0-20170715172608-9a0d72014007
github.com/onsi/ginkgo v1.10.3 // indirect
github.com/onsi/gomega v1.7.1 // indirect
github.com/pborman/uuid v1.2.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0
github.com/sirupsen/logrus v1.6.0
github.com/x-cray/logrus-prefixed-formatter v0.5.2
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
sigs.k8s.io/yaml v1.2.0
)

require (
github.com/armon/go-radix v1.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/coreos/etcd v3.3.27+incompatible // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/garyburd/redigo v1.6.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.1.2 // indirect
github.com/hashicorp/consul/api v1.11.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.4.3 // indirect
github.com/hashicorp/go-retryablehttp v0.7.0 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-secure-stdlib/mlock v0.1.1 // indirect
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.2 // indirect
github.com/hashicorp/go-secure-stdlib/strutil v0.1.1 // indirect
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
github.com/hashicorp/go-uuid v1.0.2 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.9.5 // indirect
github.com/hashicorp/vault/api v1.3.0 // indirect
github.com/hashicorp/vault/sdk v0.3.0 // indirect
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.26.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/tevino/go-zookeeper v0.0.0-20170512024026-c218ec636bef // indirect
go.etcd.io/etcd v3.3.27+incompatible // indirect
go.etcd.io/etcd/api/v3 v3.5.2 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.2 // indirect
go.etcd.io/etcd/client/v2 v2.305.1 // indirect
go.etcd.io/etcd/client/v3 v3.5.2 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/genproto v0.0.0-20220217155828-d576998c0009 // indirect
google.golang.org/grpc v1.44.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit fff7b7a

Please sign in to comment.