-
Notifications
You must be signed in to change notification settings - Fork 573
Improvements for remote controller code #1620
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
Conversation
We don't know if other builds might be running, etc, so we should allow the server to decide when to exit. Signed-off-by: Justin Chadwell <me@jedevc.com>
When exiting, we should ideally always print a message, and give details as to exactly what error we received. Signed-off-by: Justin Chadwell <me@jedevc.com>
This signal may be sent using an external tool such as pkill, and since we can handle it neatly, we should. Signed-off-by: Justin Chadwell <me@jedevc.com>
This patch improves timeout logic for testing and creating a buildx server. Instead of needing to have a custom loop, we can just use the primitives provided by go and grpc for easier handling. Additionally, without the explicit time.Sleeps, we defer to GRPCs exponential backoff algorithm which should provide substantially better results. Signed-off-by: Justin Chadwell <me@jedevc.com>
This ensures that we should never accidentally connect to a server with a mismatched version, while also allowing us to run multiple buildx servers at a time. Signed-off-by: Justin Chadwell <me@jedevc.com>
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.
Thank you, overall LGTM
defaultLogFilename = fmt.Sprintf("buildx.%s.log", version.Revision) | ||
defaultSocketFilename = fmt.Sprintf("buildx.%s.sock", version.Revision) | ||
defaultPIDFilename = fmt.Sprintf("buildx.%s.pid", version.Revision) |
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.
nit: Should be encoded not to include "/" (e.g. sha256?)
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.
I think these revisions are already sha256-encoded, they're derived from the git revision.
@crazy-max does this make sense to you? Is there a different version identifier that might make more sense here / do we need to add a round of sha256 to remove special characters?
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.
There is an edge case where version.Revision
can be empty if not built from the Dockerfile. I think we could use the same pattern as the kubernetes driver with contextPathHash
if that makes sense:
buildx/controller/build/build.go
Lines 182 to 186 in 74f64f8
// key string used for kubernetes "sticky" mode | |
contextPathHash, err := filepath.Abs(in.ContextPath) | |
if err != nil { | |
contextPathHash = in.ContextPath | |
} |
sha1
enc.
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.
As discussed I got confused as this is for buildx server and not build commands. We could use https://pkg.go.dev/runtime/debug#ReadBuildInfo and read vcs.revision
.
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.
Added a follow-up in #1637.
Added an updated commit to ensure that we take the absolute path of the buildx binary, since on exec we change the working directory to |
Signed-off-by: Justin Chadwell <me@jedevc.com>
d850278
to
54f4dc8
Compare
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.
Thank you. LGTM.
A few commits with various improvements for the remote controller code.
context.Context
for timeout handling with GRPC instead of a custom loop - this simplifies the code, makes it more configurable, and gives us better performance.log_file
specified inconfig.toml
. Ideas for this welcome 😄