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(http): optional query parameter to update only containers of a specified image #1289

Merged
merged 12 commits into from
Jun 14, 2022

Conversation

Foxite
Copy link
Contributor

@Foxite Foxite commented May 12, 2022

Implements the second request from #1285: Added an optional query parameter that allows you to only update containers of the specified image. This works even if the image was built locally (ie the container no longer has the image label in docker ps).

Also includes an indentation fix that Goland went on strike over.

I will implement the first request later today, and probably add the ability to specify more than one image as well. This draft PR is so there can be a code review of what's already been done.

Don't hold back on roasting my Go skills. :P

@Foxite
Copy link
Contributor Author

Foxite commented May 16, 2022

CI is saying url.Has is undefined, but this very much compiles (and works) on my end. Am I using the wrong Go version or something? I didn't tell my IDE what it should use, go.mod seems to set it to 1.12 which doesn't match what the CI seems to use (1.15).

@Foxite
Copy link
Contributor Author

Foxite commented May 16, 2022

In any case, I think it's probably better to implement debouncing in the "glue proxy" that's needed if you use this to trigger updates by registry notifications, which is the only reason why debouncing is necessary in the first place.

@Foxite Foxite marked this pull request as ready for review May 16, 2022 14:38
@Foxite Foxite requested a review from simskij as a code owner May 16, 2022 14:38
pkg/api/update/update.go Outdated Show resolved Hide resolved
@piksel
Copy link
Member

piksel commented May 17, 2022

CI is saying url.Has is undefined, but this very much compiles (and works) on my end. Am I using the wrong Go version or something? I didn't tell my IDE what it should use, go.mod seems to set it to 1.12 which doesn't match what the CI seems to use (1.15).

Yeah,

func (Values) Has, added in go1.17

But I added a suggestion for skipping it (and saving a few CPU cycles! :D)

pkg/api/update/update.go Outdated Show resolved Hide resolved
cmd/root.go Outdated Show resolved Hide resolved
Copy link
Member

@piksel piksel left a comment

Choose a reason for hiding this comment

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

In general, this looks good! The main blocker is the lock handling (and the URL.Values.Has call).

Foxite and others added 4 commits May 17, 2022 18:16
Not sure what changed in my testing setup, but Docker reports image names including the tag name now.
@Foxite Foxite requested a review from piksel May 17, 2022 17:02
@codecov
Copy link

codecov bot commented May 20, 2022

Codecov Report

Merging #1289 (a4ba473) into main (56368a7) will increase coverage by 0.68%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1289      +/-   ##
==========================================
+ Coverage   63.13%   63.82%   +0.68%     
==========================================
  Files          23       23              
  Lines        1530     1534       +4     
==========================================
+ Hits          966      979      +13     
+ Misses        474      465       -9     
  Partials       90       90              
Impacted Files Coverage Δ
pkg/filters/filters.go 83.63% <100.00%> (+2.38%) ⬆️
pkg/container/client.go 30.80% <0.00%> (+2.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 56368a7...a4ba473. Read the comment docs.

@simskij simskij removed their request for review May 26, 2022 09:43
@piksel
Copy link
Member

piksel commented Jun 7, 2022

@Foxite are you still working on this?

@Foxite
Copy link
Contributor Author

Foxite commented Jun 7, 2022

I was confused by your earlier comment about the locking, I thought it was going to be complicated to make it do what I want (and postponed the task until I have time to learn about it). But upon re-reading it it seems simple; just to be clear, I understand that all that needs to be done is check if any images are specified, and only block on the lock if that's the case -- if not, then skip the request if the lock is not immediately acquired.

Or:

if len(images) > 0 {
  // old locking code
} else {
  // new locking code
}

Is that correct?

@Foxite
Copy link
Contributor Author

Foxite commented Jun 7, 2022

I've gone ahead and done that, and it works. So if I've understood you correctly, this should be ready to merge.

@piksel
Copy link
Member

piksel commented Jun 8, 2022

Sorry about that. Yeah, that was what I meant. When there are filter arguments to the requests, it makes sense to queue them up (unless they are the same, but would be much more complex to implement), but if it's just a "do the update now" it's probably better to ignore them ("yes, I am currently doing the update"). And also for the aforementioned backwards compatibility.

@Foxite
Copy link
Contributor Author

Foxite commented Jun 8, 2022

Looks like code coverage target is not met, I should probably write unit tests.

@Foxite
Copy link
Contributor Author

Foxite commented Jun 13, 2022

@piksel I have added unit tests and all the checks are green, how does it look?

Copy link
Member

@piksel piksel left a comment

Choose a reason for hiding this comment

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

LGTM! Great job.

@piksel piksel merged commit 739f328 into containrrr:main Jun 14, 2022
@piksel
Copy link
Member

piksel commented Jun 14, 2022

@all-contributors add @Foxite for code

@allcontributors
Copy link
Contributor

@piksel

I've put up a pull request to add @Foxite! 🎉

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