cylc-flow icon indicating copy to clipboard operation
cylc-flow copied to clipboard

portability: permit arpa address

Open oliver-sanders opened this issue 2 years ago • 10 comments

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.md and 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 (and conda-environment.yml if present).
  • [x] Tests are included (or explain why tests are not needed).
  • [x] CHANGES.md entry 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 ?.?.x branch.

oliver-sanders avatar Mar 14 '23 13:03 oliver-sanders

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?).

hjoliver avatar Mar 15 '23 01:03 hjoliver

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.

oliver-sanders avatar Mar 16 '23 11:03 oliver-sanders

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?

  1. Blacklist known localhost references (has worked so far but is annoying and ugly).
  2. Here's a patch associated with the Python bug report, but not accepted. It uses gethostbyaddr which is V4/6 compliant.
  3. 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.

oliver-sanders avatar Mar 21 '23 17:03 oliver-sanders

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?

hjoliver avatar Mar 21 '23 20:03 hjoliver

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.

oliver-sanders avatar Mar 22 '23 15:03 oliver-sanders

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.

oliver-sanders avatar May 16 '23 10:05 oliver-sanders

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.

oliver-sanders avatar Dec 14 '23 12:12 oliver-sanders

I'm going to put this one to sleep for now until it gets reported.

It has been reported! #6147

oliver-sanders avatar Jun 17 '24 10:06 oliver-sanders

Thank you so much guys ! 🙏

elliotfontaine avatar Jun 19 '24 15:06 elliotfontaine

@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.

oliver-sanders avatar Jun 26 '24 11:06 oliver-sanders

Do we want a changelog entry for this one?

MetRonnie avatar Jul 04 '24 11:07 MetRonnie

Nah

oliver-sanders avatar Jul 04 '24 12:07 oliver-sanders