Skip to content

Commit

Permalink
Merge branch 'main' into cache-post-query
Browse files Browse the repository at this point in the history
  • Loading branch information
jranson authored Dec 3, 2023
2 parents 744e825 + 3ad1b12 commit 13920bd
Show file tree
Hide file tree
Showing 1,449 changed files with 306,359 additions and 38,641 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "monthly"
6 changes: 2 additions & 4 deletions .github/workflows/ci-build-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: [1.17.x]
go: [1.19.x]

steps:

Expand All @@ -38,7 +38,7 @@ jobs:
- name: installing codespell
run: pip install codespell
- name: running codespell
run: codespell --skip="vendor,*.git,*.png,*.pdf,*.tiff,*.plist,*.pem,rangesim*.go,*.gz" --ignore-words="./testdata/ignore_words.txt"
run: codespell --skip="vendor,*.git,*.png,*.pdf,*.tiff,*.plist,*.pem,rangesim*.go,*.gz,go.mod,go.sum" --ignore-words="./testdata/ignore_words.txt"

- uses: actions/setup-go@v1
with:
Expand All @@ -63,8 +63,6 @@ jobs:
path-to-profile: profile.cov
flag-name: Go-${{ matrix.go }}
parallel: true

name: tests results
finish:
needs: build
runs-on: ubuntu-latest
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/fossa.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/publish-beta-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: install golang
uses: actions/setup-go@v2
with:
go-version: '1.17.1'
go-version: '1.19'
- name: Build project
run: |
TAGVER=${{ steps.baretag.outputs.baretag }} make release
Expand All @@ -47,6 +47,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OPATH/trickster-${{ steps.baretag.outputs.baretag }}.tar.gz
asset_path: ./bin/trickster-${{ steps.baretag.outputs.baretag }}.tar.gz
asset_name: trickster-${{ steps.baretag.outputs.baretag }}.tar.gz
asset_content_type: application/gzip
7 changes: 6 additions & 1 deletion .github/workflows/publish-release-candidate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
#
- name: install golang
uses: actions/setup-go@v2
with:
go-version: '1.19'
#
- name: Build project
run: |
TAGVER=${{ steps.baretag.outputs.baretag }} make release
Expand All @@ -43,6 +48,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OPATH/trickster-${{ steps.baretag.outputs.baretag }}.tar.gz
asset_path: ./bin/trickster-${{ steps.baretag.outputs.baretag }}.tar.gz
asset_name: trickster-${{ steps.baretag.outputs.baretag }}.tar.gz
asset_content_type: application/gzip
7 changes: 6 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
#
- name: install golang
uses: actions/setup-go@v2
with:
go-version: '1.19'
#
- name: Build project
run: |
TAGVER=${{ steps.baretag.outputs.baretag }} make release
Expand All @@ -43,6 +48,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./OPATH/trickster-${{ steps.baretag.outputs.baretag }}.tar.gz
asset_path: ./bin/trickster-${{ steps.baretag.outputs.baretag }}.tar.gz
asset_name: trickster-${{ steps.baretag.outputs.baretag }}.tar.gz
asset_content_type: application/gzip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ trickster-data

# output path
OPATH
bin

# MacOS and other operating system artifacts
.DS_Store
Expand Down
16 changes: 16 additions & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,19 @@ v5.0.0.
600
1000
100
microservices-oriented
1.17
InfluxQL
zstd
tsmerge
influxdata's
entrypoint
sharding
sharded
1.19
byterange
420
subextent
subkey
4096
380
9 changes: 9 additions & 0 deletions ADOPTERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Who Is Using Trickster

As the Trickster community grows, we'd like to keep track of who is using it in their stack. We invite you to submit a PR with your company name and @githubhandle to be included on the list.

