Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TT-13723] Update to Go 1.23 #6812

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
fail-fast: false
matrix:
redis-version: [7]
go-version: [1.22.x]
go-version: [1.23.x]

env:
REDIS_IMAGE: redis:${{ matrix.redis-version }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/plugin-compiler-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- "v*"

env:
GOLANG_CROSS: 1.22-bullseye
GOLANG_CROSS: 1.23-bullseye

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
labels: ${{ steps.set-metadata.outputs.labels }}
tags: ${{ steps.set-metadata.outputs.tags }}
build-args: |
BASE-IMAGE=tykio/golang-cross:${{ env.GOLANG_CROSS }}
BASE_IMAGE=tykio/golang-cross:${{ env.GOLANG_CROSS }}
GITHUB_SHA=${{ github.sha }}
GITHUB_TAG=${{ github.ref_name }}

Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
labels: ${{ steps.set-metadata-ee.outputs.labels }}
tags: ${{ steps.set-metadata-ee.outputs.tags }}
build-args: |
BASE-IMAGE=tykio/golang-cross:${{ env.GOLANG_CROSS }}
BASE_IMAGE=tykio/golang-cross:${{ env.GOLANG_CROSS }}
GITHUB_SHA=${{ github.sha }}
GITHUB_TAG=${{ github.ref_name }}
BUILD_TAG=ee
22 changes: 11 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- master
- release-**
tags:
- 'v*'

Check warning on line 24 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / test-controller-distros

Using test variation

Check warning on line 24 in .github/workflows/release.yml

View workflow job for this annotation

GitHub Actions / test-controller-api

Using non-prod variation
env:
GOPRIVATE: github.com/TykTechnologies
VARIATION: inverted
Expand All @@ -41,9 +41,9 @@
fail-fast: false
matrix:
golang_cross:
- 1.22-bullseye
- 1.23-bullseye
include:
- golang_cross: 1.22-bullseye
- golang_cross: 1.23-bullseye
goreleaser: 'ci/goreleaser/goreleaser.yml'
cgo: 1
rpmvers: 'el/7 el/8 el/9 amazon/2 amazon/2023'
Expand Down Expand Up @@ -127,12 +127,12 @@
mask-aws-account-id: false
- uses: aws-actions/amazon-ecr-login@v2
id: ecr
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
if: ${{ matrix.golang_cross == '1.23-bullseye' }}
with:
mask-password: 'true'
- name: Docker metadata for CI
id: ci_metadata_
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
if: ${{ matrix.golang_cross == '1.23-bullseye' }}
uses: docker/metadata-action@v5
with:
images: ${{ steps.ecr.outputs.registry }}/tyk
Expand All @@ -146,7 +146,7 @@
type=semver,pattern={{major}}.{{minor}},prefix=v
type=semver,pattern={{version}},prefix=v
- name: push image to CI
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
if: ${{ matrix.golang_cross == '1.23-bullseye' }}
uses: docker/build-push-action@v6
with:
context: "dist"
Expand All @@ -163,7 +163,7 @@
EDITION=
- name: Docker metadata for CI ee
id: ci_metadata_ee
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
if: ${{ matrix.golang_cross == '1.23-bullseye' }}
uses: docker/metadata-action@v5
with:
images: ${{ steps.ecr.outputs.registry }}/tyk-ee
Expand All @@ -177,7 +177,7 @@
type=semver,pattern={{major}}.{{minor}},prefix=v
type=semver,pattern={{version}},prefix=v
- name: push image to CI ee
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
if: ${{ matrix.golang_cross == '1.23-bullseye' }}
uses: docker/build-push-action@v6
with:
context: "dist"
Expand Down Expand Up @@ -207,7 +207,7 @@
type=semver,pattern={{version}}
labels: "org.opencontainers.image.title=tyk-gateway (distroless) \norg.opencontainers.image.description=Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols\norg.opencontainers.image.vendor=tyk.io\norg.opencontainers.image.version=${{ github.ref_name }}\n"
- name: push image to prod
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
if: ${{ matrix.golang_cross == '1.23-bullseye' }}
uses: docker/build-push-action@v6
with:
context: "dist"
Expand Down Expand Up @@ -236,7 +236,7 @@
type=semver,pattern={{version}}
labels: "org.opencontainers.image.title=tyk-gateway Enterprise Edition (distroless) \norg.opencontainers.image.description=Tyk Open Source API Gateway written in Go, supporting REST, GraphQL, TCP and gRPC protocols\norg.opencontainers.image.vendor=tyk.io\norg.opencontainers.image.version=${{ github.ref_name }}\n"
- name: push image to prod ee
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
if: ${{ matrix.golang_cross == '1.23-bullseye' }}
uses: docker/build-push-action@v6
with:
context: "dist"
Expand All @@ -253,7 +253,7 @@
EDITION=-ee
- name: save deb
uses: actions/upload-artifact@v4
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
if: ${{ matrix.golang_cross == '1.23-bullseye' }}
with:
name: deb
retention-days: 1
Expand All @@ -263,7 +263,7 @@
!dist/*fips*.deb
- name: save rpm
uses: actions/upload-artifact@v4
if: ${{ matrix.golang_cross == '1.22-bullseye' }}
if: ${{ matrix.golang_cross == '1.23-bullseye' }}
with:
name: rpm
retention-days: 1
Expand Down
62 changes: 11 additions & 51 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,68 +1,28 @@
FROM debian:bookworm AS assets

# This Dockerfile facilitates bleeding edge development docker image builds
# directly from source. To build a development image, run `make docker`.
# If you need to tweak the environment for testing, you can override the
# `GO_VERSION` and `PYTHON_VERSION` as docker build arguments.

ARG GO_VERSION=1.22.6
ARG PYTHON_VERSION=3.11.6

WORKDIR /assets

RUN apt update && apt install wget -y && \
wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
wget -q https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz

FROM debian:bookworm

ARG GO_VERSION=1.22.6
ARG PYTHON_VERSION=3.11.6

COPY --from=assets /assets/ /tmp/
WORKDIR /tmp

# Install Go

ENV PATH=$PATH:/usr/local/go/bin

RUN tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz && \
go version
ARG GO_VERSION=1.23
FROM golang:${GO_VERSION}-bullseye

# Build essentials

RUN apt update && apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl wget libbz2-dev -y

# Install $PYTHON_VERSION

## This just installs whatever is is bullseye, makes docker build (fast/small)-(er)
RUN apt install python3 -y

## This runs python code slower, but the process finishes quicker
# RUN tar -xf Python-${PYTHON_VERSION}.tar.xz && ls -la && \
# cd Python-${PYTHON_VERSION}/ && \
# ./configure --enable-shared && make build_all && \
# make altinstall && \
# ldconfig $PWD

## This runs python code faster, but is expensive to build and runs regression tests
# RUN tar -xf Python-${PYTHON_VERSION}.tar.xz && ls -la && \
# cd Python-${PYTHON_VERSION}/ && \
# ./configure --enable-shared --enable-optimizations && make -j 2 && \
# make altinstall && \
# ldconfig $PWD

# Clean up build assets
RUN find /tmp -type f -delete

# Build gateway
RUN mkdir /opt/tyk-gateway
WORKDIR /opt/tyk-gateway

ADD go.mod go.sum /opt/tyk-gateway/
RUN go mod download

RUN --mount=type=cache,mode=0755,target=/go/pkg/mod \
--mount=type=cache,mode=0755,target=/root/.cache/go-build \
go mod download

ADD . /opt/tyk-gateway

RUN make build
RUN --mount=type=cache,mode=0755,target=/go/pkg/mod \
--mount=type=cache,mode=0755,target=/root/.cache/go-build \
make build

COPY tyk.conf.example tyk.conf

Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ tasks:
docker:
desc: "build Tyk gateway internal/tyk-gateway"
cmds:
- docker build --platform "linux/amd64" --rm -t internal/tyk-gateway .
- docker build --build-arg GO_VERSION="$(go mod edit -json | jq .Go -r)" --platform "linux/amd64" --rm -t internal/tyk-gateway .
sources:
- go.mod
- go.sum
Expand Down
2 changes: 1 addition & 1 deletion ci/images/plugin-compiler/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG BASE_IMAGE=tykio/golang-cross:1.22-bullseye
ARG BASE_IMAGE=tykio/golang-cross:1.23-bullseye
FROM ${BASE_IMAGE}

LABEL description="Image for plugin development"
Expand Down
52 changes: 37 additions & 15 deletions gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/TykTechnologies/tyk-pump/analytics"
"github.com/TykTechnologies/tyk/apidef"
"github.com/TykTechnologies/tyk/config"
"github.com/TykTechnologies/tyk/internal/debug2"
"github.com/TykTechnologies/tyk/storage"
"github.com/TykTechnologies/tyk/test"
"github.com/TykTechnologies/tyk/user"
Expand Down Expand Up @@ -643,30 +644,55 @@ func TestListenPathTykPrefix(t *testing.T) {
}

func TestReloadGoroutineLeakWithTest(t *testing.T) {
test.Flaky(t)
newRecord := func() *debug2.Record {
result := debug2.NewRecord()
result.SetIgnores([]string{
"runtime/pprof.writeRuntimeProfile",
"/root/go/pkg/mod/github.com/!tyk!technologies/[email protected]/memorycache/cache.go:69",
"/root/go/pkg/mod/github.com/pmylund/[email protected]+incompatible/cache.go:1079",
"/root/tyk/tyk/gateway/distributed_rate_limiter.go:31",
"/root/tyk/tyk/gateway/redis_signals.go:68",
})

return result
}

before := runtime.NumGoroutine()
before := newRecord()

ts := StartTest(nil)
ts.Close()

time.Sleep(time.Second)

after := runtime.NumGoroutine()
time.Sleep(100 * time.Millisecond)
runtime.GC()

if before < after {
t.Errorf("Goroutine leak, was: %d, after reload: %d", before, after)
}
final := newRecord().Since(before)
assert.Equal(t, 0, final.Count(), "final count not zero: %s", final)
}

func TestReloadGoroutineLeakWithCircuitBreaker(t *testing.T) {
ts := StartTest(nil)
t.Cleanup(ts.Close)

newRecord := func() *debug2.Record {
result := debug2.NewRecord()
result.SetIgnores([]string{
"runtime/pprof.writeRuntimeProfile",
"/root/tyk/tyk/gateway/reverse_proxy.go:223",
"/root/tyk/tyk/gateway/api_definition.go:1025",
"/root/tyk/tyk/gateway/distributed_rate_limiter.go:31",
"/root/go/pkg/mod/github.com/pmylund/[email protected]+incompatible/cache.go:1079",
"/root/go/pkg/mod/github.com/!tyk!technologies/[email protected]+incompatible/circuitbreaker.go:202",
})

return result
}

globalConf := ts.Gw.GetConfig()
globalConf.EnableJSVM = false
ts.Gw.SetConfig(globalConf)

stage1 := newRecord()

specs := ts.Gw.BuildAndLoadAPI(func(spec *APISpec) {
spec.Proxy.ListenPath = "/"
UpdateAPIVersion(spec, "v1", func(version *apidef.VersionInfo) {
Expand All @@ -684,17 +710,13 @@ func TestReloadGoroutineLeakWithCircuitBreaker(t *testing.T) {
})
})

before := runtime.NumGoroutine()

ts.Gw.LoadAPI(specs...) // just doing globalGateway.DoReload() doesn't load anything as BuildAndLoadAPI cleans up folder with API specs

time.Sleep(100 * time.Millisecond)
runtime.GC()

after := runtime.NumGoroutine()

if before < after {
t.Errorf("Goroutine leak, was: %d, after reload: %d", before, after)
}
final := newRecord().Since(stage1)
assert.Equal(t, 0, final.Count(), "final count not zero: %s", final)
}

func listenProxyProto(ls net.Listener) error {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/TykTechnologies/tyk

go 1.22.6
go 1.23.4

require (
github.com/Jeffail/tunny v0.1.4
Expand Down
Loading
Loading