Skip to content

Commit

Permalink
get websocketfs to mount even "on my laptop", i.e., for some reason a…
Browse files Browse the repository at this point in the history
…llowOther isn't supported, and it's better to work without root being allowed (which I think we don't need), then to mysteriously fail
  • Loading branch information
williamstein committed Oct 15, 2024
1 parent 9235df5 commit 56a71df
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/compute/compute/dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ The scripts here are helpful for developing the compute\-server manager, which i
1. Create the directory /tmp/user and make sure you can read it. Maybe even mount it from the target project.

2. The conf/ directory here has the same files as on /cocalc/conf in an actual compute\-server, except:
- replace api_server by something like `http://localhost:5000/6659c2e3-ff5e-4bb4-9a43-8830aa951282/port/5000`, where the port is what you're using for your dev server and the project id is of your dev server. The point is that we're going to connect directly without going through some external server.
- replace api_server by something like `http://127.0.0.1:5000/6659c2e3-ff5e-4bb4-9a43-8830aa951282/port/5000`, where the port is what you're using for your dev server and the project id is of your dev server. The point is that we're going to connect directly without going through some external server.
- api_key: the one from an actual server will get deleted when you turn that server off, so make a different project level api key.

Type `tar xvf conf.tar` to get a template for the conf directory. You will need to change the contents
of all the files you get, as mentioned above!
Type `tar xvf conf.tar` to get a template for the conf directory.
You will need to change the contents of all the files you get, as
mentioned above! Also, regarding the api_server, be especially careful
about ipv4 versus ipv6, e.g., use 127.0.0.1 instead of localhost to
nail down the protocol.

This is potentially confusing, and when developing this it was 10x worse... Maybe you'll be confused for 2 hours instead of 2 days.

Expand Down
3 changes: 2 additions & 1 deletion src/compute/compute/dev/start-filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ async function main() {
});
unmount = exports.fs.unmount;
} catch (err) {
console.log("something went wrong ", err);
console.trace("something went wrong ", err);
exitHandler();
return;
}

const info = () => {
Expand Down
21 changes: 17 additions & 4 deletions src/compute/compute/lib/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { mount } from "websocketfs";
import getLogger from "@cocalc/backend/logger";
import { project } from "@cocalc/api-client";
import { serialize } from "cookie";
import { join } from "path";
import { API_COOKIE_NAME } from "@cocalc/backend/auth/cookie-names";
import syncFS from "@cocalc/sync-fs";
import {
Expand Down Expand Up @@ -100,7 +99,7 @@ export async function mountProject({
// Ping to start project so it's possible to mount.
await pingProjectUntilSuccess(project_id);

const remote = join(getProjectWebsocketUrl(project_id), "websocketfs");
const remote = getProjectWebsocketUrl(project_id) + "/websocketfs";
log("connecting to ", remote);
const headers = { Cookie: serialize(API_COOKIE_NAME, apiKey) };
// SECURITY: DO NOT log headers and connectOptions, obviously!
Expand Down Expand Up @@ -139,7 +138,7 @@ export async function mountProject({
progress: 30,
});

({ unmount } = await mount({
const websocketfsMountOptions = {
remote,
path: homeMountPoint,
...options,
Expand All @@ -163,7 +162,21 @@ export async function mountProject({
readTrackingExclude: exclude,
// metadata file
metadataFile,
}));
};

log("websocketfs -- mount options", websocketfsMountOptions);

try {
({ unmount } = await mount(websocketfsMountOptions));
} catch (err) {
log("failed trying to mount -- ", err);
log(
"try again without allowOther, since some versions of FUSE do not support this option",
);
websocketfsMountOptions.mountOptions.allowOther = false;
({ unmount } = await mount(websocketfsMountOptions));
}

pingInterval = setInterval(async () => {
try {
await project.ping({ project_id });
Expand Down

0 comments on commit 56a71df

Please sign in to comment.