Skip to content

Pull container image when out of date#272

Merged
JamieMagee merged 1 commit intomainfrom
jamiemagee/always-pull-container-image
Feb 18, 2025
Merged

Pull container image when out of date#272
JamieMagee merged 1 commit intomainfrom
jamiemagee/always-pull-container-image

Conversation

@JamieMagee
Copy link
Member

@JamieMagee JamieMagee commented Feb 8, 2024

This change adds an additional step to the pullImage function to query the relevant container registry and find the current digest for the tag we specify. We then compare it with the digest of the image we have locally. If they don't match, we attempt to pull the image.

@jakecoffman
Copy link
Member

I just tested this locally, since I build local ARM versions I'd have to remember to add --pull=false to test things I am building locally. Is it as this point we add a dependabot config command to set ~/.dependabot configurable defaults?

@JamieMagee
Copy link
Member Author

No, that's going to add too much complexity IMO. I'll have to do:

Exists locally Doesn't exist locally
Exists remotely Compare digest Pull
Doesn't exist remotely Continue with local image 🤷

@JamieMagee JamieMagee force-pushed the jamiemagee/always-pull-container-image branch 4 times, most recently from fd5ce42 to 603cbbe Compare February 12, 2025 19:09
@JamieMagee JamieMagee changed the title Always pull the container image Pull container image when out of date Feb 12, 2025
@JamieMagee
Copy link
Member Author

I've updated this PR to compare digests first, instead of just blindly pulling the latest container.

@JamieMagee JamieMagee marked this pull request as ready for review February 12, 2025 21:15
@JamieMagee JamieMagee requested a review from a team as a code owner February 12, 2025 21:15
@JamieMagee
Copy link
Member Author

Smoke test failures appear to be unrelated to my changes.

@JamieMagee JamieMagee force-pushed the jamiemagee/always-pull-container-image branch from 92da610 to 151fa1d Compare February 14, 2025 18:31
@jakecoffman
Copy link
Member

With the timestamp check this breaks my local workflow unless I add --pull=false. To debug issues usually once a day I do:

$ cd dependabot-core
$ script/build go_modules

Sometimes this is just main, but also I'll make modifications locally to help debug.

Then I'll run dependabot update ... for the rest of the day. It would be very confusing if it downloaded a newer version without me noticing.

I'm thinking a better approach would be to first see if a local image is custom by asking the registry if it has that SHA. If an image with that SHA doesn't exist, then don't automatically pull. If it has seen it that would indicate it's ok to pull the latest.

I do like this idea as a feature as we've seen folks confused that they need to update their local images occasionally.

@JamieMagee JamieMagee force-pushed the jamiemagee/always-pull-container-image branch from 151fa1d to cee6cc8 Compare February 18, 2025 20:19
@JamieMagee JamieMagee force-pushed the jamiemagee/always-pull-container-image branch from cee6cc8 to 699a63b Compare February 18, 2025 20:41
@JamieMagee
Copy link
Member Author

@jakecoffman I think I've addressed your concerns. The CLI will now check to see if the digest exists remotely. If yes, it will proceed to check if the digest is the latest for the current tag. If no, it will continue with the local digest and avoid the remote registry check.

Copy link
Member

@jakecoffman jakecoffman left a comment

Choose a reason for hiding this comment

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

Works for me locally!

It would be great to get some functional testing around this, like as in https://github.com/dependabot/cli/blob/c7aa6e76d4cec5d49e9494299cd052104e1306d0/testdata/scripts/timeout.txt#L25-L24

But we can move forward with this since it will improve some things on your side.

@JamieMagee JamieMagee added this pull request to the merge queue Feb 18, 2025
Merged via the queue into main with commit cea6443 Feb 18, 2025
72 of 76 checks passed
@JamieMagee JamieMagee deleted the jamiemagee/always-pull-container-image branch February 18, 2025 21:16
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.

2 participants