-
Notifications
You must be signed in to change notification settings - Fork 1.7k
chore: Upgrade dependencies - primarily addressing breaking changes in docker packages #9927
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
base: main
Are you sure you want to change the base?
Conversation
…n docker packages
Summary of ChangesHello @mattsanta, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on upgrading various dependencies in the project, primarily to address breaking changes in Docker packages and to keep the project up-to-date with the latest library versions. The updates also include code modernization by migrating to the new Moby client, enhancing compatibility and stability. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
…n docker packages
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.
Code Review
This pull request upgrades a significant number of dependencies, most notably migrating from the docker/docker client to the moby/moby client. While most of the changes correctly adapt to the new APIs, I've found several issues related to incorrect API usage with the new Moby client, which will lead to compilation errors or incorrect behavior. These issues are primarily in pkg/skaffold/docker/image.go and need to be addressed. I've also pointed out some incorrect struct field access in the integration tests due to the API changes.
| // Delete stops, removes, and prunes a running container | ||
| func (l *localDaemon) Delete(ctx context.Context, out io.Writer, id string) error { | ||
| if err := l.apiClient.ContainerStop(ctx, id, container.StopOptions{}); err != nil { | ||
| if _, err := l.apiClient.ContainerStop(ctx, id, client.ContainerStopOptions{}); 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.
The ContainerStop function from the Moby client returns only an error. Using a blank identifier _ for a non-existent return value will cause a compilation error.
| if _, err := l.apiClient.ContainerStop(ctx, id, client.ContainerStopOptions{}); err != nil { | |
| if err := l.apiClient.ContainerStop(ctx, id, client.ContainerStopOptions{}); err != nil { |
| log.Entry(ctx).Debugf("unable to stop running container: %s", err.Error()) | ||
| } | ||
| if err := l.apiClient.ContainerRemove(ctx, id, container.RemoveOptions{}); err != nil { | ||
| if _, err := l.apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{}); 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.
The ContainerRemove function from the Moby client returns only an error. Using a blank identifier _ for a non-existent return value will cause a compilation error.
| if _, err := l.apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{}); err != nil { | |
| if err := l.apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{}); err != nil { |
|
|
||
| func (l *localDaemon) NetworkRemove(ctx context.Context, name string) error { | ||
| return l.apiClient.NetworkRemove(ctx, name) | ||
| _, err := l.apiClient.NetworkRemove(ctx, name, client.NetworkRemoveOptions{}) |
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.
The NetworkRemove function in the Moby client returns only an error and does not accept client.NetworkRemoveOptions. The blank identifier _ and the options argument are incorrect and will cause a compilation error.
| _, err := l.apiClient.NetworkRemove(ctx, name, client.NetworkRemoveOptions{}) | |
| return l.apiClient.NetworkRemove(ctx, name) |
| if _, err := l.apiClient.ImageTag(ctx, client.ImageTagOptions{Source: image, Target: ref}); err != nil { | ||
| return err | ||
| } |
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.
| so.Timeout = util.Ptr[int](int(stopTimeout.Seconds())) | ||
| } | ||
| if err := l.apiClient.ContainerStop(ctx, id, so); err != nil { | ||
| if _, err := l.apiClient.ContainerStop(ctx, id, so); 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.
|
|
||
| func (l *localDaemon) Remove(ctx context.Context, id string) error { | ||
| if err := l.apiClient.ContainerRemove(ctx, id, container.RemoveOptions{}); err != nil { | ||
| if _, err := l.apiClient.ContainerRemove(ctx, id, client.ContainerRemoveOptions{}); 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.
| containers, err := dockerclient.ContainerList(context.Background(), client.ContainerListOptions{All: true}) | ||
| if err != nil { | ||
| t.Fail() | ||
| } | ||
| time.Sleep(sleepTime) | ||
| if len(containers) == 0 { | ||
| if len(containers.Items) == 0 { | ||
| continue | ||
| } | ||
|
|
||
| checkEntrypointRewrite(containers, &verifyEntrypointRewrite) | ||
| checkSupportContainer(containers, &verifySupportContainer) | ||
| checkEntrypointRewrite(containers.Items, &verifyEntrypointRewrite) | ||
| checkSupportContainer(containers.Items, &verifySupportContainer) |
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.
The result of ContainerList from the new Moby client is a struct that contains the list of containers in the Items field. The code needs to be updated to access this field to get the list of containers.
| containers, err := dockerclient.ContainerList(context.Background(), client.ContainerListOptions{All: true}) | |
| if err != nil { | |
| t.Fail() | |
| } | |
| time.Sleep(sleepTime) | |
| if len(containers) == 0 { | |
| if len(containers.Items) == 0 { | |
| continue | |
| } | |
| checkEntrypointRewrite(containers, &verifyEntrypointRewrite) | |
| checkSupportContainer(containers, &verifySupportContainer) | |
| checkEntrypointRewrite(containers.Items, &verifyEntrypointRewrite) | |
| checkSupportContainer(containers.Items, &verifySupportContainer) | |
| containers, err := dockerclient.ContainerList(context.Background(), client.ContainerListOptions{All: true}) | |
| if err != nil { | |
| t.Fail() | |
| } | |
| time.Sleep(sleepTime) | |
| if len(containers.Items) == 0 { | |
| continue | |
| } | |
| checkEntrypointRewrite(containers.Items, &verifyEntrypointRewrite) | |
| checkSupportContainer(containers.Items, &verifySupportContainer) |
| if cInfo.Container.State.Running { | ||
| containersRunning++ | ||
| } | ||
|
|
||
| if cInfo.State.Dead || cInfo.State.Restarting { | ||
| if cInfo.Container.State.Dead || cInfo.Container.State.Restarting { | ||
| return false, fmt.Errorf("container %v is in dead or restarting state", cn) |
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.
The ContainerInspect function returns a types.ContainerJSON object which has a State field directly. Accessing State via a Container field is incorrect and will fail. It should be cInfo.State.
| if cInfo.Container.State.Running { | |
| containersRunning++ | |
| } | |
| if cInfo.State.Dead || cInfo.State.Restarting { | |
| if cInfo.Container.State.Dead || cInfo.Container.State.Restarting { | |
| return false, fmt.Errorf("container %v is in dead or restarting state", cn) | |
| if cInfo.State != nil && cInfo.State.Running { | |
| containersRunning++ | |
| } | |
| if cInfo.State != nil && (cInfo.State.Dead || cInfo.State.Restarting) { | |
| return false, fmt.Errorf("container %v is in dead or restarting state", cn) | |
| } |
| return nil, errors.Wrap(err, "inspecting init container") | ||
| } | ||
| if len(r.Mounts) != 1 { | ||
| if len(r.Container.Mounts) != 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.
| return err | ||
| } | ||
| if r.Warning != "" { | ||
| if len(r.Warning) == 0 { |
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.
…rTools#9917) Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.43.0 to 0.45.0. - [Commits](golang/crypto@v0.43.0...v0.45.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-version: 0.45.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…n docker packages
chore: Upgrade dependencies - primarily addressing breaking changes in docker packages
Still WIP. Needs some dependencies to also address the breaking changes.
google/go-containerregistry#2160
buildpacks/pack#2470
buildpacks/imgutil#298