portability: permit arpa address
Closes #6147
Frustratingly, the arpa address returned by socket.getfqdn on Mac OS is different with Python 3.9 than 3.7 (conda-forge).
For context see https://github.com/cylc/cylc-flow/pull/4296
I'm not especially keen on fiddling this exception every time it changes, but can't really think of a better way to do this safely.
Check List
- [x] I have read
CONTRIBUTING.mdand added my name as a Code Contributor. - [x] Contains logically grouped changes (else tidy your branch by rebase).
- [x] Does not contain off-topic changes (use other PRs for other changes).
- [x] Applied any dependency changes to both
setup.cfg(andconda-environment.ymlif present). - [x] Tests are included (or explain why tests are not needed).
- [x]
CHANGES.mdentry included if this is a change that can affect users - [x] Cylc-Doc pull request opened if required at cylc/cylc-doc/pull/XXXX.
- [ ] If this is a bug fix, PR should be raised against the relevant
?.?.xbranch.
Can't say I understand the problem very well, but the "fix" seems fine. I take it we're safe from users on different Mac OS version having different variants of the problem? (It's entirely Python version dependent?).
This was the first time I've seen this new address. I'm assuming it's Python version dependent as that's the only thing I've changed but there is a small chance that it's network related, will test that assumption when I get the chance. Unfortunately there's not very much literature on this problem, only a couple of posts from people asking why socket.getfqdn() doesn't match hostname -f and a cPython issue.
Q: Why does socket.getfqdn() not match hostname -f?
A: Because of a long-standing Python bug.
Q: What the hell is "arpa"?
A: The in-addr.arpa and ip6.arpa are the IP V4 and V6 variants of a special domain used for reverse DNS lookups.
What can we do about it?
- Blacklist known localhost references (has worked so far but is annoying and ugly).
- Here's a patch associated with the Python bug report, but not accepted. It uses
gethostbyaddrwhich is V4/6 compliant. - Subprocess call to
hostname -f:grin:
Will try out gethostbyaddr when I get a chance, should be fine, but any change to this sensitive code is a risk.
A: Because of a https://github.com/python/cpython/issues/49254.
Damn, disappointing that that has not been fixed yet.
Could we use the patch referred to at the end of that Python issue?
Could we use the patch referred to at the end of that Python issue?
Yep, a couple of other systems appear to be doing this. It is a little risky though as we know this code to be sensitive.
FYI: This is waiting on me, I need to confirm this new arpa I encountered is due to the default Mac OS DNS config and not due the to configuration of the wider network.
If it is, we need to decide whether to go for the more general, but riskier patch above, or just to hardcode the new exception as done before.
Low priority until we start getting bug reports.
I think the differing result I was seeing may have been a result of local network / ISP both of which can influence a fully IP based setup.
I'm going to put this one to sleep for now until it gets reported.
I'm going to put this one to sleep for now until it gets reported.
It has been reported! #6147
Thank you so much guys ! 🙏
@hjoliver, suggest going ahead with the workaround for now and looking into more advanced methods in the future, possibly in combination with an overhaul of Cylc's DNS use in general.
Do we want a changelog entry for this one?
Nah