On two separate occasions GitHub added random garbage into the hosts
file breaking our tests.  This change adds a permanent workaround for
this kind of stuff.  It will remove everything that doesn't look like
a correct syntax from the file.

The regex is not perfect, but it should be sufficient for most cases.
It allows empty lines, comments and a valid 'IP NAME[ NAME]...' lines,
where 'IP' resembles an IP address and the 'NAME' consists of valid
DNS characters.  Under normal conditions the diff should always be
empty.

Signed-off-by: Ilya Maximets <i.maxim...@ovn.org>
---
 .github/workflows/build-and-test.yml | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/.github/workflows/build-and-test.yml 
b/.github/workflows/build-and-test.yml
index cea15fbb5..aa429c67b 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -279,6 +279,20 @@ jobs:
       with:
         python-version: ${{ env.python_default }}
 
+    - name: fix /etc/hosts
+      # On multiple occasions GitHub added things to /etc/hosts that are not
+      # a correct syntax for this file causing test failures:
+      #   https://github.com/actions/runner-images/issues/3353
+      #   https://github.com/actions/runner-images/issues/12192
+      # Just clearing those out, if any.
+      run: |
+        set -x
+        cp /etc/hosts ./hosts.bak
+        sed -E -n \
+          
'/^[[:space:]]*(#.*|[0-9a-fA-F:.]+([[:space:]]+[a-zA-Z0-9.-]+)+|)$/p' \
+          ./hosts.bak | sudo tee /etc/hosts
+        diff -u ./hosts.bak /etc/hosts || true
+
     - name: DPDK cache
       if:   matrix.dpdk != '' || matrix.dpdk_shared != ''
       uses: actions/cache@v4
-- 
2.49.0

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to