Skip to content

chore: enable and fix noctx issues - #3266

Open
mmorel-35 wants to merge 1 commit into
moby:masterfrom
mmorel-35:ctx
Open

chore: enable and fix noctx issues#3266
mmorel-35 wants to merge 1 commit into
moby:masterfrom
mmorel-35:ctx

Conversation

@mmorel-35

Copy link
Copy Markdown
Contributor

- What I did

enable and fix noctx issues

- How I did it

Add noctx to noctx to enabled linters and fix raised issues

- How to test it

- Description for the changelog

@mmorel-35
mmorel-35 force-pushed the ctx branch 2 times, most recently from 717bd3a to 5d33adc Compare July 29, 2026 05:44
@codecov-commenter

codecov-commenter commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 14.72%. Comparing base (6e9e7b8) to head (5258bff).
⚠️ Report is 68 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3266      +/-   ##
==========================================
- Coverage   14.73%   14.72%   -0.02%     
==========================================
  Files         200      200              
  Lines       93077    93033      -44     
==========================================
- Hits        13712    13696      -16     
+ Misses      78019    77994      -25     
+ Partials     1346     1343       -3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mmorel-35
mmorel-35 force-pushed the ctx branch 2 times, most recently from ab4ad04 to 7b4aaea Compare July 30, 2026 11:07
Comment thread ca/testutils/cautils.go
Comment on lines +164 to +168
if t != nil {
ctx = t.Context()
} else {
ctx = context.Background()
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was curious why the nil-check was needed, but it looks because we also use the same utility for TestMain;

func TestMain(m *testing.M) {
tc = cautils.NewTestCA(nil)
res := m.Run()
tc.Stop()
os.Exit(res)
}

So, it's "ok" for now to do this, but perhaps we should look at;

  • rewriting these utilities to return an error + a wrapper that's a t.Helper(), which would change error -> t.Fail
  • OR; depending on how many tests require this; call the setup for each test individually. We'd have to look how costly it is (alternative could potentially be some sync.Once to prevent repeating it)

Last one is mostly to see if we need a TestMain (perhaps we still do, but I also notice an init func in that same file;

func init() {
grpclog.SetLoggerV2(grpclog.NewLoggerV2(io.Discard, io.Discard, io.Discard))
log.L.Logger.SetOutput(io.Discard)
}

Comment thread ca/transport.go Outdated
@@ -352,7 +352,7 @@ func (t *Transport) dial(addr string) (*grpc.ClientConn, error) {
// TODO(anshul) Add an option to configure this.
grpcOptions = append(grpcOptions,
grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one's deprecated, so we may as well do;

grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
	return (&net.Dialer{}).DialContext(ctx, "tcp", addr)
})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

.. I think? (or would we lose the timeout?)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants