Skip to content

Commit d57c13a

Browse files
committed
disable sidecar -- let's go with the better/easier/simpler approach!
1 parent 919fcad commit d57c13a

File tree

2 files changed

+43
-132
lines changed

2 files changed

+43
-132
lines changed

src/packages/project-runner/run/filesystem.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import {
44
} from "@cocalc/conat/files/file-server";
55
import { type Client as ConatClient } from "@cocalc/conat/core/client";
66
import { sshServer as defaultSshServer } from "@cocalc/backend/data";
7-
import { join } from "node:path";
8-
import { mkdir } from "node:fs/promises";
97

108
//import getLogger from "@cocalc/backend/logger";
119

@@ -30,20 +28,12 @@ export async function setQuota(project_id: string, size: number | string) {
3028
await c.setQuota({ project_id, size });
3129
}
3230

33-
// default localPath if you don't specify something explicitly when calling
34-
// init in project-runner/run/index.ts
35-
// This is where the fileserver is storing files, and works if projects are
36-
// running on the same compute as the file server, e.g., dev mode.
31+
// where files are stored
3732
export async function localPath({
3833
project_id,
3934
}: {
4035
project_id: string;
4136
}): Promise<string> {
42-
if (process.env.COCALC_PROJECT_PATH) {
43-
const path = join(process.env.COCALC_PROJECT_PATH, project_id);
44-
await mkdir(path, { recursive: true });
45-
return path;
46-
}
4737
const c = getFsClient();
4838
const { path } = await c.mount({ project_id });
4939
return path;

src/packages/project-runner/run/podman.ts

Lines changed: 42 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import {
3737
type LocalPathFunction,
3838
} from "@cocalc/conat/project/runner/types";
3939
import { initSshKeys } from "@cocalc/backend/ssh-keys";
40-
import { PROJECT_IMAGE_PATH } from "@cocalc/util/db-schema/defaults";
40+
41+
const SIDECAR = false;
4142

4243
const logger = getLogger("project-runner:podman");
4344
const children: { [project_id: string]: any } = {};
@@ -64,16 +65,6 @@ export async function start({
6465
return;
6566
}
6667

67-
await initSidecar();
68-
const pod = `project-${project_id}`;
69-
try {
70-
await podman(["pod", "create", "--name", pod, "--network=pasta"]);
71-
} catch (err) {
72-
if (!`${err}`.includes("exists")) {
73-
throw err;
74-
}
75-
}
76-
7768
const home = await localPath({ project_id });
7869
logger.debug("start: got home", { project_id, home });
7970
const mounts = getCoCalcMounts();
@@ -87,15 +78,29 @@ export async function start({
8778
HOME: "/root",
8879
image,
8980
});
90-
const initMutagen = await startSidecar({
91-
image,
92-
project_id,
93-
home,
94-
mounts,
95-
env,
96-
pod,
97-
servers,
98-
});
81+
82+
let pod;
83+
if (SIDECAR) {
84+
// disable for now -- we might not need it
85+
await initSidecar();
86+
87+
pod = `project-${project_id}`;
88+
try {
89+
await podman(["pod", "create", "--name", pod, "--network=pasta"]);
90+
} catch (err) {
91+
if (!`${err}`.includes("exists")) {
92+
throw err;
93+
}
94+
}
95+
96+
await startSidecar({
97+
project_id,
98+
home,
99+
mounts,
100+
env,
101+
pod,
102+
});
103+
}
99104

100105
const rootfs = await rootFilesystem.mount({ project_id, home, config });
101106
logger.debug("start: got rootfs", { project_id, rootfs });
@@ -130,7 +135,9 @@ export async function start({
130135
args.push("--rm");
131136
args.push("--replace");
132137
args.push("--user=0:0");
133-
args.push("--pod", pod);
138+
if (SIDECAR) {
139+
args.push("--pod", pod);
140+
}
134141

135142
const cmd = "podman";
136143
const script = join(COCALC_SRC, "/packages/project/bin/cocalc-project.js");
@@ -167,19 +174,9 @@ export async function start({
167174
child.stderr.on("data", (chunk: Buffer) => {
168175
logger.debug(`project_id=${project_id}.stderr: `, chunk.toString());
169176
});
170-
171-
await initMutagen?.();
172177
}
173178

174-
async function startSidecar({
175-
image,
176-
project_id,
177-
mounts,
178-
env,
179-
pod,
180-
home,
181-
servers,
182-
}) {
179+
async function startSidecar({ project_id, mounts, env, pod, home }) {
183180
// sidecar: refactor
184181
const sidecarPodName = `sidecar-${project_id}`;
185182
const args2 = [
@@ -202,88 +199,10 @@ async function startSidecar({
202199

203200
args2.push(sidecarImageName, "mutagen", "daemon", "run");
204201

205-
// always start with fresh .mutagen
202+
// always start with fresh mutagen state
206203
await rm(join(home, ".mutagen-dev"), { force: true, recursive: true });
207204

208205
await podman(args2);
209-
210-
if (servers.length == 0) {
211-
return;
212-
}
213-
214-
const upperdir = join(PROJECT_IMAGE_PATH, image, "upperdir");
215-
await podman(
216-
[
217-
"exec",
218-
sidecarPodName,
219-
"rsync",
220-
"--relative",
221-
"-axH",
222-
`${servers[0].name}:${upperdir}/`,
223-
"/root/",
224-
],
225-
10 * 60,
226-
);
227-
228-
await podman(
229-
[
230-
"exec",
231-
sidecarPodName,
232-
"rsync",
233-
"-axH",
234-
"--exclude",
235-
".local/share/overlay/**",
236-
"--exclude",
237-
".cache/cocalc/**",
238-
"--exclude",
239-
".mutagen-dev/**",
240-
"--exclude",
241-
".ssh/**",
242-
"--exclude",
243-
".snapshots/**",
244-
`${servers[0].name}:/root/`,
245-
"/root/",
246-
],
247-
10 * 60,
248-
);
249-
250-
return async () => {
251-
await podman([
252-
"exec",
253-
sidecarPodName,
254-
"mutagen",
255-
"sync",
256-
"create",
257-
"--name=upperdir",
258-
"--mode=one-way-replica",
259-
"--symlink-mode=posix-raw",
260-
join("/root", upperdir),
261-
`${servers[0].name}:${upperdir}`,
262-
]);
263-
264-
await podman([
265-
"exec",
266-
sidecarPodName,
267-
"mutagen",
268-
"sync",
269-
"create",
270-
"--name=root",
271-
"--mode=two-way-resolved",
272-
"--symlink-mode=posix-raw",
273-
"--ignore",
274-
".local/share/overlay/**",
275-
"--ignore",
276-
".cache/cocalc/**",
277-
"--ignore",
278-
".mutagen-dev/**",
279-
"--ignore",
280-
".ssh/**",
281-
"--ignore",
282-
".snapshots/**",
283-
"/root",
284-
`${servers[0].name}:/root`,
285-
]);
286-
};
287206
}
288207

289208
export async function stop({
@@ -301,16 +220,18 @@ export async function stop({
301220

302221
if (child != null && child.exitCode == null) {
303222
const v: any[] = [];
304-
v.push(
305-
podman([
306-
"pod",
307-
"rm",
308-
"-f",
309-
"-t",
310-
force ? "0" : `${GRACE_PERIOD / 1000}`,
311-
`project-${project_id}`,
312-
]),
313-
);
223+
if (SIDECAR) {
224+
v.push(
225+
podman([
226+
"pod",
227+
"rm",
228+
"-f",
229+
"-t",
230+
force ? "0" : `${GRACE_PERIOD / 1000}`,
231+
`project-${project_id}`,
232+
]),
233+
);
234+
}
314235
v.push(
315236
podman([
316237
"rm",

0 commit comments

Comments
 (0)