Yiyiyimu commented on a change in pull request #549:
URL:
https://github.com/apache/apisix-ingress-controller/pull/549#discussion_r655598787
##########
File path: pkg/apisix/global_rule.go
##########
@@ -40,33 +40,46 @@ func newGlobalRuleClient(c *cluster) GlobalRule {
}
// Get returns the GlobalRule.
+func (r *globalRuleClient) Get(ctx context.Context, name string)
(*v1.GlobalRule, error) {
+ return r.get(ctx, id.GenID(name), name)
+}
+
+// GetByName returns the GlobalRule with global rule id
+func (r *globalRuleClient) GetByID(ctx context.Context, realID string)
(*v1.GlobalRule, error) {
+ return r.get(ctx, realID, realID)
+}
+
// FIXME, currently if caller pass a non-existent resource, the Get always
passes
// through cache.
-func (r *globalRuleClient) Get(ctx context.Context, name string)
(*v1.GlobalRule, error) {
+func (r *globalRuleClient) get(ctx context.Context, id string, name string)
(*v1.GlobalRule, error) {
log.Debugw("try to look up global_rule",
- zap.String("name", name),
+ zap.String("name/id", name),
zap.String("url", r.url),
zap.String("cluster", "default"),
)
- rid := id.GenID(name)
- globalRule, err := r.cluster.cache.GetGlobalRule(rid)
- if err == nil {
- return globalRule, nil
- }
- if err != cache.ErrNotFound {
- log.Errorw("failed to find global_rule in cache, will try to
lookup from APISIX",
- zap.String("name", name),
- zap.Error(err),
- )
- } else {
- log.Debugw("failed to find global_rule in cache, will try to
lookup from APISIX",
- zap.String("name", name),
- zap.Error(err),
- )
+
+ var globalRule *v1.GlobalRule
+ var err error
Review comment:
Thx! fixed
--
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]