tokers commented on a change in pull request #549:
URL:
https://github.com/apache/apisix-ingress-controller/pull/549#discussion_r654935150
##########
File path: pkg/apisix/route.go
##########
@@ -41,16 +41,24 @@ func newRouteClient(c *cluster) Route {
}
// Get returns the Route.
+func (r *routeClient) Get(ctx context.Context, name string) (*v1.Route, error)
{
+ return r.get(ctx, id.GenID(name), name)
+}
+
+// GetByName returns the Route with route name
+func (r *routeClient) GetByID(ctx context.Context, realID string) (*v1.Route,
error) {
+ return r.get(ctx, realID, realID)
+}
+
// FIXME, currently if caller pass a non-existent resource, the Get always
passes
// through cache.
-func (r *routeClient) Get(ctx context.Context, name string) (*v1.Route, error)
{
+func (r *routeClient) get(ctx context.Context, id string, name string)
(*v1.Route, error) {
log.Debugw("try to look up route",
zap.String("name", name),
zap.String("url", r.url),
zap.String("cluster", "default"),
Review comment:
Should also print the route id in logs.
##########
File path: pkg/apisix/cluster.go
##########
@@ -276,6 +281,11 @@ func (c *cluster) String() string {
// HasSynced implements Cluster.HasSynced method.
func (c *cluster) HasSynced(ctx context.Context) error {
+ // if bypass cache no need to sync
+ if !c.bypassCache {
Review comment:
It should be `if c.bypassCache`.
##########
File path: pkg/apisix/route.go
##########
@@ -41,16 +41,24 @@ func newRouteClient(c *cluster) Route {
}
// Get returns the Route.
+func (r *routeClient) Get(ctx context.Context, name string) (*v1.Route, error)
{
+ return r.get(ctx, id.GenID(name), name)
+}
+
+// GetByName returns the Route with route name
+func (r *routeClient) GetByID(ctx context.Context, realID string) (*v1.Route,
error) {
+ return r.get(ctx, realID, realID)
+}
+
// FIXME, currently if caller pass a non-existent resource, the Get always
passes
// through cache.
-func (r *routeClient) Get(ctx context.Context, name string) (*v1.Route, error)
{
+func (r *routeClient) get(ctx context.Context, id string, name string)
(*v1.Route, error) {
log.Debugw("try to look up route",
zap.String("name", name),
zap.String("url", r.url),
zap.String("cluster", "default"),
)
- rid := id.GenID(name)
- route, err := r.cluster.cache.GetRoute(rid)
+ route, err := r.cluster.cache.GetRoute(id)
Review comment:
It still queries the cache. Does this PR still work in progress?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]