Skip to content

Conversation

@giuseppe
Copy link
Member

@giuseppe giuseppe commented Jul 23, 2025

commit 2d75d8e bumped the linter version without fixing the new issues.

Follow-up for #2482

Summary by Sourcery

Fix all reported lint errors by replacing context-less calls to exec.Command, net.Listen, and net.Dial with their context-aware counterparts across the codebase.

Enhancements:

  • Use exec.CommandContext with context.Background() instead of exec.Command for all external command invocations
  • Use net.ListenConfig.Listen with context.Background() instead of net.Listen for TCP listeners in tests
  • Use net.Dialer.DialContext with context.Background() instead of net.Dial for UNIX socket connections

@sourcery-ai
Copy link

sourcery-ai bot commented Jul 23, 2025

Reviewer's Guide

This PR migrates synchronous exec.Command, net.Listen, and net.Dial calls to their context-aware variants using context.Background, addressing lint errors introduced by the updated golangci-lint rules.

Class diagram for updated usage of exec and net packages

classDiagram
    class exec {
        +Command(name string, arg ...string) *Cmd
        +CommandContext(ctx context.Context, name string, arg ...string) *Cmd
    }
    class net {
        +Dial(network, address string) (Conn, error)
        +Dialer
        +Dialer.DialContext(ctx context.Context, network, address string) (Conn, error)
    }
    class context {
        +Background() Context
    }
    exec <.. context : uses
    net <.. context : uses
    net <|-- net.Dialer
    net.Dialer <.. context : uses
Loading

File-Level Changes

Change Details Files
Replace exec.Command with exec.CommandContext for process invocations
  • Migrate SSH and SCP exec.Command calls
  • Update apparmor_parser command executions
  • Adjust checkpoint/restore runtime command checks
  • Refactor cgroups test mknod invocation
  • Revise version package command querying
pkg/ssh/connection_native.go
pkg/apparmor/apparmor_linux.go
pkg/crutils/checkpoint_restore_utils.go
pkg/cgroups/cgroups_linux_test.go
pkg/version/version.go
Use context-aware listening in tests
  • Introduce net.ListenConfig and call Listen with context
  • Add context.Background for listener creation
libnetwork/cni/run_test.go
libnetwork/netavark/run_test.go
Replace net.Dial with DialContext via net.Dialer
  • Instantiate net.Dialer and call DialContext for unix sockets
  • Add context.Background for dialing operations
libnetwork/slirp4netns/slirp4netns.go
pkg/ssh/connection_golang.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @giuseppe - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 23, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, sourcery-ai[bot]

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@giuseppe giuseppe closed this Jul 23, 2025
commit 2d75d8e bumped the linter
version without fixing the new issues.

Follow-up for containers#2482

Signed-off-by: Giuseppe Scrivano <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant