-
Notifications
You must be signed in to change notification settings - Fork 590
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
Send push timings to the server #2152
Conversation
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
…ngs-wiring Signed-off-by: Nikhil Sinha <[email protected]>
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.
⏱️👀
go.mod
Outdated
toolchain go1.23.2 | ||
go 1.23.0 | ||
|
||
toolchain go1.23.6 |
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 looks like maybe your asdf
installation isn't happy 🤔 The toolchain
should stay in lockstep with what is in .tool-versions
.
pkg/docker/push.go
Outdated
// Generate 256 bit random hash (4x64 bits) to use as an upload ID | ||
for i := 0; i < 4; i++ { | ||
// Ignoring the linter warning about math/rand/v2 not being cryptographically secure | ||
// because this just needs to be a "unique enough" ID for a cache between when the | ||
// push starts and ends, which should only be ~a week max. | ||
imageID = fmt.Sprintf("%s%x", imageID, rand.Int64()) //nolint:gosec | ||
} |
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.
- moving this to a function would be nice 😁
- I'm uncomfortable with this being random. Could it be deterministic instead? Isn't this ID assigned by the server side in a later step?
- does
rand.Int64
guarantee large enoughint64
values for our needs? The docs claim the value will always be a 63 bit int, so I think the answer is "yes", but wanted to call it out.
pkg/docker/push.go
Outdated
parts := strings.Split(imageMeta.ID, ":") | ||
if len(parts) != 2 { | ||
console.Warn("Image ID was not of the form sha:hash") | ||
} else { | ||
imageID = parts[1] | ||
} |
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: Ooh! Use strings.Cut instead!
pkg/docker/push.go
Outdated
err = webClient.PostBuildStart(ctx, imageID, buildTime) | ||
if err != nil { |
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: I don't see err
being used later, so
err = webClient.PostBuildStart(ctx, imageID, buildTime) | |
if err != nil { | |
if err := webClient.PostBuildStart(ctx, imageID, buildTime); err != nil { |
pkg/web/client.go
Outdated
} | ||
|
||
url := webBaseURL() | ||
url.Path = strings.Join([]string{"", "api", "models", "build-start"}, "/") |
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: Given there's no variable data in this string, I think it should be a const
instead.
pkg/web/client.go
Outdated
defer resp.Body.Close() | ||
|
||
if resp.StatusCode != http.StatusCreated { | ||
return errors.New("Bad response from new version endpoint: " + strconv.Itoa(resp.StatusCode)) |
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: it's not a huge deal in this context since the process is not long-lived, but errors.New
should generally not be used like this. Instead, define a module-level var
of the base error and then use error wrapping to include the variable bit.
…ngs-wiring Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
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.
Nice 🙌🏼 !
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
Signed-off-by: Nikhil Sinha <[email protected]>
…ngs-wiring Signed-off-by: Nikhil Sinha <[email protected]>
Summary
We want to know about how long it takes to build and push images. If we are introducing something called "fast push", we should probably know if it is actually faster or not than the same thing through the standard push flow.
Test Plan
Do a push with the fast push flow and the standard push flow and see if they still work