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

[FEAT] Support explicit digest in mod list #922

Open
1 task done
qlonik opened this issue Jun 18, 2024 · 14 comments
Open
1 task done

[FEAT] Support explicit digest in mod list #922

qlonik opened this issue Jun 18, 2024 · 14 comments
Assignees
Labels
enhancement New feature or request work-in-progress Stale exempt

Comments

@qlonik
Copy link

qlonik commented Jun 18, 2024

Is this a new feature request?

  • I have searched the existing issues

Name of mod

mod-scripts (general)

Wanted change

Add support for specifying digests in the list of mods, e.g.:

DOCKER_MODS=ghcr.io/linuxserver/mods:universal-calibre-v7.12.0@sha256:e8aad70cc71c65587e28711ab16a0ffa1bbcb707b462a6313b721f7622529be3|ghcr.io/linuxserver/mods:lazylibrarian-ffmpeg@sha256:5083d9f2bdfcb27edf65a55e7c05d0ae8ce309d02d5f0cdc83bfe8e95c942dd4

Reason for change

This provides extra enforcement of the mod version.

I have renovate bot manage these sha256 digests for me: https://github.com/qlonik/musical-parakeet/blob/90396d3c0287656ad87c97e522a6d483f83ccf37/kubernetes/main/apps/default/lazylibrarian/app/helmrelease.yaml#L47-L60, so it is not a very big burden. I suspect other people might not have a setup like this, but it would be helpful to support explicit digests.

Proposed code change

No. It seems that either get_blob_sha needs to change or the call before this function needs to check for presence of sha256 in tag.

@qlonik qlonik added the enhancement New feature or request label Jun 18, 2024
qlonik added a commit to qlonik/musical-parakeet that referenced this issue Jun 18, 2024
@LinuxServer-CI
Copy link

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

@TheRedCyclops
Copy link

implementing this or explicit version numbers would be great

@LinuxServer-CI
Copy link

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

@asardaes
Copy link

asardaes commented Nov 2, 2024

+1 and hoping this is not closed due to inactivity

@LinuxServer-CI
Copy link

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

@thespad
Copy link
Member

thespad commented Dec 23, 2024

I'll have a look at this, it may be possible but it's going to require a bunch of changes to how we currently handle mods

@thespad
Copy link
Member

thespad commented Dec 30, 2024

OK so I have this working with one minor caveat. If you look at the debug logs you'll see something like:

[mod-init] (DEBUG) Mod SHA is sha256:7c6b7fa8184ac3c2f023fbbf318f5edb0987d5b1960fd5bc8be45b34fa844941
[mod-init] Installing linuxserver/mods:universal-tshoot@sha256:d31f2d4a88a0c5d98f6bf7f4725e228959b6d22dcd14d44c7a755521f007cd98

Because you're using the manfiest SHA to identify the image to pull, but we use the layer SHA to validate the mod. It's all working, it's just potentially confusing because of the different hashes.

@thespad
Copy link
Member

thespad commented Dec 30, 2024

If you want to test it out, then download https://github.com/linuxserver/docker-mods/blob/mod-scripts-sha/docker-mods.v3 and mount it into the container at /docker-mods (make sure it's executable) then try and add mods by SHA.

Note that this will currently only support the full:

linuxserver/mods:universal-tshoot@sha256:d31f2d4a88a0c5d98f6bf7f4725e228959b6d22dcd14d44c7a755521f007cd98

format and not the shorter form:

linuxserver/mods@sha256:d31f2d4a88a0c5d98f6bf7f4725e228959b6d22dcd14d44c7a755521f007cd98

@asardaes
Copy link

First of all, thanks for taking a look at this. If I understand correctly, the limitation you mention about the shorter form would be problematic with images published to ghcr.io if they overwrite the tag, right? For example this mod has a moving main tag, so every new publication untags the previous one and leaves only the short form reachable.

@thespad
Copy link
Member

thespad commented Dec 30, 2024

The true secret of the manifest hash format is that the tag doesn't actually do anything.

linuxserver/mods:universal-tshoot@sha256:d31f2d4a88a0c5d98f6bf7f4725e228959b6d22dcd14d44c7a755521f007cd98

is the same as

linuxserver/mods@sha256:d31f2d4a88a0c5d98f6bf7f4725e228959b6d22dcd14d44c7a755521f007cd98

is the same as

linuxserver/mods:foo@sha256:d31f2d4a88a0c5d98f6bf7f4725e228959b6d22dcd14d44c7a755521f007cd98

But from a "parsing out tags to use the correct bits in the API calls to the registry" perspective, it's significantly easier if we can always assume a tag is present.

@asardaes
Copy link

Do you think this would work? Trying to first split by @ and adjusting the subsequent logic based on that:

IFS="@" read -ra DOCKER_MOD_WITH_SHA <<<"$DOCKER_MOD"

if [[ "${DOCKER_MOD_WITH_SHA[1]}" =~ sha256: ]]; then
    TAGSHA="${DOCKER_MOD_WITH_SHA[1]}"
fi

TAG="${DOCKER_MOD_WITH_SHA[0]#*:}"
if [[ "${TAG}" == "${DOCKER_MOD_WITH_SHA[0]}" ]]; then
    TAG="latest"
fi

@thespad
Copy link
Member

thespad commented Dec 30, 2024

The short answer is I know roughly what needs to be done but it's a fair chunk of work to properly test and fix all the many stupid edge cases we have to deal with and it's the Christmas break so I can't be arsed to do it right now.

Once I've got some time and motivation in a couple of weeks I'll fix it up but in the meantime there's a version that works as long as the long-form image format is used.

@thespad
Copy link
Member

thespad commented Dec 31, 2024

I lied, I had time this afternoon #998

@asardaes
Copy link

Thanks, worked for me running in podman. BTW, I'd suggest leaving CURL_NOISE_LEVEL="-vs" when debugging curl, that way the download stats output (which can mess up the formatting of other logs) is suppressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request work-in-progress Stale exempt
Projects
Status: Issues
Development

No branches or pull requests

5 participants