Skip to content

Commit 771ebb5

Browse files
authored
fix: stop online IPFS daemon before offline run
setup-ipfs always starts an online daemon (its run_daemon input is a no-op truthy string), which joined the public swarm and triggered Harden-Runner anomalous-egress warnings. Shut it down and wait for the RPC port to close before starting the isolated offline daemon, and probe the RPC API for readiness instead of 'ipfs id'. Signed-off-by: Alex Piatakov <alex.piatakov@swirldslabs.com>
1 parent 9a7b486 commit 771ebb5

5 files changed

Lines changed: 35 additions & 20 deletions

File tree

.github/workflows/api-after-commit.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,19 @@ jobs:
9191
uses: oduwsdl/setup-ipfs@678755ac20f92d2dfca7e16138e40ae75f7a0f6f # v0.8.0
9292
with:
9393
ipfs_version: 0.42.0
94-
run_daemon: false
95-
94+
9695
- name: Start IPFS offline
9796
shell: bash
9897
run: |
99-
ipfs config profile apply test # Routing.Type=none, no bootstrap, mDNS off, localhost-only
98+
# setup-ipfs always starts an online daemon (run_daemon is a no-op); stop it before our offline node.
99+
ipfs shutdown || true
100+
until ! curl -s -X POST http://127.0.0.1:5001/api/v0/id >/dev/null 2>&1; do sleep 0.5; done
101+
ipfs config profile apply test # Routing.Type=none, no bootstrap, mDNS off
100102
ipfs bootstrap rm --all
103+
ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001 # test profile randomizes ports; pin RPC for the app and probe
101104
ipfs config --json Discovery.MDNS.Enabled false
102105
ipfs daemon --offline &
103-
until ipfs id >/dev/null 2>&1; do sleep 0.5; done
106+
until curl -s -X POST http://127.0.0.1:5001/api/v0/id >/dev/null 2>&1; do sleep 0.5; done
104107
105108
- name: Start MongoDB
106109
uses: step-security/mongodb-github-action@ca72004b9c8ad6d9ed996c3174edbe62f9f7424a

.github/workflows/api-manual.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,19 @@ jobs:
9999
uses: oduwsdl/setup-ipfs@678755ac20f92d2dfca7e16138e40ae75f7a0f6f # v0.8.0
100100
with:
101101
ipfs_version: 0.42.0
102-
run_daemon: false
103-
102+
104103
- name: Start IPFS offline
105104
shell: bash
106105
run: |
107-
ipfs config profile apply test # Routing.Type=none, no bootstrap, mDNS off, localhost-only
106+
# setup-ipfs always starts an online daemon (run_daemon is a no-op); stop it before our offline node.
107+
ipfs shutdown || true
108+
until ! curl -s -X POST http://127.0.0.1:5001/api/v0/id >/dev/null 2>&1; do sleep 0.5; done
109+
ipfs config profile apply test # Routing.Type=none, no bootstrap, mDNS off
108110
ipfs bootstrap rm --all
111+
ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001 # test profile randomizes ports; pin RPC for the app and probe
109112
ipfs config --json Discovery.MDNS.Enabled false
110113
ipfs daemon --offline &
111-
until ipfs id >/dev/null 2>&1; do sleep 0.5; done
114+
until curl -s -X POST http://127.0.0.1:5001/api/v0/id >/dev/null 2>&1; do sleep 0.5; done
112115
113116
- name: Start MongoDB
114117
uses: step-security/mongodb-github-action@ca72004b9c8ad6d9ed996c3174edbe62f9f7424a

