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

🐛 Sanitize temporary filename for podman image load #803

Merged
merged 1 commit into from
Apr 30, 2024

Conversation

trgeiger
Copy link
Contributor

Description

The podman-specific kind-load commands in the Makefile currently write the image archive to a temporary file named $IM but that by default includes slashes and a colon. My changes replace any slashes or colons with hyphens to prevent any errors trying to write that file.

Also, the naming doesn't really matter, we can just make it be a hard-coded "tmp.tar" or something.

Also, also, I saw the closed PR from earlier today and the discussion about not getting too into the weeds on podman/docker-specific configuration in the Makefile, but the current setup will cause that file-write error for anyone who does use CONTAINER_RUNTIME=podman with our default env variables, so I figured that was worth a quick fix.

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@trgeiger trgeiger requested a review from a team as a code owner April 29, 2024 19:53
Copy link

netlify bot commented Apr 29, 2024

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit d813099
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/66312bab05a77d000869027f
😎 Deploy Preview https://deploy-preview-803--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Apr 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.21%. Comparing base (32ed986) to head (d813099).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #803   +/-   ##
=======================================
  Coverage   67.21%   67.21%           
=======================================
  Files          23       23           
  Lines        1467     1467           
=======================================
  Hits          986      986           
  Misses        415      415           
  Partials       66       66           
Flag Coverage Δ
e2e 45.53% <ø> (ø)
unit 61.34% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Makefile Outdated
rm $(IMG).tar
$(CONTAINER_RUNTIME) save $(IMG) -o /tmp/$(shell echo $(IMG) | sed 's/[/:]/-/g').tar
$(KIND) load image-archive /tmp/$(shell echo $(IMG) | sed 's/[/:]/-/g').tar --name $(KIND_CLUSTER_NAME)
rm /tmp/$(shell echo $(IMG) | sed 's/[/:]/-/g').tar
Copy link
Member

@m1kola m1kola Apr 30, 2024

Choose a reason for hiding this comment

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

Can we use mktemp here? I think it will be a bit more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just with the default randomly generated filename to simplify all of this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or even just a shell variable for the filename.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh, yeah good idea lol

Makefile Outdated
@@ -156,9 +156,9 @@ e2e-coverage:
kind-load: $(KIND) #EXHELP Loads the currently constructed image onto the cluster.
ifeq ($(CONTAINER_RUNTIME),podman)
Copy link
Member

Choose a reason for hiding this comment

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

Probably out of scope for what this PR is trying to accomplish (and I asked in the other now-closed PR), but would be possible to use this podman procedure for docker as well? That way we don't have to maintain two different implementations of kind-load.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would be find doing that, I can just remove the ifeq bits and leave only the first block with the temp archive. That should always work regardless of if the user is using podman, docker, or podman with the "podman-docker" alias package.

Makefile Outdated
Comment on lines 157 to 160
TMP_FILE=$(shell mktemp -t operator-controller-image-archive-XXXX.tar) ;\
$(CONTAINER_RUNTIME) save $(IMG) -o $$TMP_FILE ;\
$(KIND) load image-archive $$TMP_FILE --name $(KIND_CLUSTER_NAME) ;\
rm $$TMP_FILE
Copy link
Member

@joelanford joelanford Apr 30, 2024

Choose a reason for hiding this comment

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

Even simpler?

$(CONTAINER_RUNTIME) save $(IMG) | $(KIND) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

very nice, implemented in latest push

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you or someone else has docker available, would be nice just to double check this works as expected

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh but the CI probably uses docker doesn't it?

This simplified logic should work on both podman and docker, removing
our need to have distinct ways of handling the image loading.
@joelanford joelanford added this pull request to the merge queue Apr 30, 2024
Merged via the queue into operator-framework:main with commit 79d64e8 Apr 30, 2024
16 checks passed
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.

None yet

4 participants