1. [Comcast](https://comcast.github.io) [[@jranson](https://github.com/jranson)]
2. [Selfnet e.V.](https://www.selfnet.de/) [[@ThoreKr](https://github.com/ThoreKr)]
3. [swarmstack](https://github.com/swarmstack) [[@mh720](https://github.com/mh720)]
4. [Hostinger](https://www.hostinger.com/) [[@ton31337](https://github.com/ton31337)]
5. [The Remote Company (MailerLite, MailerSend, MailerCheck, YCode)](https://www.remotecompany.com) [[@aorfanos]](https://github.com/aorfanos)
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ For complete instructions on how to compile see: [Building From Source](https://
For quickly compiling and testing your changes do:

```bash
# For building.
# For building
make
./OPATH/trickster
./bin/trickster

# For testing.
make test
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# This docker file is for local dev, the official Dockerfile is at
# https://github.com/trickstercache/trickster-docker-images/

FROM golang:1.16 as builder
FROM golang:1.20 as builder
COPY . /go/src/github.com/trickstercache/trickster
WORKDIR /go/src/github.com/trickstercache/trickster

RUN GOOS=linux CGO_ENABLED=0 make build

FROM alpine:3
FROM alpine
LABEL maintainer "The Trickster Authors <trickster-developers@googlegroups.com>"

COPY --from=builder /go/src/github.com/trickstercache/trickster/OPATH/trickster /usr/local/bin/trickster
COPY --from=builder /go/src/github.com/trickstercache/trickster/bin/trickster /usr/local/bin/trickster
COPY examples/conf/example.full.yaml /etc/trickster/trickster.yaml
RUN chown nobody /usr/local/bin/trickster
RUN chmod +x /usr/local/bin/trickster
Expand Down
13 changes: 7 additions & 6 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

| Name | Contact | Company | Term Expires |
|---|---|---|---|
|James Ranson ([@jranson](https://github.com/jranson)) | <james@ranson.org> | Virga | 22/Mar/2022 |
|James Ranson ([@jranson](https://github.com/jranson)) | <james@ranson.org> | Virga | 22/Mar/2024 |

## Trickster Project Maintainers

| Name | Contact | Company | Focus Areas|
|---|---|---|---|
|James Ranson ([@jranson](https://github.com/jranson)) | <james@ranson.org> | Virga | Core Functionality |
|Chris Randles ([@crandles](https://github.com/crandles)) | <randles.chris@gmail.com> | Comcast | Core Functionality |
|Adam Ross ([@LimitlessEarth](https://github.com/LimitlessEarth)) | <adamross1126@gmail.com> | Comcast | Deployment & Artifacts (Makefile, Dockerfile, Helm Charts, etc) |
| Name | Contact | Company | Pronouns | Focus Areas|
|---|---|---|---|---|
|James Ranson ([@jranson](https://github.com/jranson)) | <james@ranson.org> | Virga | He/Him | Core Functionality |
|Jake Nichols ([@jakenichols2719](https://github.com/jakenichols2719)) | <jnichols2719@protonmail.com> | Virga | They/Them | Core Functionality |
|Chris Randles ([@crandles](https://github.com/crandles)) | <randles.chris@gmail.com> | | He/Him | Core Functionality |
|Adam Ross ([@LimitlessEarth](https://github.com/LimitlessEarth)) | <adamross1126@gmail.com> | Amazon | He/Him | Deployment & Artifacts (Makefile, Dockerfile, Helm Charts, etc) |

You can contact the maintainers using the `@trickstercache/maintainers` handle in an Issue or PR, or via email at <cncf-trickster-maintainers@lists.cncf.io>.

Expand Down
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ TRICKSTER := $(FIRST_GOPATH)/bin/trickster
PROGVER := $(shell grep 'applicationVersion = ' $(TRICKSTER_MAIN)/main.go | awk '{print $$3}' | sed -e 's/\"//g')
BUILD_TIME := $(shell date -u +%FT%T%z)
GIT_LATEST_COMMIT_ID := $(shell git rev-parse HEAD)
GO_VER := $(shell go version | awk '{print $$3}')
IMAGE_TAG ?= latest
IMAGE_ARCH ?= amd64
GOARCH ?= amd64
TAGVER ?= unspecified
LDFLAGS =-ldflags "-extldflags '-static' -w -s -X main.applicationBuildTime=$(BUILD_TIME) -X main.applicationGitCommitID=$(GIT_LATEST_COMMIT_ID) -X main.applicationGoVersion=$(GO_VER) -X main.applicationGoArch=$(GOARCH)"
BUILD_SUBDIR := OPATH
LDFLAGS =-ldflags "-extldflags '-static' -w -s -X main.applicationBuildTime=$(BUILD_TIME) -X main.applicationGitCommitID=$(GIT_LATEST_COMMIT_ID)"
BUILD_SUBDIR := bin
PACKAGE_DIR := ./$(BUILD_SUBDIR)/trickster-$(PROGVER)
BIN_DIR := $(PACKAGE_DIR)/bin
CONF_DIR := $(PACKAGE_DIR)/conf
Expand All @@ -55,7 +54,7 @@ test-go-mod:

.PHONY: build
build: go-mod-tidy go-mod-vendor
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=$(CGO_ENABLED) $(GO) build $(LDFLAGS) -o ./$(BUILD_SUBDIR)/trickster -a -v $(TRICKSTER_MAIN)/*.go
CGO_ENABLED=$(CGO_ENABLED) $(GO) build $(LDFLAGS) -o ./$(BUILD_SUBDIR)/trickster -a -v $(TRICKSTER_MAIN)/*.go

rpm: build
mkdir -p ./$(BUILD_SUBDIR)/SOURCES
Expand Down Expand Up @@ -120,7 +119,7 @@ kube-local:

.PHONY: docker
docker:
docker build --build-arg IMAGE_ARCH=$(IMAGE_ARCH) --build-arg GOARCH=$(GOARCH) -f ./deploy/Dockerfile -t trickster:$(PROGVER) .
docker build --build-arg IMAGE_ARCH=$(IMAGE_ARCH) --build-arg GOARCH=$(GOARCH) -f ./Dockerfile -t trickster:$(PROGVER) .

.PHONY: docker-release
docker-release:
Expand Down Expand Up @@ -182,5 +181,17 @@ spelling:
if [[ "$$?" != "0" ]]; then \
echo "codespell is not installed" ; \
else \
codespell --skip='vendor,*.git,*.png,*.pdf,*.tiff,*.plist,*.pem,rangesim*.go,*.gz' --ignore-words='./testdata/ignore_words.txt' ; \
codespell --skip='vendor,*.git,*.png,*.pdf,*.tiff,*.plist,*.pem,rangesim*.go,*.gz,go.sum,go.mod' --ignore-words='./testdata/ignore_words.txt' ; \
fi

.PHONY: serve
serve:
@cd cmd/trickster && go run . -config /etc/trickster/trickster.yaml

.PHONY: serve-debug
serve-debug:
@cd cmd/trickster && go run . -config /etc/trickster/trickster.yaml --log-level debug

.PHONY: serve-info
serve-info:
@cd cmd/trickster && go run . -config /etc/trickster/trickster.yaml --log-level info
14 changes: 2 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Trickster Helm Charts are located at <https://helm.tricksterproxy.io> for instal
### Building from source

To build Trickster from the source code yourself you need to have a working
Go environment with [version 1.17 or greater installed](http://golang.org/doc/install).
Go environment with [version 1.19 or greater installed](http://golang.org/doc/install).

You can directly use the `go` tool to download and install the `trickster`
binary into your `GOPATH`:
Expand All @@ -117,7 +117,7 @@ You can also clone the repository yourself and build using `make`:
$ git clone https://github.com/trickstercache/trickster.git
$ cd trickster
$ make build
$ ./OPATH/trickster -origin-url http://prometheus.example.com:9090 -provider prometheus
$ ./bin/trickster -origin-url http://prometheus.example.com:9090 -provider prometheus
```

The Makefile provides several targets, including:
Expand All @@ -137,14 +137,4 @@ The Makefile provides several targets, including:

Refer to [CONTRIBUTING.md](CONTRIBUTING.md)

## Who Is Using Trickster

As the Trickster community grows, we'd like to keep track of who is using it in their stack. We invite you to submit a PR with your company name and @githubhandle to be included on the list.

1. [Comcast](https://comcast.github.io) [[@jranson](https://github.com/jranson)]
2. [Selfnet e.V.](https://www.selfnet.de/) [[@ThoreKr](https://github.com/ThoreKr)]
3. [swarmstack](https://github.com/swarmstack) [[@mh720](https://github.com/mh720)]
4. [Hostinger](https://www.hostinger.com/) [[@ton31337](https://github.com/ton31337)]
5. [The Remote Company (MailerLite, MailerSend, MailerCheck, YCode)](https://www.remotecompany.com) [[@aorfanos]](https://github.com/aorfanos)

© 2021 The Linux Foundation. All rights reserved. The Linux Foundation has registered trademarks and uses trademarks. For a list of trademarks of The Linux Foundation, please see our [Trademark Usage](https://www.linuxfoundation.org/trademark-usage) page.
29 changes: 15 additions & 14 deletions cmd/trickster/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"net/http"
"os"
goruntime "runtime"
"strings"
"sync"
"time"
Expand All @@ -37,11 +38,9 @@ import (
"github.com/trickstercache/trickster/v2/pkg/observability/metrics"
tr "github.com/trickstercache/trickster/v2/pkg/observability/tracing/registration"
"github.com/trickstercache/trickster/v2/pkg/proxy/handlers"
th "github.com/trickstercache/trickster/v2/pkg/proxy/handlers"
"github.com/trickstercache/trickster/v2/pkg/router"
"github.com/trickstercache/trickster/v2/pkg/routing"
"github.com/trickstercache/trickster/v2/pkg/runtime"

"github.com/gorilla/mux"
)

var cfgLock = &sync.Mutex{}
Expand All @@ -50,7 +49,7 @@ var hc healthcheck.HealthChecker
func runConfig(oldConf *config.Config, wg *sync.WaitGroup, logger *tl.Logger,
oldCaches map[string]cache.Cache, args []string, errorFunc func()) error {

metrics.BuildInfo.WithLabelValues(applicationGoVersion,
metrics.BuildInfo.WithLabelValues(goruntime.Version(),
applicationGitCommitID, applicationVersion).Set(1)

cfgLock.Lock()
Expand Down Expand Up @@ -127,21 +126,22 @@ func applyConfig(conf, oldConf *config.Config, wg *sync.WaitGroup, logger *tl.Lo
}

// every config (re)load is a new router
router := mux.NewRouter()
r := router.NewRouter()
mr := http.NewServeMux()

router.HandleFunc(conf.Main.PingHandlerPath, th.PingHandleFunc(conf)).Methods(http.MethodGet)

r.HandleFunc(conf.Main.PingHandlerPath, handlers.PingHandleFunc(conf)).Methods(http.MethodGet)
var caches = applyCachingConfig(conf, oldConf, logger, oldCaches)
rh := handlers.ReloadHandleFunc(runConfig, conf, wg, logger, caches, args)

o, err := routing.RegisterProxyRoutes(conf, router, mr, caches, tracers, logger, false)
o, err := routing.RegisterProxyRoutes(conf, r, mr, caches, tracers, logger, false)
if err != nil {
handleStartupIssue("route registration failed", tl.Pairs{"detail": err.Error()},
logger, errorFunc)
return err
}

r.HandleFunc(conf.Main.PurgeKeyHandlerPath, handlers.PurgeKeyHandleFunc(conf, o)).Methods(http.MethodDelete)

if hc != nil {
hc.Shutdown()
}
Expand All @@ -150,9 +150,9 @@ func applyConfig(conf, oldConf *config.Config, wg *sync.WaitGroup, logger *tl.Lo
return err
}
alb.StartALBPools(o, hc.Statuses())
routing.RegisterDefaultBackendRoutes(router, o, logger, tracers)
routing.RegisterDefaultBackendRoutes(r, o, logger, tracers)
routing.RegisterHealthHandler(mr, conf.Main.HealthHandlerPath, hc)
applyListenerConfigs(conf, oldConf, router, http.HandlerFunc(rh), mr, logger, tracers)
applyListenerConfigs(conf, oldConf, r, http.HandlerFunc(rh), mr, logger, tracers, o)

metrics.LastReloadSuccessfulTimestamp.Set(float64(time.Now().Unix()))
metrics.LastReloadSuccessful.Set(1)
Expand Down Expand Up @@ -263,8 +263,9 @@ func initLogger(c *config.Config) *tl.Logger {
tl.Pairs{
"name": runtime.ApplicationName,
"version": runtime.ApplicationVersion,
"goVersion": applicationGoVersion,
"goArch": applicationGoArch,
"goVersion": goruntime.Version(),
"goArch": goruntime.GOARCH,
"goOS": goruntime.GOOS,
"commitID": applicationGitCommitID,
"buildTime": applicationBuildTime,
"logLevel": c.Logging.LogLevel,
Expand Down Expand Up @@ -315,7 +316,7 @@ func validateConfig(conf *config.Config) error {
caches[k] = nil
}

router := mux.NewRouter()
r := router.NewRouter()
mr := http.NewServeMux()
logger := tl.ConsoleLogger(conf.Logging.LogLevel)

Expand All @@ -324,7 +325,7 @@ func validateConfig(conf *config.Config) error {
return err
}

_, err = routing.RegisterProxyRoutes(conf, router, mr, caches, tracers, logger, true)
_, err = routing.RegisterProxyRoutes(conf, r, mr, caches, tracers, logger, true)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit 13920bd

Please sign in to comment.