Skip to content

Commit

Permalink
Merge e2f68b3 into 2182a48
Browse files Browse the repository at this point in the history
  • Loading branch information
AlinsRan authored May 4, 2023
2 parents 2182a48 + e2f68b3 commit b236399
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 32 deletions.
28 changes: 12 additions & 16 deletions pkg/providers/gateway/gateway_httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
})
}

Expand Down
28 changes: 12 additions & 16 deletions pkg/providers/gateway/gateway_tcproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
})
}

Expand Down

0 comments on commit b236399

Please sign in to comment.