Skip to content

Commit 0c0c5f9

Browse files
authored
feat: support benchmark test (#2663)
1 parent ad22360 commit 0c0c5f9

File tree

16 files changed

+848
-167
lines changed

16 files changed

+848
-167
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Benchmark Test
19+
20+
on:
21+
push:
22+
branches:
23+
- master
24+
pull_request:
25+
branches:
26+
- master
27+
workflow_dispatch:
28+
inputs:
29+
routes:
30+
description: "Number of routes for benchmark test"
31+
required: false
32+
default: "2000"
33+
consumers:
34+
description: "Number of consumers for benchmark test"
35+
required: false
36+
default: "2000"
37+
38+
concurrency:
39+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
40+
cancel-in-progress: true
41+
42+
env:
43+
ADC_VERSION: dev
44+
BENCHMARK_ROUTES: ${{ github.event.inputs.routes }}
45+
BENCHMARK_CONSUMERS: ${{ github.event.inputs.consumers }}
46+
47+
jobs:
48+
e2e-test:
49+
strategy:
50+
matrix:
51+
provider_type:
52+
- apisix-standalone
53+
- apisix
54+
fail-fast: false
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
with:
60+
submodules: recursive
61+
62+
- name: Setup Go Env
63+
uses: actions/setup-go@v4
64+
with:
65+
go-version: "1.24"
66+
67+
- name: Install kind
68+
run: |
69+
go install sigs.k8s.io/[email protected]
70+
71+
- name: Install ginkgo
72+
run: |
73+
make install-ginkgo
74+
75+
- name: Build images
76+
env:
77+
TAG: dev
78+
ARCH: amd64
79+
ENABLE_PROXY: "false"
80+
BASE_IMAGE_TAG: "debug"
81+
run: |
82+
echo "building images..."
83+
make build-image
84+
85+
- name: Launch Kind Cluster
86+
run: |
87+
make kind-up
88+
89+
- name: Loading Docker Image to Kind Cluster
90+
run: |
91+
make kind-load-images
92+
93+
- name: Install Gateway API And CRDs
94+
run: |
95+
make install
96+
97+
- name: Extract adc binary
98+
if: ${{ env.ADC_VERSION == 'dev' }}
99+
run: |
100+
docker create --name adc-temp ghcr.io/api7/adc:dev
101+
docker cp adc-temp:main.js adc.js
102+
docker rm adc-temp
103+
node $(pwd)/adc.js -v
104+
echo "ADC_BIN=node $(pwd)/adc.js" >> $GITHUB_ENV
105+
106+
- name: Run Benchmark Test
107+
shell: bash
108+
env:
109+
PROVIDER_TYPE: ${{ matrix.provider_type }}
110+
TEST_LABEL: ${{ matrix.cases_subset }}
111+
TEST_ENV: CI
112+
run: |
113+
make benchmark-test

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ IMG ?= apache/apisix-ingress-controller:$(IMAGE_TAG)
2727
ENVTEST_K8S_VERSION = 1.30.0
2828
KIND_NAME ?= apisix-ingress-cluster
2929

30-
ADC_VERSION ?= 0.21.2
30+
ADC_VERSION ?= 0.23.1
3131

3232
DIR := $(shell pwd)
3333

@@ -57,6 +57,9 @@ CONFORMANCE_TEST_REPORT_OUTPUT ?= $(DIR)/apisix-ingress-controller-conformance-r
5757
## https://github.com/kubernetes-sigs/gateway-api/blob/v1.3.0/conformance/utils/suite/profiles.go
5858
CONFORMANCE_PROFILES ?= GATEWAY-HTTP,GATEWAY-GRPC,GATEWAY-TLS
5959

60+
TEST_EXCLUDES ?= /e2e /conformance /benchmark
61+
TEST_PACKAGES = $(shell go list ./... $(foreach p,$(TEST_EXCLUDES),| grep -v $(p)))
62+
6063
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
6164
ifeq (,$(shell go env GOBIN))
6265
GOBIN=$(shell go env GOPATH)/bin
@@ -128,7 +131,7 @@ vet: ## Run go vet against code.
128131

129132
.PHONY: test
130133
test: manifests generate fmt vet envtest ## Run tests.
131-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $$(go list ./... | grep -v /e2e | grep -v /conformance) -coverprofile cover.out
134+
KUBEBUILDER_ASSETS="$$( $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path )" go test $(TEST_PACKAGES) -coverprofile cover.out
132135

133136
.PHONY: kind-e2e-test
134137
kind-e2e-test: kind-up build-image kind-load-images e2e-test
@@ -153,6 +156,10 @@ conformance-test:
153156
--conformance-profiles=$(CONFORMANCE_PROFILES) \
154157
--report-output=$(CONFORMANCE_TEST_REPORT_OUTPUT)
155158

159+
.PHONY: benchmark-test
160+
benchmark-test:
161+
go test -v ./test/benchmark -test.timeout=$(TEST_TIMEOUT) -v -ginkgo.v
162+
156163
.PHONY: lint
157164
lint: sort-import golangci-lint ## Run golangci-lint linter
158165
$(GOLANGCI_LINT) run

go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ require (
1818
github.com/hashicorp/go-memdb v1.3.4
1919
github.com/imdario/mergo v0.3.16
2020
github.com/incubator4/go-resty-expr v0.1.1
21+
github.com/olekukonko/tablewriter v1.1.1
2122
github.com/onsi/ginkgo/v2 v2.22.0
2223
github.com/onsi/gomega v1.36.1
24+
github.com/panjf2000/ants/v2 v2.11.3
2325
github.com/pkg/errors v0.9.1
2426
github.com/prometheus/client_golang v1.19.1
2527
github.com/samber/lo v1.47.0
@@ -33,6 +35,7 @@ require (
3335
k8s.io/apiextensions-apiserver v0.32.3
3436
k8s.io/apimachinery v0.32.3
3537
k8s.io/client-go v0.32.3
38+
k8s.io/code-generator v0.32.3
3639
k8s.io/kubectl v0.30.3
3740
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738
3841
sigs.k8s.io/controller-runtime v0.20.4
@@ -91,6 +94,9 @@ require (
9194
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect
9295
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
9396
github.com/cespare/xxhash/v2 v2.3.0 // indirect
97+
github.com/clipperhouse/displaywidth v0.3.1 // indirect
98+
github.com/clipperhouse/stringish v0.1.1 // indirect
99+
github.com/clipperhouse/uax29/v2 v2.2.0 // indirect
94100
github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect
95101
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
96102
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
@@ -139,6 +145,7 @@ require (
139145
github.com/mailru/easyjson v0.7.7 // indirect
140146
github.com/mattn/go-colorable v0.1.13 // indirect
141147
github.com/mattn/go-isatty v0.0.20 // indirect
148+
github.com/mattn/go-runewidth v0.0.19 // indirect
142149
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 // indirect
143150
github.com/miekg/dns v1.1.65 // indirect
144151
github.com/mitchellh/copystructure v1.2.0 // indirect
@@ -150,6 +157,9 @@ require (
150157
github.com/modern-go/reflect2 v1.0.2 // indirect
151158
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
152159
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
160+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 // indirect
161+
github.com/olekukonko/errors v1.1.0 // indirect
162+
github.com/olekukonko/ll v0.1.2 // indirect
153163
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
154164
github.com/pquerna/otp v1.4.0 // indirect
155165
github.com/prometheus/client_model v0.6.1 // indirect
@@ -203,6 +213,7 @@ require (
203213
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
204214
k8s.io/apiserver v0.32.3 // indirect
205215
k8s.io/component-base v0.32.3 // indirect
216+
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 // indirect
206217
k8s.io/klog/v2 v2.130.1 // indirect
207218
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
208219
moul.io/http2curl/v2 v2.3.0 // indirect

go.sum

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3
111111
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
112112
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
113113
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
114+
github.com/clipperhouse/displaywidth v0.3.1 h1:k07iN9gD32177o1y4O1jQMzbLdCrsGJh+blirVYybsk=
115+
github.com/clipperhouse/displaywidth v0.3.1/go.mod h1:tgLJKKyaDOCadywag3agw4snxS5kYEuYR6Y9+qWDDYM=
116+
github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs=
117+
github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA=
118+
github.com/clipperhouse/uax29/v2 v2.2.0 h1:ChwIKnQN3kcZteTXMgb1wztSgaU+ZemkgWdohwgs8tY=
119+
github.com/clipperhouse/uax29/v2 v2.2.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
114120
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
115121
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
116122
github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0=
@@ -285,6 +291,8 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k
285291
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
286292
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
287293
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
294+
github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw=
295+
github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
288296
github.com/mattn/go-zglob v0.0.1/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
289297
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326 h1:ofNAzWCcyTALn2Zv40+8XitdzCgXY6e9qvXwN9W0YXg=
290298
github.com/mattn/go-zglob v0.0.2-0.20190814121620-e3c945676326/go.mod h1:9fxibJccNxU2cnpIKLRRFA7zX7qhkJIQWBb449FYHOo=
@@ -311,12 +319,22 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
311319
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
312320
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
313321
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
322+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6 h1:zrbMGy9YXpIeTnGj4EljqMiZsIcE09mmF8XsD5AYOJc=
323+
github.com/olekukonko/cat v0.0.0-20250911104152-50322a0618f6/go.mod h1:rEKTHC9roVVicUIfZK7DYrdIoM0EOr8mK1Hj5s3JjH0=
324+
github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM=
325+
github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
326+
github.com/olekukonko/ll v0.1.2 h1:lkg/k/9mlsy0SxO5aC+WEpbdT5K83ddnNhAepz7TQc0=
327+
github.com/olekukonko/ll v0.1.2/go.mod h1:b52bVQRRPObe+yyBl0TxNfhesL0nedD4Cht0/zx55Ew=
328+
github.com/olekukonko/tablewriter v1.1.1 h1:b3reP6GCfrHwmKkYwNRFh2rxidGHcT6cgxj/sHiDDx0=
329+
github.com/olekukonko/tablewriter v1.1.1/go.mod h1:De/bIcTF+gpBDB3Alv3fEsZA+9unTsSzAg/ZGADCtn4=
314330
github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo=
315331
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
316332
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
317333
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
318334
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
319335
github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
336+
github.com/panjf2000/ants/v2 v2.11.3 h1:AfI0ngBoXJmYOpDh9m516vjqoUu2sLrIVgppI9TZVpg=
337+
github.com/panjf2000/ants/v2 v2.11.3/go.mod h1:8u92CYMUc6gyvTIw8Ru7Mt7+/ESnJahz5EVtqfrilek=
320338
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
321339
github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28=
322340
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
@@ -579,8 +597,12 @@ k8s.io/apiserver v0.32.3 h1:kOw2KBuHOA+wetX1MkmrxgBr648ksz653j26ESuWNY8=
579597
k8s.io/apiserver v0.32.3/go.mod h1:q1x9B8E/WzShF49wh3ADOh6muSfpmFL0I2t+TG0Zdgc=
580598
k8s.io/client-go v0.32.3 h1:RKPVltzopkSgHS7aS98QdscAgtgah/+zmpAogooIqVU=
581599
k8s.io/client-go v0.32.3/go.mod h1:3v0+3k4IcT9bXTc4V2rt+d2ZPPG700Xy6Oi0Gdl2PaY=
600+
k8s.io/code-generator v0.32.3 h1:31p2TVzC9+hVdSkAFruAk3JY+iSfzrJ83Qij1yZutyw=
601+
k8s.io/code-generator v0.32.3/go.mod h1:+mbiYID5NLsBuqxjQTygKM/DAdKpAjvBzrJd64NU1G8=
582602
k8s.io/component-base v0.32.3 h1:98WJvvMs3QZ2LYHBzvltFSeJjEx7t5+8s71P7M74u8k=
583603
k8s.io/component-base v0.32.3/go.mod h1:LWi9cR+yPAv7cu2X9rZanTiFKB2kHA+JjmhkKjCZRpI=
604+
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9 h1:si3PfKm8dDYxgfbeA6orqrtLkvvIeH8UqffFJDl0bz4=
605+
k8s.io/gengo/v2 v2.0.0-20240911193312-2b36238f13e9/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU=
584606
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
585607
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
586608
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y=

internal/adc/cache/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func NewStore(log logr.Logger) *Store {
4040
return &Store{
4141
cacheMap: make(map[string]Cache),
4242
pluginMetadataMap: make(map[string]adctypes.PluginMetadata),
43-
log: log,
43+
log: log.WithName("store"),
4444
}
4545
}
4646

internal/adc/client/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ func (c *Client) Sync(ctx context.Context) (map[string]types.ADCExecutionErrors,
198198
if resources == nil {
199199
continue
200200
}
201+
c.log.Info("syncing resources for config", "service_number", len(resources.Services))
201202

202203
if err := c.sync(ctx, Task{
203204
Name: name + "-sync",

internal/controller/status/updater.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
pkgmetrics "github.com/apache/apisix-ingress-controller/pkg/metrics"
3838
)
3939

40-
const UpdateChannelBufferSize = 1000
40+
const UpdateChannelBufferSize = 10000
4141

4242
type Update struct {
4343
NamespacedName k8stypes.NamespacedName
@@ -119,7 +119,7 @@ func (u *UpdateHandler) updateStatus(ctx context.Context, update Update) error {
119119

120120
newObj.SetUID(obj.GetUID())
121121

122-
u.log.Info("updating status", "name", update.NamespacedName.Name,
122+
u.log.V(1).Info("updating status", "name", update.NamespacedName.Name,
123123
"namespace", update.NamespacedName.Namespace,
124124
"kind", types.KindOf(newObj),
125125
)
@@ -140,11 +140,10 @@ func (u *UpdateHandler) Start(ctx context.Context) error {
140140
case update := <-u.updateChannel:
141141
// Decrement queue length after removing item from queue
142142
pkgmetrics.DecStatusQueueLength()
143-
u.log.V(1).Info("received a status update", "namespace", update.NamespacedName.Namespace,
143+
u.log.Info("received a status update", "namespace", update.NamespacedName.Namespace,
144144
"name", update.NamespacedName.Name,
145145
"kind", types.KindOf(update.Resource),
146146
)
147-
148147
u.apply(ctx, update)
149148
}
150149
}

internal/controller/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ func ProcessIngressClassParameters(tctx *provider.TranslateContext, c client.Cli
13681368
return err
13691369
}
13701370

1371-
log.Info("found GatewayProxy for IngressClass", "ingressClass", ingressClass.Name, "gatewayproxy", gatewayProxy.Name)
1371+
log.V(1).Info("found GatewayProxy for IngressClass", "ingressClass", ingressClass.Name, "gatewayproxy", gatewayProxy.Name)
13721372
tctx.GatewayProxies[ingressClassKind] = *gatewayProxy
13731373
tctx.ResourceParentRefs[objKind] = append(tctx.ResourceParentRefs[objKind], ingressClassKind)
13741374

internal/manager/readiness/manager.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ func (r *readinessManager) Start(ctx context.Context) error {
125125
})
126126
}
127127
if len(expected) > 0 {
128-
r.log.V(1).Info("registering readiness state", "gvk", gvk, "expected", expected)
128+
r.log.Info("registering readiness state", "gvk", gvk, "registered_count", len(expected))
129+
r.log.V(1).Info("registered resources for readiness", "gvk", gvk, "resources", expected)
129130
r.registerState(gvk, expected)
130131
}
131132
}
@@ -135,13 +136,12 @@ func (r *readinessManager) Start(ctx context.Context) error {
135136
r.isReady.Store(true)
136137
close(r.done)
137138
}
139+
r.log.Info("readiness manager started")
138140
})
139141
return err
140142
}
141143

142144
func (r *readinessManager) registerState(gvk schema.GroupVersionKind, list []k8stypes.NamespacedName) {
143-
r.mu.Lock()
144-
defer r.mu.Unlock()
145145
if _, ok := r.state[gvk]; !ok {
146146
r.state[gvk] = make(map[k8stypes.NamespacedName]struct{})
147147
}
@@ -155,9 +155,12 @@ func (r *readinessManager) Done(obj client.Object, nn k8stypes.NamespacedName) {
155155
if r.IsReady() {
156156
return
157157
}
158+
<-r.started
159+
158160
r.mu.Lock()
159161
defer r.mu.Unlock()
160162
gvk := types.GvkOf(obj)
163+
r.log.Info("marking resource as done", "gvk", gvk, "name", nn, "state_count", len(r.state[gvk]))
161164
if _, ok := r.state[gvk]; !ok {
162165
return
163166
}
@@ -191,7 +194,7 @@ func (r *readinessManager) WaitReady(ctx context.Context, timeout time.Duration)
191194
case <-ctx.Done():
192195
return false
193196
case <-time.After(timeout):
194-
return true
197+
return false
195198
case <-r.done:
196199
return true
197200
}

0 commit comments

Comments
 (0)