Skip to content

Commit

Permalink
portability: path mac os dns issues
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-sanders committed Jul 9, 2021
1 parent d26bf20 commit 70d0931
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/test_fast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ jobs:
- name: Brew Install
if: startsWith(matrix.os, 'macos')
run: |
# apply DNS patch
patch cylc/flow/hostuserutil.py < etc/conf/macos-patch
brew update
brew install shellcheck sqlite3 bash coreutils
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test_functional.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,6 @@ jobs:
- name: Brew Install
if: startsWith(matrix.os, 'macos')
run: |
# apply DNS patch
patch cylc/flow/hostuserutil.py < etc/conf/macos-patch
# install system deps
brew update
brew install bash coreutils gnu-sed
Expand Down
19 changes: 18 additions & 1 deletion cylc/flow/hostuserutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,19 @@
"""

from contextlib import suppress
import os
import pwd
import socket
from contextlib import suppress
import sys
from time import time

from cylc.flow.cfgspec.glbl_cfg import glbl_cfg


IS_MAC_OS = 'darwin' in sys.platform.lower()


class HostUtil:
"""host and user ID utility."""

Expand Down Expand Up @@ -114,6 +118,19 @@ def _get_host_info(self, target=None):
if target not in self._host_exs:
if target is None:
target = socket.getfqdn()
if (
IS_MAC_OS
and target == (
'1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.'
'0.0.0.0.0.0.ip6.arpa'
)
):
# Python's socket bindings don't play nicely with mac os
# so by default we get the above ip6.arpa adresss from
# socket.getfqdn, note this does *not* match `hostname -f`.
# https://github.com/cylc/cylc-flow/issues/2689
# https://github.com/cylc/cylc-flow/issues/3595
target = socket.gethostname()
try:
self._host_exs[target] = socket.gethostbyname_ex(target)
except IOError as exc:
Expand Down
13 changes: 0 additions & 13 deletions etc/conf/macos-patch

This file was deleted.

0 comments on commit 70d0931

Please sign in to comment.