Exa-Networks / exabgp

The BGP swiss army knife of networking

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

healthcheck: Loopback IP Parsing

clwluvw opened this issue · comments

** Bug Report **

Describe the bug

When having two ips with labels like labelname and labelname-something, specifying --label labelname would pick both labelname and labelname-something.

Expected behavior

Only the desired label be chosen.

Additional context

It must be probably because of the startswith func here (https://github.com/Exa-Networks/exabgp/blob/main/src/exabgp/application/healthcheck.py#L221)

I think this would work if label was replaced by "{0}:".format(label).

I see a backslash at the end of the label from /sbin/ip -o address show dev lo output.

I don't remember if it was the reason I have used startswith. Maybe the right fix would be:

if lmo.groupdict().get("label", "").rstrip("\\") == label:

Sorry, looking at the documentation string, this is something expected. Labels need to be unique, so that's why there is a startswith(). If you want to use several loopbacks, you label them haproxy1, haproxy2, haproxy3 and you use --label haproxy.

hmm - maybe a better approach was to support regex as an arg so this wouldn't be confusing. I mean now you can't use it unless you change the names completely.

It would break existing setups and just adding a new option means more code to support, more bugs and more people confused. In years, this is the first time this issue is reported. If we were to start over, we would use "label + number" like the example, but now, who knows how people did use this feature.