openresty / openresty/lua-upstream-nginx-module

get_primary_peers doesn't return name

Open
#31 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
512
Forks
153
Avg merge
1h 29m
Merged PRs (30d)
2

Description

Hello, it seems that when "zone" is defined the name filed is returned only for the first peer.

nginx version:
./nginx -v nginx version: openresty/1.9.15.1

upstreams.conf:

upstream http_local {
zone local_zone 64k;
server 127.0.0.1:80 ;
server 127.0.0.2:80 ;
keepalive 16;
}

access.lua:

log(ERR, cjson.encode(upstream.get_primary_peers(upstream_name)))
log(ERR, cjson.encode(upstream.get_servers(upstream_name)))

log.txt:

016/07/19 13:50:00 [error] 80976#0: *92 [lua] access.lua:91: [{"weight":1,"id":0,"conns":0,"fails":0,"current_weight":0,"fail_timeout":10,"effective_weight":1,"name":"127.0.0.1:80","max_fails":1},{"weight":0,"id":1,"conns":0,"fails":0,"current_weight":0,"down":true,"effective_weight":0,"fail_timeout":12,"checked":1.4057793776513e+14,"name":"","max_fails":16}], client: 127.0.0.1, server: _, request: "GET /index.php HTTP/1.1", host: "xxxxx"

2016/07/19 13:50:00 [error] 80976#0: *92 [lua] access.lua:92: [{"addr":"127.0.0.1:80","weight":1,"fail_timeout":10,"name":"127.0.0.1:80","max_fails":1},{"addr":"127.0.0.2:80","weight":1,"fail_timeout":10,"name":"127.0.0.2:80","max_fails":1}], client: 127.0.0.1, server: _, request: "GET /index.php HTTP/1.1", host: "xxxxx"

As you can see in the first log, the second "name " field is empty. If "zone" definition is removed than the result is ok. In contrast the upstream.get_servers method returns always good results.

This issue affects https://github.com/openresty/lua-resty-upstream-healthcheck

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the upstreams.conf zone configuration and compare access.lua output from get_primary_peers with get_servers. Start at the get_primary_peers entry point in the C module, then verify that every returned peer has its name populated when a zone is used; the existing log output provides the expected comparison.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, nginx
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.