Skip to content
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

Support mounting remote archives #620

Merged
merged 8 commits into from
Oct 3, 2023
Merged

Conversation

fkorotkov
Copy link
Contributor

Allow to pass an HTTPS link instead of a local path to tart run --dir argument. HTTPS link should point to a gzipped Tar archive aka *.tar.gz file.

In this situation Tart will download an archive by the link if necessary, will cache it and will unarchive it into a temporary folder inside $TART_HOME to be mounted to the VM.

This use case is useful for mounting something external that updates faster than the VM itself. For example, GitHub Actions Runner installation.

Allow to pass an HTTPS link instead of a local path to `tart run --dir` argument. HTTPS link should point to a gzipped Tar archive aka `*.tar.gz` file.

In this situation Tart will download an archive by the link if necessary, will cache it and will unarchive it into a temporary folder inside `$TART_HOME` to be mounted to the VM.

This use case is useful for mounting something external that updates faster than the VM itself. For example, GitHub Actions Runner installation.
@@ -598,13 +599,71 @@ struct VMView: NSViewRepresentable {
}
}

func sanitizeDirectoryShareConfiguration(createFrom: String) throws -> String {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think sanitizeDirectoryShareConfiguration()'s is a bit overloaded and it name seems to be misleading because what it really does is:

  1. Parse()
  2. Fetch()
  3. Unarchive()

What do you think about:

  1. Keeping the DirectoryShare() call as it was before
  2. Moving the Parse() part of sanitizeDirectoryShareConfiguration() into DirectoryShare()
    • we could also preserve :ro there (e.g. http://127.0.0.1:8080/archive.tar.gz:ro would set readOnly to true)
  3. Calling Fetch() and Unarchive() from DirectoryShare() if we're dealing with an URL

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a bit different and moved the logic to DirectoryShare#createConfiguration method. See 8c0f8f4.

fkorotkov added a commit that referenced this pull request Oct 3, 2023
@fkorotkov fkorotkov enabled auto-merge (squash) October 3, 2023 13:34
edigaryev
edigaryev previously approved these changes Oct 3, 2023
@fkorotkov
Copy link
Contributor Author

Fixed tests in d70fff2. @edigaryev PTAL

@fkorotkov fkorotkov merged commit 71d0322 into main Oct 3, 2023
5 checks passed
@fkorotkov fkorotkov deleted the support-mounting-remote-archives branch October 3, 2023 19:01
@fkorotkov
Copy link
Contributor Author

@ruimarinho FYI with Tart 2.1.0 you can mount a remote archives, for example:

tart clone ghcr.io/cirruslabs/macos-sonoma-base:latest sonoma-base
tart run --dir=ghar:https://github.com/actions/runner/releases/download/v2.309.0/actions-runner-osx-arm64-2.309.0.tar.gz sonoma-base

This way your Tart VM will have the latest GHA Runner mounted to /Volumes/My Shared Files/ghar folder.

@Jon889
Copy link

Jon889 commented Oct 4, 2023

@fkorotkov Have you got this working with the Github Action runner. I seem to have a problem where any run: step in the GitHub actions workflow fails with the error: /bin/bash: /Volumes/My: No such file or directory even just run: echo "hello"

Screenshot 2023-10-04 at 17 16 41

it seems like the runner can't be in directory whose path has spaces in it.

If I change the workflow to:

shell: bash -e "{0}"
run: echo "hello"

Then it all works. The default is without the quotes as specified here: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell

@fkorotkov
Copy link
Contributor Author

Yeah, seems GHA runner is not happy with such paths. Most actions can handle it though! You can change the mount point by running the following commands:

sudo umount "/Volumes/My Shared Files"
mkdir ~/workspace
mount_virtiofs com.apple.virtio-fs.automount ~/workspace

Then your runner will be in /Users/admin/workspace/ghar folder.

@Jon889
Copy link

Jon889 commented Oct 4, 2023

Thanks! I'll try that. I added a PR to the runner, but it seems it's a deliberate choice to not have the argument in quotes.

@ruimarinho
Copy link
Contributor

@fkorotkov this is very cool! In theory with orchard we just need to do --host-dirs= ghar:https://github.com/actions/runner/releases/download/v2.309.0/actions-runner-osx-arm64-2.309.0.tar.gz right?

@fkorotkov
Copy link
Contributor Author

Yep, should work with Orchard as well. I've also created this discussion so maybe GotHub folks will remove version number from the archive so it's easy to always point to the latest one. https://github.com/orgs/community/discussions/68788

@ruimarinho
Copy link
Contributor

@fkorotkov seems like Orchard has a stricter host dir policy. I've created a ticket to look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants