-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): change volume mount for networking to a simpler one
makes the old volume mount invalid and needs a new one to make the networking graph work correctly again BREAKING CHANGE: volume mount for networking graph is different now close #58
- Loading branch information
1 parent
c3ab094
commit 0a14c1f
Showing
6 changed files
with
50 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { exec as exaca } from 'child_process'; | ||
import * as fs from 'fs'; | ||
import { promisify } from 'util'; | ||
|
||
const exec = promisify(exaca); | ||
|
||
export let NET_INTERFACE = 'unknown'; | ||
|
||
export const setupNetworking = async () => { | ||
if (fs.existsSync('/mnt/host_ns_net')) { | ||
try { | ||
await exec('mkdir -p /mnt/host_sys'); | ||
await exec( | ||
'mountpoint -q /mnt/host_sys || nsenter --net=/mnt/host_ns_net mount -t sysfs nodevice /mnt/host_sys' | ||
); | ||
} catch (e) { | ||
console.warn(e); | ||
} | ||
|
||
try { | ||
const { stdout } = await exec( | ||
"nsenter --net=/mnt/host_ns_net route | grep default | awk '{print $8}'" | ||
); | ||
NET_INTERFACE = stdout.trim(); | ||
|
||
console.log(`Using network interface "${NET_INTERFACE}"`); | ||
} catch (e) { | ||
console.warn(e); | ||
} | ||
} else { | ||
console.log(`Using default container network interface`); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters