Conversation
# Conflicts: # cmd/src/code_intel_upload_flags.go
|
Thank you for such a thorough write-up of your testing examples!! 😄 |
courier-new
left a comment
There was a problem hiding this comment.
I defer to others on the team for a heavier review of the docker-specific interactions, but the mounted file handling and other changes look great to me. 🙂
eseliger
left a comment
There was a problem hiding this comment.
Great PR description and testing! I left a few comments inline
| } | ||
| // Update the mount path to the absolute path so building the absolute path (above) does not need to be | ||
| // redone when adding the mount argument to the Docker container. | ||
| step.Mount[j].Path = p |
There was a problem hiding this comment.
Can this affect caching somehow? Sorry, I feel like I should know, but sadly I don't 👎
There was a problem hiding this comment.
I don't see any issues with caching, but I am not super familiar with the cache yet.
Actually, I was having issues with the cache where I would only make a change to the script file and would rerun the batch spec and nothing would change because of the cache (for example changing the text to append to the README.md from Hello from python to Hello from python1).
I was getting slightly annoyed with this issue, and I am sure another user will too. Is this something we want to deal with in this Issue or in a follow up Issue?
There was a problem hiding this comment.
I just saw the flag -clear-cache. So I guess, it is really not a problem? Maybe we should have some docs around the mount and cache and communicate that the -clear-cache flag is available when updating the script[s]?
There was a problem hiding this comment.
I'd actually be inclined to go the other way, and start by not using or writing to the cache at all if mount is in use to avoid this problem.
In a follow up, I think we could start figuring out how to use the cache in some ways — we probably don't want to hash every file in mount (since some users will probably be mounting large binaries or other files), but maybe we could come up with a make style heuristic around last modification time.
There was a problem hiding this comment.
@LawnGnome what is the best way to go about creating a followup to "re-implement" caching for mount functionality? Create an Issue and talk about it? Design sesh? RFC?
LawnGnome
left a comment
There was a problem hiding this comment.
This looks really good! I have a few questions, but nothing fundamental to how this is implemented.
|
It would appear that Erik and my owls crossed in mid-air. Sorry! |
…ry of the batch spec
…is provided as standard input
# Conflicts: # go.mod # go.sum
…c for remote processing
…to be sent for server-side processing
|
Very cool! I like that you can mount an entire directory as well 💯 I can think of many users that are gonna love this right away. |
Closes #31790.
Add the ability to mount a path on the local machine into a container during a
step.A
pathcan point to a file (./foo.shor/bar/foo.sh) or a directory (./baror/foo/bar/). Thepathcan be an absolute path or a relative path (for example./foo.sh). Regardless if the path is absolute or relative, the path must be within the same directory as the batch spec that is being ran (the batch spec directory is considered the "working directory").Validation/handling of the
mountfield in astepis handled in thesrc-cliversusbatcheslibinsourcegraph/sourcegraph. The reason for this was the avoid having conditional logic to figure out ifparseBatchSpecis being called on a local machine vs behind an API. This also contains the file system logic within the context ofsrc-cliwhich is dealing with the file system.This PR also includes some general fixes I saw while in the code (for example, package and variable naming collision).
Test plan
Go Unit Tests and manual testing.
Examples
Below are examples of mounting a path that contains a script (python or Go binary in this case) that is ran in the
runfield of astep.Python
Example of running a python script that is mounted into the container and ran in a
step.Batch Spec
Script
Changesets
Binary
Example of running a binary (written in Go) that is mounted into the container and ran in a
step.Batch Spec
Binary
Binary was built from Go
Built with the following command,
env GOOS=linux GOGOARCH=amd64 go build -ldflags="-s -w"Changesets
Directory
The above examples have the
pathpointing to a specific file. Directories can also be mounted in the container. This example reuses the above Python Example but mounts a directory that contains the script.Batch Spec
Changesets