-
Notifications
You must be signed in to change notification settings - Fork 3.1k
the first release of client replica #1692
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
dd647d5 to
97c78fc
Compare
|
@KernelDeimos @jelveh this PR is ready for review/merge |
f8a8be2 to
ede3cc2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Biggest concerns are:
- filesystem events should be used instead of adding hooks everywhere
- database
UPDATEadded tomoveoperation; I don't understand what it's fixing
Go code looks good to me, but I reviewed it very quickly since it's more outside the concern of the core backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(1) Why is this file changed? There do not appear to be any functional changes here - I think these changes were included by accident.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment "(1)"
|
|
||
| const db = services.get('database').get(DB_WRITE, 'filesystem'); | ||
| await db.write( | ||
| 'UPDATE fsentries SET parent_uid = ? WHERE uuid = ?', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit concerning to see this change. If the parent_uid was not already being updated, that would mean move is currently broken. However, I just tried moving a file in prod - move is not broken.
A second area of concern is I was informed that the relica code won't do anything if it's not enabled, however this looks like a database operation that's happening every time a file is moved without any feature flag being checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not broken but the parent_uid is wrong without this patch, see here for details:
the code below this patch doesn't set the parent_uid correctly:
puter/src/backend/src/modules/puterfs/lib/PuterFSProvider.js
Lines 223 to 232 in 847b3a0
| const op_update = await svc_fsEntry.update(node.uid, { | |
| ...( | |
| await node.get('parent_uid') !== await new_parent.get('uid') | |
| ? { parent_uid: await new_parent.get('uid') } | |
| : {} | |
| ), | |
| path: new_path, | |
| name: new_name, | |
| ...(metadata ? { metadata } : {}), | |
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found parent_uid is correct after moving, I'll look into this later
| console.error('user_id is missing'); | ||
| return; | ||
| } | ||
| await sendFSNew(user_id, response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't necessary to add these hooks into the filesystem implementation provider. This puts the responsibility on file system providers to inform the client-replica system of what's happening, requiring duplication of effort any time a new provider is added. This sort of thing is why we have filesystem events like fs.create.*, for example here. If the events don't have enough information or some events are missing (it looks like we don't have an event for delete yet) then the events should be updated to support that.
| } | ||
| if ( config.env === 'dev' && process.env.DEBUG ) { | ||
| console.log(`request url: ${req.url}, body: ${JSON.stringify(req.body)}`); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this conditional debug log being removed? This only prints of the DEBUG environment variable is set - it allows easier debugging of endpoints when Puter is initiated with a terminal input like: DEBUG=1 npm start
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, this log was added by me. I don't know others are using it - will revert this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I thought I added it, but let's keep it - it seems useful
| })(); | ||
|
|
||
| // ================== client-replica hook start ================== | ||
| // "rename" hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we can use events instead of this hook here that would be better.
ac6de4a to
9f4d6d0
Compare
stash changes
stash changes stash changes stash changes stash changes stash changes stash changes stash changes
stash changes stash changes stash changes stash changes stash changes stash changes stash changes stash changes stash changes
stash changes stash changes stash changes stash changes stash changes stash changes stash changes stash changes stash changes stash changes
9f4d6d0 to
0647fed
Compare
This is the first release of client-replica, check the RFC for details: https://github.com/XiaochenCui/puter/blob/fs/client-replica/doc/RFCS/20250821_client_replica_file_system.md
It's safe to merge and deploy it without update the config, no client will use client-replica in this case.
How to review
src/fs_tree_managersrc/fs_tree_manager/server.gosrc/fs_tree_manager/goandsrc/fs_tree_manager/jssrc/fs_tree_manager/merklesrc/fs_tree_manager/proto/fs_tree_manager.protosrc/puter-js/src/modules/FileSystem/replicasrc/backend/src/routers/filesystem_api/fs_tree_managerOther code are hooks for integration with the existing codebase.
Config
cp src/fs_tree_manager/example-config.yaml src/fs_tree_manager/config.yamlsrc/fs_tree_manager/config.yaml, set mysql args to the same as puter backend{ ... "services": { ... "client-replica": { "enabled": true, "fs_tree_manager_url": "<ip>:<port>" } } }Deploy
Whitelist
Whitelist is done by permission service: