Skip to content

Use read deadline for registry server read#30

Merged
mikejholly merged 1 commit into
earthly-mainfrom
mh/registry-read-deadline
Oct 26, 2023
Merged

Use read deadline for registry server read#30
mikejholly merged 1 commit into
earthly-mainfrom
mh/registry-read-deadline

Conversation

@mikejholly

Copy link
Copy Markdown
Contributor

For the registry-over-gRPC proxy, we'll also want to timeout idle reads from the BK registry server so as not to leave connections open. Discovered while testing earthly/earthly#3420.

Comment thread api/services/registry/server.go Outdated
if err != nil {
return 0, err
}
buf := make([]byte, 32*1024)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we move this outside of the for loop? reallocating this buffer each time might be expensive.

Comment thread api/services/registry/server.go Outdated
@mikejholly mikejholly requested a review from alexcb October 24, 2023 00:55
Comment thread api/services/registry/server.go Outdated
}
return t, err
}
buf = buf[0:n]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems problematic, because this will shrink the buf, and the next time conn.Read(buf) is called, it could be smaller.

Maybe it's best to delete this line, and do w.Write(buf[0:n]) instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I missed that line when I made the previous change. Updated.

@mikejholly mikejholly requested a review from alexcb October 25, 2023 18:18
@mikejholly mikejholly force-pushed the mh/registry-read-deadline branch from 1f0bbc6 to d5e9d25 Compare October 25, 2023 20:49
@mikejholly mikejholly merged commit d5e9d25 into earthly-main Oct 26, 2023
mikejholly added a commit to earthly/earthly that referenced this pull request Oct 26, 2023
Enables image registry proxy support for Mac via a side-car `socat`
container. On Mac, `docker pull` (and friends) will make requests to
`localhost`. These requests will be answered by the `socat` container
and proxied through to the registry proxy server spawned by the CLI.
That server then sends the request to BK (remote or local) via the gRPC
tunnel.

Depends on: earthly/buildkit#30

#3412
@alexcb alexcb deleted the mh/registry-read-deadline branch January 26, 2024 20:57
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