Skip to content

Commit e0143ef

Browse files
committed
fix: r
Signed-off-by: Ashing Zheng <[email protected]>
1 parent 4276f2a commit e0143ef

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

internal/controller/label/label.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,17 @@ const (
3131
LabelNamespace = "k8s/namespace"
3232
LabelControllerName = "k8s/controller-name"
3333
LabelManagedBy = "manager-by"
34+
LabelID = "k8s/uid"
3435
)
3536

36-
func GenLabel(client client.Object, args ...string) Label {
37+
func GenLabel(obj client.Object, args ...string) Label {
3738
label := make(Label)
38-
label[LabelKind] = client.GetObjectKind().GroupVersionKind().Kind
39-
label[LabelNamespace] = client.GetNamespace()
40-
label[LabelName] = client.GetName()
39+
label[LabelKind] = obj.GetObjectKind().GroupVersionKind().Kind
40+
label[LabelNamespace] = obj.GetNamespace()
41+
label[LabelName] = obj.GetName()
4142
label[LabelControllerName] = config.ControllerConfig.ControllerName
4243
label[LabelManagedBy] = "apisix-ingress-controller"
44+
label[LabelID] = string(obj.GetUID())
4345
for i := 0; i < len(args); i += 2 {
4446
label[args[i]] = args[i+1]
4547
}

internal/provider/adc/adc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,10 @@ func (d *adcClient) Sync(ctx context.Context) error {
413413

414414
func (d *adcClient) sync(ctx context.Context, task Task) error {
415415
log.Debugw("syncing resources", zap.Any("task", task))
416+
if len(task.Labels) > 0 {
417+
// only keep the id label for filtering resources
418+
task.Labels = map[string]string{label.LabelID: task.Labels[label.LabelID]}
419+
}
416420

417421
if len(task.configs) == 0 {
418422
log.Warnw("no adc configs provided", zap.Any("task", task))

test/e2e/crds/v2/route.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"context"
2222
"fmt"
2323
"io"
24+
"log"
2425
"net"
2526
"net/http"
2627
"time"
@@ -441,6 +442,7 @@ spec:
441442
By("verify ApisixRoute works")
442443
for _, id := range []string{"1", "11", "111", "1111", "11111"} {
443444
host := fmt.Sprintf("httpbin-%s", id)
445+
log.Println("host: ", host)
444446
Eventually(func() int {
445447
return s.NewAPISIXClient().GET("/get").WithHost(host).Expect().Raw().StatusCode
446448
}).WithTimeout(8 * time.Second).ProbeEvery(time.Second).Should(Equal(http.StatusOK))

0 commit comments

Comments
 (0)