Skip to content

Commit c628768

Browse files
committed
fix: r
Signed-off-by: ashing <[email protected]>
1 parent 54dab10 commit c628768

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

config/samples/config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
log_level: "debug" # The log level of the APISIX Ingress Controller.
1+
log_level: "info" # The log level of the APISIX Ingress Controller.
22
# the default value is "info".
33

44
controller_name: apisix.apache.org/apisix-ingress-controller # The controller name of the APISIX Ingress Controller,

internal/controller/apisixglobalrule_controller.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/go-logr/logr"
1919
corev1 "k8s.io/api/core/v1"
2020
networkingv1 "k8s.io/api/networking/v1"
21-
k8serrors "k8s.io/apimachinery/pkg/api/errors"
2221
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2322
"k8s.io/apimachinery/pkg/runtime"
2423
"k8s.io/apimachinery/pkg/types"
@@ -59,13 +58,13 @@ func (r *ApisixGlobalRuleReconciler) Reconcile(ctx context.Context, req ctrl.Req
5958

6059
var globalRule apiv2.ApisixGlobalRule
6160
if err := r.Get(ctx, req.NamespacedName, &globalRule); err != nil {
62-
if k8serrors.IsNotFound(err) {
61+
if client.IgnoreNotFound(err) == nil {
6362
log.Info("global rule not found, possibly deleted")
6463
// Create a minimal object for deletion
6564
globalRule.Namespace = req.Namespace
6665
globalRule.Name = req.Name
6766
globalRule.TypeMeta = metav1.TypeMeta{
68-
Kind: "ApisixGlobalRule",
67+
Kind: KindApisixGlobalRule,
6968
APIVersion: apiv2.GroupVersion.String(),
7069
}
7170
// Delete from provider
@@ -75,19 +74,9 @@ func (r *ApisixGlobalRuleReconciler) Reconcile(ctx context.Context, req ctrl.Req
7574
}
7675
return ctrl.Result{}, nil
7776
}
78-
log.Error(err, "failed to get ApisixGlobalRule")
7977
return ctrl.Result{}, err
8078
}
8179

82-
// Check if the global rule is being deleted
83-
if !globalRule.DeletionTimestamp.IsZero() {
84-
if err := r.Provider.Delete(ctx, &globalRule); err != nil {
85-
log.Error(err, "failed to delete global rule from provider")
86-
return ctrl.Result{}, err
87-
}
88-
return ctrl.Result{}, nil
89-
}
90-
9180
// create a translate context
9281
tctx := provider.NewDefaultTranslateContext(ctx)
9382

@@ -146,6 +135,12 @@ func (r *ApisixGlobalRuleReconciler) SetupWithManager(mgr ctrl.Manager) error {
146135
predicate.NewPredicateFuncs(r.checkIngressClass),
147136
),
148137
).
138+
WithEventFilter(
139+
predicate.Or(
140+
predicate.GenerationChangedPredicate{},
141+
predicate.AnnotationChangedPredicate{},
142+
),
143+
).
149144
Watches(
150145
&networkingv1.IngressClass{},
151146
handler.EnqueueRequestsFromMapFunc(r.listGlobalRulesForIngressClass),
@@ -156,7 +151,6 @@ func (r *ApisixGlobalRuleReconciler) SetupWithManager(mgr ctrl.Manager) error {
156151
Watches(&v1alpha1.GatewayProxy{},
157152
handler.EnqueueRequestsFromMapFunc(r.listGlobalRulesForGatewayProxy),
158153
).
159-
Named("apisixglobalrule").
160154
Complete(r)
161155
}
162156

internal/controller/utils.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,15 @@ import (
4646
)
4747

4848
const (
49-
KindGateway = "Gateway"
50-
KindHTTPRoute = "HTTPRoute"
51-
KindGatewayClass = "GatewayClass"
52-
KindIngress = "Ingress"
53-
KindIngressClass = "IngressClass"
54-
KindGatewayProxy = "GatewayProxy"
55-
KindSecret = "Secret"
56-
KindService = "Service"
49+
KindGateway = "Gateway"
50+
KindHTTPRoute = "HTTPRoute"
51+
KindGatewayClass = "GatewayClass"
52+
KindIngress = "Ingress"
53+
KindIngressClass = "IngressClass"
54+
KindGatewayProxy = "GatewayProxy"
55+
KindSecret = "Secret"
56+
KindService = "Service"
57+
KindApisixGlobalRule = "ApisixGlobalRule"
5758
)
5859

5960
const defaultIngressClassAnnotation = "ingressclass.kubernetes.io/is-default-class"

internal/provider/adc/adc.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ const (
5353
type adcClient struct {
5454
sync.Mutex
5555

56+
syncLock sync.Mutex
57+
5658
translator *translator.Translator
5759
// gateway/ingressclass -> adcConfig
5860
configs map[types.NamespacedNameKind]adcConfig
@@ -220,8 +222,8 @@ func (d *adcClient) Delete(ctx context.Context, obj client.Object) error {
220222
case *networkingv1.IngressClass:
221223
// delete all resources
222224
case *apiv2.ApisixGlobalRule:
223-
// don't need gen labels for global rule?
224225
resourceTypes = append(resourceTypes, "global_rule")
226+
labels = label.GenLabel(obj)
225227
}
226228

227229
rk := utils.NamespacedNameKind(obj)
@@ -292,6 +294,9 @@ func (d *adcClient) Start(ctx context.Context) error {
292294
}
293295

294296
func (d *adcClient) Sync(ctx context.Context) error {
297+
d.syncLock.Lock()
298+
defer d.syncLock.Unlock()
299+
295300
log.Debug("syncing all resources")
296301

297302
if len(d.configs) == 0 {

0 commit comments

Comments
 (0)