.github/workflows/api-schedule-all.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,19 @@ jobs:
9292
uses: oduwsdl/setup-ipfs@678755ac20f92d2dfca7e16138e40ae75f7a0f6f # v0.8.0
9393
with:
9494
ipfs_version: 0.42.0
95-
run_daemon: false
96-
95+
9796
- name: Start IPFS offline
9897
shell: bash
9998
run: |
100-
ipfs config profile apply test # Routing.Type=none, no bootstrap, mDNS off, localhost-only
99+
# setup-ipfs always starts an online daemon (run_daemon is a no-op); stop it before our offline node.
100+
ipfs shutdown || true
101+
until ! curl -s -X POST http://127.0.0.1:5001/api/v0/id >/dev/null 2>&1; do sleep 0.5; done
102+
ipfs config profile apply test # Routing.Type=none, no bootstrap, mDNS off
101103
ipfs bootstrap rm --all
104+
ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001 # test profile randomizes ports; pin RPC for the app and probe
102105
ipfs config --json Discovery.MDNS.Enabled false
103106
ipfs daemon --offline &
104-
until ipfs id >/dev/null 2>&1; do sleep 0.5; done
107+
until curl -s -X POST http://127.0.0.1:5001/api/v0/id >/dev/null 2>&1; do sleep 0.5; done
105108
106109
- name: Start MongoDB
107110
uses: step-security/mongodb-github-action@ca72004b9c8ad6d9ed996c3174edbe62f9f7424a

.github/workflows/api-schedule-vm0033.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,19 @@ jobs:
9292
uses: oduwsdl/setup-ipfs@678755ac20f92d2dfca7e16138e40ae75f7a0f6f # v0.8.0
9393
with:
9494
ipfs_version: 0.42.0
95-
run_daemon: false
96-
95+
9796
- name: Start IPFS offline
9897
shell: bash
9998
run: |
100-
ipfs config profile apply test # Routing.Type=none, no bootstrap, mDNS off, localhost-only
99+
# setup-ipfs always starts an online daemon (run_daemon is a no-op); stop it before our offline node.
100+
ipfs shutdown || true
101+
until ! curl -s -X POST http://127.0.0.1:5001/api/v0/id >/dev/null 2>&1; do sleep 0.5; done
102+
ipfs config profile apply test # Routing.Type=none, no bootstrap, mDNS off
101103
ipfs bootstrap rm --all
104+
ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001 # test profile randomizes ports; pin RPC for the app and probe
102105
ipfs config --json Discovery.MDNS.Enabled false
103106
ipfs daemon --offline &
104-
until ipfs id >/dev/null 2>&1; do sleep 0.5; done
107+
until curl -s -X POST http://127.0.0.1:5001/api/v0/id >/dev/null 2>&1; do sleep 0.5; done
105108
106109
- name: Start MongoDB
107110
uses: step-security/mongodb-github-action@ca72004b9c8ad6d9ed996c3174edbe62f9f7424a

.github/workflows/ui-manual.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,19 @@ jobs:
9292
uses: oduwsdl/setup-ipfs@678755ac20f92d2dfca7e16138e40ae75f7a0f6f # v0.8.0
9393
with:
9494
ipfs_version: 0.42.0
95-
run_daemon: false
96-
95+
9796
- name: Start IPFS offline
9897
shell: bash
9998
run: |
100-
ipfs config profile apply test # Routing.Type=none, no bootstrap, mDNS off, localhost-only
99+
# setup-ipfs always starts an online daemon (run_daemon is a no-op); stop it before our offline node.
100+
ipfs shutdown || true
101+
until ! curl -s -X POST http://127.0.0.1:5001/api/v0/id >/dev/null 2>&1; do sleep 0.5; done
102+
ipfs config profile apply test # Routing.Type=none, no bootstrap, mDNS off
101103
ipfs bootstrap rm --all
104+
ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001 # test profile randomizes ports; pin RPC for the app and probe
102105
ipfs config --json Discovery.MDNS.Enabled false
103106
ipfs daemon --offline &
104-
until ipfs id >/dev/null 2>&1; do sleep 0.5; done
107+
until curl -s -X POST http://127.0.0.1:5001/api/v0/id >/dev/null 2>&1; do sleep 0.5; done
105108
106109
- name: Start MongoDB
107110
uses: step-security/mongodb-github-action@ca72004b9c8ad6d9ed996c3174edbe62f9f7424a

0 commit comments

Comments
 (0)