This is an automated email from the ASF dual-hosted git repository.
zhangjintao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
The following commit(s) were added to refs/heads/master by this push:
new 31891bac fix: Referencing empty objects during tcproute and httproute
updates (#1825)
31891bac is described below
commit 31891bac85f02bc3487069af47a22ad403a863e5
Author: Xin Rong <[email protected]>
AuthorDate: Fri May 5 17:58:40 2023 +0800
fix: Referencing empty objects during tcproute and httproute updates (#1825)
---
pkg/providers/gateway/gateway_httproute.go | 28 ++++++++++++----------------
pkg/providers/gateway/gateway_tcproute.go | 28 ++++++++++++----------------
2 files changed, 24 insertions(+), 32 deletions(-)
diff --git a/pkg/providers/gateway/gateway_httproute.go
b/pkg/providers/gateway/gateway_httproute.go
index 30de8f19..22fd40cb 100644
--- a/pkg/providers/gateway/gateway_httproute.go
+++ b/pkg/providers/gateway/gateway_httproute.go
@@ -163,22 +163,17 @@ func (c *gatewayHTTPRouteController) sync(ctx
context.Context, ev *types.Event)
} else {
var oldCtx *translation.TranslateContext
oldObj := ev.OldObject.(*gatewayv1beta1.HTTPRoute)
- oldCtx, err =
c.controller.translator.TranslateGatewayHTTPRouteV1beta1(oldObj)
- if err != nil {
- log.Errorw("failed to translate old HTTPRoute",
- zap.String("version", oldObj.APIVersion),
- zap.String("event_type", "update"),
- zap.Any("HTTPRoute", oldObj),
- zap.Error(err),
- )
- return err
- }
+ oldCtx, _ =
c.controller.translator.TranslateGatewayHTTPRouteV1beta1(oldObj)
+ if oldCtx != nil {
- om := &utils.Manifest{
- Routes: oldCtx.Routes,
- Upstreams: oldCtx.Upstreams,
+ om := &utils.Manifest{
+ Routes: oldCtx.Routes,
+ Upstreams: oldCtx.Upstreams,
+ }
+ added, updated, deleted = m.Diff(om)
+ } else {
+ added = m
}
- added, updated, deleted = m.Diff(om)
}
return utils.SyncManifests(ctx, c.controller.APISIX,
c.controller.APISIXClusterName, added, updated, deleted, false)
@@ -252,8 +247,9 @@ func (c *gatewayHTTPRouteController) onUpdate(oldObj,
newObj interface{}) {
)
c.workqueue.Add(&types.Event{
- Type: types.EventUpdate,
- Object: key,
+ Type: types.EventUpdate,
+ Object: key,
+ OldObject: oldHTTPRoute,
})
}
diff --git a/pkg/providers/gateway/gateway_tcproute.go
b/pkg/providers/gateway/gateway_tcproute.go
index 7a08f85a..028b3f5b 100644
--- a/pkg/providers/gateway/gateway_tcproute.go
+++ b/pkg/providers/gateway/gateway_tcproute.go
@@ -134,22 +134,17 @@ func (c *gatewayTCPRouteController) sync(ctx
context.Context, ev *types.Event) e
} else {
var oldCtx *translation.TranslateContext
oldObj := ev.OldObject.(*gatewayv1alpha2.TCPRoute)
- oldCtx, err =
c.controller.translator.TranslateGatewayTCPRouteV1Alpha2(oldObj)
- if err != nil {
- log.Errorw("failed to translate old TCPRoute",
- zap.String("version", oldObj.APIVersion),
- zap.String("event_type", "update"),
- zap.Any("TCPRoute", oldObj),
- zap.Error(err),
- )
- return err
+ oldCtx, _ =
c.controller.translator.TranslateGatewayTCPRouteV1Alpha2(oldObj)
+ if oldCtx != nil {
+ om := &utils.Manifest{
+ StreamRoutes: oldCtx.StreamRoutes,
+ Upstreams: oldCtx.Upstreams,
+ }
+ added, updated, deleted = m.Diff(om)
+ } else {
+ added = m
}
- om := &utils.Manifest{
- StreamRoutes: oldCtx.StreamRoutes,
- Upstreams: oldCtx.Upstreams,
- }
- added, updated, deleted = m.Diff(om)
}
return utils.SyncManifests(ctx, c.controller.APISIX,
c.controller.APISIXClusterName, added, updated, deleted, false)
@@ -246,8 +241,9 @@ func (c *gatewayTCPRouteController) onUpdate(oldObj, newObj
interface{}) {
zap.Any("new object", newObj),
)
c.workqueue.Add(&types.Event{
- Type: types.EventUpdate,
- Object: key,
+ Type: types.EventUpdate,
+ Object: key,
+ OldObject: oldTCPRoute,
})
}