-
Notifications
You must be signed in to change notification settings - Fork 705
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
Add DockerHub implementation for send_tags #6580
Conversation
Signed-off-by: Michael Nelson <[email protected]>
✅ Deploy Preview for kubeapps-dev ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
// For now we use a default page size. | ||
url.query_pairs_mut() | ||
.append_pair("page_size", &format!("{}", DEFAULT_PAGE_SIZE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, are we only fetching (DEFAULT_PAGE_SIZE=100
) elements for now, aren't we? I mean, there I don't see any pagination logic here. It seems Docker is using a Link
header to let the client know about the next page (source), but we are not using it at the moment. No?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just the current default pagesize for the requests we make to dockerhub (ie. how big are the batches that we request), so will affect performance only (number of requests required to exhaust the result). It's not limiting how many results we get at all (ie. if I set this to 10, then the loop will fetch the results in batches of 10).
The gRPC API that we provide streams the result back, so no pagination required.
})) | ||
.await | ||
.unwrap(); | ||
async fn send_tags(&self, tx: mpsc::Sender<Result<Tag, Status>>, request: &ListTagsRequest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what is worth, (I guess you already know it, but just in case), here is the "official" (albeit tagged as experimental) DockerHub client: https://github.com/docker/hub-tool/blob/main/pkg/hub/tags.go#L61
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as you can see in their (go) client, they need to collect all the page results (appending to the array) before returning the result. In our case, we're wanting to stream the results back (via gRPC stream) while they're collected, which is why I'm using these send_tags
and send_repositories
, to show the results down a channel (which we can buffer as needed) and continue fetching.
BTW: interesting to see they use the same default page size :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat! Thanks for the explanation!
if response.next.is_some() { | ||
url = reqwest::Url::parse(&response.next.unwrap()).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - reading it twice, perhaps this is the pagination logic? If so, I would add some comments just for our future ourselves to understand 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is us using the pagination of the dockerhub API, yes - requesting the next page if response.next
is defined. I'll add a comment to that effect.
@@ -44,7 +60,7 @@ impl OCICatalogSender for DockerHubAPI { | |||
tx: mpsc::Sender<Result<Repository, Status>>, | |||
request: &ListRepositoriesRequest, | |||
) { | |||
let mut url = url_for_request(request); | |||
let mut url = url_for_request_repositories(request); | |||
|
|||
let client = reqwest::Client::builder().build().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not now, but given the DockerHub rate limits, perhaps it is worthwhile adding sth like: https://crates.io/crates/governor for better handling it on the client side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that'd be great to add in the future if we find we're hitting rate limits (I'll be testing this using the bitnami catalog, which is probably on the larger side of OCI helm registries).
Signed-off-by: Michael Nelson <[email protected]>
Description of the change
Adds the implementation for retrieving and sending tags for dockerhub repositories.
Benefits
Enables an initial integration to be tested.
Possible drawbacks
Applicable issues
Additional information
IRL test: