Closed alienninja closed 2 years ago
In looking at this further, I found a more advanced example of TAR and implemented it in a fork. This is working for me, and the fork link is below. This also has a checksum capability where you can optionally specify a checksum via an environment variable. I still am in the process of testing the checksum feature. https://github.com/alienninja/hub/tree/main/actions/archive2disk/v1
The examples I used were: https://github.com/shuveb/containers-the-hard-way/blob/85013e2ebdc028a846b749cc0acc540085ff19cd/tarfile.go I didn't see a license file here.
I also referenced this example: https://github.com/hashicorp/terraform-provider-helm/blob/main/vendor/oras.land/oras-go/pkg/content/utils.go However, I was unable to get it working with the "prefix" parameter, and I wasn't sure if this was needed. It's checking to make sure that none of the TAR files target to outside of the target directory (I think), but some of the hardlinks start with "/" so it wasn't working as expected. This included the checksum code which seems like a good security feature.
My fork works as expected. Note for the end image to be bootable, the docker container image needs to include a lot more than just the default docker ubuntu:latest, I plan to post my example Dockerfile as well.
Maybe libarchive via go-libarchive could be useful here?
@alienninja I see your branch is under active development. Do you think it would be possible to open a PR and get your improvements upstreamed? Thank you for reporting this and finding the time to work on a solution!
@nshalman Sounds good, I'll submit a pull request. Thanks
After archive2disk runs, looking at the root directory, symbolic links show up as zero length files. This makes the partition unusable, and the actions after archive2disk fail. I discovered this issue trying to use cexec.
Expected Behaviour
archive2disk should check the header type of each file and process the files per the respective header type.
Current Behaviour
Symlinks get created as zero length files.
Possible Solution
Review all of the header types and process according to the type, including TypeSymlink
Steps to Reproduce (for bugs)
Context
I was trying to use archive2disk to untar an ubuntu_rootfs.tar.gz image. Since the tar file does not process symlinks correctly, the actions after archive2disk fail.
Manually extracting the file onto the partition works, and allows a cexec container to run. In looking at other uses of golangs tar package, files are processed based off the header.typeflag which includes TypeSymLlink
Your Environment
Operating System and version (e.g. Linux, Windows, MacOS):
The provisioner is running Ubuntu 20.04 on a VM on ESXi. The machine being provisioned is on the same ESXi server. So both VM's.
How are you running Tinkerbell? Using Vagrant & VirtualBox, Vagrant & Libvirt, on Packet using Terraform, or give details: Running Tinkerbell with docker-compose
Link to your project or a code example to reproduce issue: