fix(ingress): nil deref in parseRules, missing httpLoader.Close, swallowed SetRule error

- parseRules: add nil guard before accessing rule.Hostname (parseLine
  returns nil for comments, blanks, and invalid lines)
- Close: call httpLoader.Close() alongside fileLoader and redisLoader
- grpcPlugin.SetRule: log error and return false instead of discarding it
- Add 28 unit tests covering parseLine, parseRules, GetRule wildcard
  matching, reload, Close, and all loader types
This commit is contained in:
ginuerzh
2026-05-24 17:27:17 +08:00
parent 011759d888
commit 501051ce4d
3 changed files with 645 additions and 2 deletions
+5 -1
View File
@@ -81,11 +81,15 @@ func (p *grpcPlugin) SetRule(ctx context.Context, rule *ingress.Rule, opts ...in
opt(&options)
}
r, _ := p.client.SetRule(ctx, &proto.SetRuleRequest{
r, err := p.client.SetRule(ctx, &proto.SetRuleRequest{
Service: options.Service,
Host: rule.Hostname,
Endpoint: rule.Endpoint,
})
if err != nil {
p.log.Error(err)
return false
}
if r == nil {
return false
}