Skip to content

Commit cd8bebb

Browse files
authored
feat: support new adc sync api (#235)
Signed-off-by: Ashing Zheng <[email protected]>
1 parent 76ff1df commit cd8bebb

File tree

6 files changed

+27
-6
lines changed

6 files changed

+27
-6
lines changed

.github/workflows/apisix-e2e-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
ARCH: amd64
7272
ENABLE_PROXY: "false"
7373
BASE_IMAGE_TAG: "debug"
74-
# ADC_VERSION: "dev"
74+
ADC_VERSION: "dev"
7575
run: |
7676
echo "building images..."
7777
make build-image

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ kind-load-images: pull-infra-images kind-load-ingress-image
191191
@kind load docker-image kennethreitz/httpbin:latest --name $(KIND_NAME)
192192
@kind load docker-image jmalloc/echo-server:latest --name $(KIND_NAME)
193193
@kind load docker-image ghcr.io/api7/adc:dev --name $(KIND_NAME)
194+
@kind load docker-image apache/apisix:dev --name $(KIND_NAME)
194195

195196
.PHONY: kind-load-gateway-image
196197
kind-load-gateway-image:
@@ -217,6 +218,7 @@ pull-infra-images:
217218
@docker pull kennethreitz/httpbin:latest
218219
@docker pull jmalloc/echo-server:latest
219220
@docker pull ghcr.io/api7/adc:dev
221+
@docker pull apache/apisix:dev
220222

221223
##@ Build
222224

internal/adc/client/executor.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,12 @@ type ADCServerTask struct {
213213
// ADCServerOpts represents the options in ADC Server task
214214
type ADCServerOpts struct {
215215
Backend string `json:"backend"`
216-
Server string `json:"server"`
216+
Server []string `json:"server"`
217217
Token string `json:"token"`
218218
LabelSelector map[string]string `json:"labelSelector,omitempty"`
219219
IncludeResourceType []string `json:"includeResourceType,omitempty"`
220220
TlsSkipVerify *bool `json:"tlsSkipVerify,omitempty"`
221+
CacheKey string `json:"cacheKey"`
221222
}
222223

223224
// HTTPADCExecutor implements ADCExecutor interface using HTTP calls to ADC Server
@@ -247,7 +248,15 @@ func (e *HTTPADCExecutor) runHTTPSync(ctx context.Context, mode string, config a
247248
Name: config.Name,
248249
}
249250

250-
for _, addr := range config.ServerAddrs {
251+
serverAddrs := func() []string {
252+
if mode == "apisix-standalone" {
253+
return []string{strings.Join(config.ServerAddrs, ",")}
254+
}
255+
return config.ServerAddrs
256+
}()
257+
log.Debugw("running http sync", zap.Strings("serverAddrs", serverAddrs), zap.String("mode", mode))
258+
259+
for _, addr := range serverAddrs {
251260
if err := e.runHTTPSyncForSingleServer(ctx, addr, mode, config, args); err != nil {
252261
log.Errorw("failed to run http sync for server", zap.String("server", addr), zap.Error(err))
253262
var execErr types.ADCExecutionServerAddrError
@@ -365,11 +374,12 @@ func (e *HTTPADCExecutor) buildHTTPRequest(ctx context.Context, serverAddr, mode
365374
Task: ADCServerTask{
366375
Opts: ADCServerOpts{
367376
Backend: mode,
368-
Server: serverAddr,
377+
Server: strings.Split(serverAddr, ","),
369378
Token: config.Token,
370379
LabelSelector: labels,
371380
IncludeResourceType: types,
372381
TlsSkipVerify: ptr.To(!tlsVerify),
382+
CacheKey: config.Name,
373383
},
374384
Config: *resources,
375385
},
@@ -386,6 +396,7 @@ func (e *HTTPADCExecutor) buildHTTPRequest(ctx context.Context, serverAddr, mode
386396
zap.String("url", e.serverURL+"/sync"),
387397
zap.String("server", serverAddr),
388398
zap.String("mode", mode),
399+
zap.String("cacheKey", config.Name),
389400
zap.Any("labelSelector", labels),
390401
zap.Strings("includeResourceType", types),
391402
zap.Bool("tlsSkipVerify", !tlsVerify),

internal/provider/apisix/status.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ func (d *apisixProvider) handleDetailedFailedStatuses(
205205
statusUpdateMap map[types.NamespacedNameKind][]string,
206206
) {
207207
for _, status := range failedStatus.FailedStatuses {
208+
// in the APISIX standalone mode, the related values in the sync failure event are empty.
209+
if status.Event.ResourceType == "" {
210+
d.handleEmptyFailedStatuses(configName, failedStatus, statusUpdateMap)
211+
return
212+
}
213+
208214
id := status.Event.ResourceID
209215
labels, err := d.client.GetResourceLabel(configName, status.Event.ResourceType, id)
210216
if err != nil {

test/e2e/framework/api7_dashboard.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ func (f *Framework) CreateNewGatewayGroupWithIngressE() (string, error) {
395395
}
396396

397397
func (f *Framework) setDpManagerEndpoints() {
398-
payload := []byte(fmt.Sprintf(`{"control_plane_address":["%s"]}`, DPManagerTLSEndpoint))
398+
payload := []byte(fmt.Sprintf(`{"dp_manager_address":["%s"]}`, DPManagerTLSEndpoint))
399399

400400
respExp := f.DashboardHTTPClient().
401401
PUT("/api/system_settings").
@@ -408,7 +408,7 @@ func (f *Framework) setDpManagerEndpoints() {
408408
f.Logf("set dp manager endpoints response: %s", respExp.Body().Raw())
409409

410410
respExp.Status(200).
411-
Body().Contains("control_plane_address")
411+
Body().Contains("dp_manager_address")
412412
}
413413

414414
func (f *Framework) GetDashboardEndpoint() string {

test/e2e/framework/manifests/ingress.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ spec:
437437
value: ingress
438438
- name: ADC_EXPERIMENTAL_FEATURE_FLAGS
439439
value: remote-state-file,parallel-backend-request
440+
- name: ADC_INGRESS_LOG_LEVEL
441+
value: "debug"
440442
name: adc-server
441443
args:
442444
- "server"

0 commit comments

Comments
 (0)