-
Notifications
You must be signed in to change notification settings - Fork 5.7k
test(testutil): Performance and code quality improvements on container #17276
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: master
Are you sure you want to change the base?
test(testutil): Performance and code quality improvements on container #17276
Conversation
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 the PR @skartikey! I'm not sure where the performance improvement is but as I said in another, this is test-only code and therefore performance doesn't matter too much. Please find some comments in the code...
testutil/container.go
Outdated
@@ -193,6 +202,29 @@ func (c *Container) GetInfo() (string, error) { | |||
return "", fmt.Errorf("getting provider failed: %w", err) | |||
} | |||
|
|||
// Try direct inspection first - much more efficient than listing all images | |||
imageInfo, _, err := provider.Client().ImageInspectWithRaw(c.ctx, ci.ContainerJSONBase.Image) |
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 function is deprecated according to the linter.
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.
updated with the new method ImageInspect
4cad8ac
to
2ee0cf7
Compare
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 👍 This pull request doesn't change the Telegraf binary size 📦 Click here to get additional PR build artifactsArtifact URLs |
Summary
This PR optimizes Docker container operations in the testutil package to improve performance, particularly in environments with many Docker images or when processing multiple containers.
ImageList()
- retrieves ALL Docker images, then searches linearlyImageInspect()
- directly inspects the specific image by IDChecklist
Related issues
resolves #