-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: Support sync code with local folders #102
Comments
Other discussions: tensorchord/envd#530 |
Implementation notes (Ignore)
TODO:
SyncthingKsync ImplementationOketeto ImplementationInteracts with syncthing via binary cli Questions
Nonessential Features
|
Proof of ConceptFor a proof of concept, I added a syncthing container to DemoIn the demo, I'm manually clicking the sync button, but we can adjust the syncthing sync interval. Screen.Recording.2022-12-24.at.1.48.27.PM.movNext stepsFunctionalityLocal setup
Implement the manual sync steps with code: (I don't know how to do this yet)Syncthing uses xml to set up configurations (link)
Other features
Questions
|
I think we can add this to
We can setup a synching docker at user's side also as the client. It makes the binary delivery easier.
You can assume the working directory as the source directory now. We may provide more detailed configuration later.
We can generate a random ID directly. And use ssh port-forwarding to connect to the pod's syncthing ports. |
If you mean the binary install, bootstrap will be better. Or we need to add complex logic in attach |
And I am not sure if we should use synching or https://github.com/rclone/rclone XML config looks weird to me. |
You don't really have to work with the xml other than writing up the default. If you want to make changes to the configuration, you can also use the go struct (here)[https://pkg.go.dev/github.com/syncthing/[email protected]/lib/config#Configuration] so you don't have to work with the xml directly. Ksync and okteto both use syncthing but i can look into rclone a bit more. |
Design DocumentEnvd-server file sync functionality DescriptionWhen a pod/environment is provisioned after Functional Requirements
Non-functional Requirements
ImplementationSyncingThe core sync functionality is implemented by using syncthing, which can sync files between two devices. Syncthing on LocalThe syncthing binary is downloaded based on the user's os and architecture, it is installed on Syncthing on KubernetesFor syncthing in the kubernetes pod, we use an image of syncthing here to start it up as a container. In terms of the starting configuration, we send in the Working with SyncthingIn order to make changes or get information from the syncthing application (to add devices, add folders, check on status, etc.), we use the syncthing rest api. To communicate with the syncthing instance on kubernetes, the appropriate port needs to be forwarded. The two syncthing instances also need to be discoverable by each other. This can be done through ssh tunnel port forwarding. (I've only tested discovery with the kubernetes cluster and local syncthing instance on the same network/computer so I'm not sure if it'll be different if the kubernetes cluster is on another instance) Waiting for EventsSince most interactions with syncthing are asynchronous, we need to wait for operations to complete before proceeding. As a few examples, when the binary is executed, you need to wait for the syncthing application to start up to start calling the rest api, when configurations are applied via the rest api, syncthing returns a response immediately and you have to wait for the changes to actually be applied. Some other example asynchronous operations are when files are being scanned or folders are being synced. Therefore, for asynchronous operations that need to be awaited, there are Design ChoicesSyncthing configurationsFor the other kubernetes file sync implementations that I referenced (okteto, ksync) both use Connecting Two DevicesSyncthing's deviceIDs are generated deterministically from the priv/pub keys. For okteto's implementation, the deviceIDs and priv/pub keys are hard coded. However, for my implementation, I let syncthing autogenerate the deviceID and priv/pub keys and use the API to query the deviceID, and configure the file sync. Hopefully this will prove to be more flexible and extendable in the future. |
Will there be a syncthing process in the local host? |
Yes. The process is started with |
Cool. Then when will the process terminate? I think we can terminate it when users stop the ssh connection. |
For local development, I'm not sure if it's better to use Some corner cases:
|
Sure, or also when the environment is destroyed. I'm almost done with functionalities but haven't actually put the code in the cli commands yet. We can discuss more details after the core sync functionalities are finished! |
There can be an option to configure ignore files/folder but the case when you accidentally drop a large file into the folder can definitely be problematic. Potential solutions could be halt if a large file is detected, or ignore large files. What are you suggesting with mount? |
By default, we will mount the current working directory. I think it's not necessary to sync the files in this dir. |
Description
Currently, envd-server will clone the repo from the info of image label. We should also support sync with user's local folder
Current logic at https://github.com/tensorchord/envd-server/blob/main/pkg/server/environment_create.go#L175-L201
Reference:
Message from the maintainers:
Love this enhancement proposal? Give it a 👍. We prioritise the proposals with the most 👍.
The text was updated successfully, but these errors were encountered: