Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 .github/workflows/apisix-conformance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
id: go
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"

- name: Install kind
run: |
Expand All @@ -71,7 +71,7 @@ jobs:
- name: Setup Go Env
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"

- name: Login to Registry
uses: docker/login-action@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/apisix-e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
id: go
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"

- name: Install kind
run: |
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Setup Go Env
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"

- name: Login to Registry
uses: docker/login-action@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/conformance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
id: go
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"

- name: Install kind
run: |
Expand All @@ -69,7 +69,7 @@ jobs:
- name: Setup Go Env
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"
- name: Login to Registry
uses: docker/login-action@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
id: go
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"

- name: Install kind
run: |
Expand All @@ -68,7 +68,7 @@ jobs:
- name: Setup Go Env
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"

- name: Login to Registry
uses: docker/login-action@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Setup Go Env
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"

- name: check go path for debug
run: go env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-docker-v2-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- name: Setup Go Env
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"

# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Setup Go Env
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Setup Go Env
uses: actions/setup-go@v4
with:
go-version: "1.22"
go-version: "1.23"
- name: Run unit test
working-directory: ./
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The APISIX Ingress Controller allows you to run the APISIX Gateway as a Kubernet

### Prerequisites

* go version v1.22.0+
* go version v1.23.0+
* docker version 17.03+.
* kubectl version v1.11.3+.
* Access to a Kubernetes v1.11.3+ cluster.
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/apache/apisix-ingress-controller

go 1.22.0
go 1.23.0

toolchain go1.22.5
toolchain go1.23.7

require (
github.com/Masterminds/sprig/v3 v3.2.3
Expand All @@ -18,6 +18,7 @@ require (
github.com/onsi/ginkgo/v2 v2.20.0
github.com/onsi/gomega v1.34.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.1
github.com/samber/lo v1.47.0
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
Expand Down Expand Up @@ -152,7 +153,6 @@ require (
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/pquerna/otp v1.2.0 // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.55.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
Expand Down
6 changes: 6 additions & 0 deletions internal/controller/status/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/util/retry"
"sigs.k8s.io/controller-runtime/pkg/client"

pkgmetrics "github.com/apache/apisix-ingress-controller/pkg/metrics"
)

const UpdateChannelBufferSize = 1000
Expand Down Expand Up @@ -110,6 +112,8 @@ func (u *UpdateHandler) Start(ctx context.Context) error {
case <-ctx.Done():
return nil
case update := <-u.updateChannel:
// Decrement queue length after removing item from queue
pkgmetrics.DecStatusQueueLength()
u.log.Info("received a status update", "namespace", update.NamespacedName.Namespace,
"name", update.NamespacedName.Name)

Expand Down Expand Up @@ -137,4 +141,6 @@ type UpdateWriter struct {
func (u *UpdateWriter) Update(update Update) {
u.wg.Wait()
u.updateChannel <- update
// Increment queue length after adding new item
pkgmetrics.IncStatusQueueLength()
}
1 change: 1 addition & 0 deletions internal/manager/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
"github.com/apache/apisix-ingress-controller/internal/controller/config"
"github.com/apache/apisix-ingress-controller/internal/controller/status"
"github.com/apache/apisix-ingress-controller/internal/provider/adc"
_ "github.com/apache/apisix-ingress-controller/pkg/metrics"
)

var (
Expand Down
62 changes: 58 additions & 4 deletions internal/provider/adc/adc.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/apache/apisix-ingress-controller/internal/provider/adc/translator"
"github.com/apache/apisix-ingress-controller/internal/types"
"github.com/apache/apisix-ingress-controller/internal/utils"
pkgmetrics "github.com/apache/apisix-ingress-controller/pkg/metrics"
)

type adcConfig struct {
Expand Down Expand Up @@ -389,6 +390,8 @@ func (d *adcClient) sync(ctx context.Context, task Task) error {
return nil
}

var errs types.ADCExecutionErrors

// for global rules, we need to list all global rules and set it to the task resources
if slices.Contains(task.ResourceTypes, "global_rule") {
for _, config := range task.configs {
Expand All @@ -410,42 +413,93 @@ func (d *adcClient) sync(ctx context.Context, task Task) error {
task.Resources.GlobalRules = globalrule
log.Debugw("syncing resources global rules", zap.Any("globalRules", task.Resources.GlobalRules))

fileIOStart := time.Now()
syncFilePath, cleanup, err := prepareSyncFile(task.Resources)
if err != nil {
pkgmetrics.RecordFileIODuration("prepare_sync_file", "failure", time.Since(fileIOStart).Seconds())
return err
}
pkgmetrics.RecordFileIODuration("prepare_sync_file", "success", time.Since(fileIOStart).Seconds())
defer cleanup()

args := BuildADCExecuteArgs(syncFilePath, task.Labels, task.ResourceTypes)

if err := d.executor.Execute(ctx, d.BackendMode, config, args); err != nil {
// Record sync duration for each config
startTime := time.Now()
resourceType := strings.Join(task.ResourceTypes, ",")
if resourceType == "" {
resourceType = "all"
}

err = d.executor.Execute(ctx, d.BackendMode, config, args)
duration := time.Since(startTime).Seconds()

status := "success"
if err != nil {
status = "failure"
log.Errorw("failed to execute adc command", zap.Error(err), zap.Any("config", config))
return err

var execErr types.ADCExecutionError
if errors.As(err, &execErr) {
errs.Errors = append(errs.Errors, execErr)
pkgmetrics.RecordExecutionError(config.Name, execErr.Name)
} else {
pkgmetrics.RecordExecutionError(config.Name, "unknown")
}
}

// Record metrics
pkgmetrics.RecordSyncDuration(config.Name, resourceType, status, duration)
}

if len(errs.Errors) > 0 {
return errs
}
return nil
}

// Record file I/O duration
fileIOStart := time.Now()
// every task resources is the same, so we can use the first config to prepare the sync file
syncFilePath, cleanup, err := prepareSyncFile(task.Resources)
if err != nil {
pkgmetrics.RecordFileIODuration("prepare_sync_file", "failure", time.Since(fileIOStart).Seconds())
return err
}
pkgmetrics.RecordFileIODuration("prepare_sync_file", "success", time.Since(fileIOStart).Seconds())
defer cleanup()

args := BuildADCExecuteArgs(syncFilePath, task.Labels, task.ResourceTypes)

var errs types.ADCExecutionErrors
for _, config := range task.configs {
if err := d.executor.Execute(ctx, d.BackendMode, config, args); err != nil {
// Record sync duration for each config
startTime := time.Now()
resourceType := strings.Join(task.ResourceTypes, ",")
if resourceType == "" {
resourceType = "all"
}

err := d.executor.Execute(ctx, d.BackendMode, config, args)
duration := time.Since(startTime).Seconds()

status := "success"
if err != nil {
status = "failure"
log.Errorw("failed to execute adc command", zap.Error(err), zap.Any("config", config))

var execErr types.ADCExecutionError
if errors.As(err, &execErr) {
errs.Errors = append(errs.Errors, execErr)
pkgmetrics.RecordExecutionError(config.Name, execErr.Name)
} else {
pkgmetrics.RecordExecutionError(config.Name, "unknown")
}
}

// Record metrics
pkgmetrics.RecordSyncDuration(config.Name, resourceType, status, duration)
}

if len(errs.Errors) > 0 {
return errs
}
Expand Down
Loading
Loading