Skip to content
This repository has been archived by the owner on Sep 28, 2024. It is now read-only.

Commit

Permalink
Revert "Propagate host DNS to workspaces"
Browse files Browse the repository at this point in the history
This reverts commit 4778145.
  • Loading branch information
gorbak25 committed Apr 3, 2023
1 parent 4778145 commit 11c4e14
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 22 deletions.
16 changes: 7 additions & 9 deletions app/agent/agent-util.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,22 @@ export class AgentUtilService {
}
}

async writeFile(
ssh: NodeSSH,
path: string,
content: string,
useSudo: boolean = false,
): Promise<void> {
const cmdPrefix = useSudo ? ["sudo"] : [];
async writeFile(ssh: NodeSSH, path: string, content: string): Promise<void> {
// I don't use SFTP because I've found it to be unreliable, causing
// untraceable errors.
try {
await execSshCmd(
{
ssh,
opts: {
stdin: content,
execOptions: {
env: {
FILE_CONTENT: content,
} as any,
},
},
},
[...cmdPrefix, "bash", "-c", `cat - > ${path}`],
["bash", "-c", `echo -n "$FILE_CONTENT" > ${path}`],
);
} catch (err) {
throw new Error(`Failed to write file "${path}": ${(err as any)?.message}`);
Expand Down
6 changes: 0 additions & 6 deletions app/agent/firecracker.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,6 @@ export class FirecrackerService {
useSudo,
);
}
await this.agentUtilService.writeFile(
ssh,
"/etc/resolv.conf",
(await fsAsync.readFile(this.agentConfig.dnsConfigPath)).toString(),
useSudo,
);
const r = await fn({
ssh,
sshConfig,
Expand Down
2 changes: 0 additions & 2 deletions app/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ export const config = makeConfig()({
"/srv/jailer/resources/checkout-and-inspect.ext4",
defaultWorkspaceRootFs:
process.env.DEFAULT_WORKSPACE_ROOTFS_PATH ?? "/srv/jailer/resources/default-workspace.ext4",
// DNS config which will be propagated to vm's
dnsConfigPath: process.env.AGENT_DNS_CONFIG_PATH ?? "/host/resolv.conf",
prebuildSshPublicKey:
process.env.AGENT_PREBUILD_SSH_PUBLIC_KEY ?? DEFAULT_PREBUILD_SSH_KEY_PUBLIC,
prebuildSshPrivateKey:
Expand Down
3 changes: 2 additions & 1 deletion hocus-workspace/resources/docker/dnssetup
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Setups /etc/hosts
# Short-Description: Setups /etc/resolv.conf
### END INIT INFO
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "127.0.0.1 localhost" >> /etc/hosts
1 change: 0 additions & 1 deletion ops/docker/agent-dev.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ services:
- "${REPO_DIR}:/app"
- "${HOCUS_RESOURCES_DIR}:/srv/jailer"
- /dev/kvm:/dev/kvm
- /etc/resolv.conf:/host/resolv.conf:ro
command: sleep infinity
1 change: 0 additions & 1 deletion ops/docker/agent-in-hocus.docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ services:
- "${AGENT_REPO_DIR}:/app"
- "${HOCUS_RESOURCES_DIR}:/srv/jailer"
- /dev/kvm:/dev/kvm
- /etc/resolv.conf:/host/resolv.conf:ro
environment:
- "HOCUS_DEV_GIT_NAME=${HOCUS_DEV_GIT_NAME}"
- "HOCUS_DEV_GIT_EMAIL=${HOCUS_DEV_GIT_EMAIL}"
Expand Down
1 change: 0 additions & 1 deletion ops/docker/hocus-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,3 @@ services:
volumes:
- agent_data:/srv/jailer:rw
- /dev/kvm:/dev/kvm
- /etc/resolv.conf:/host/resolv.conf:ro
3 changes: 2 additions & 1 deletion resources/docker/dnssetup
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Setups /etc/hosts
# Short-Description: Setups /etc/resolv.conf
### END INIT INFO
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "127.0.0.1 localhost" >> /etc/hosts

0 comments on commit 11c4e14

Please sign in to comment.