Skip to content
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

fix: bad connection handling for in cluster dialer #1800

Merged
merged 4 commits into from
Jun 19, 2023

Conversation

matejvasek
Copy link
Contributor

@matejvasek matejvasek commented Jun 8, 2023

Changes

  • 🐛 Fix bad connection handling for in cluster dialer which caused confusing error messages (although functionality was not affected). Connections were closed from wrong end of io.Pipe
    which resulted in confusing error logs.
  • 🎁 Better error handling:
    • ContextDial() returns some errors immediately instead of deferring them on Read/Write operation on returned connection.
    • ContextDial() tries to parse socat's stderr and translate it to Go's net.OpError instead of just creating error with whole stderr embedded in it.

/kind bug

resolves: #1792

fix: connection handling for `in cluster dialer` causing confusing error messages #1792

@knative-prow knative-prow bot added kind/bug Categorizes issue or PR as related to a bug. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jun 8, 2023
@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Patch coverage: 89.38% and project coverage change: +1.31 🎉

Comparison is base (18fe643) 62.50% compared to head (7a18b2f) 63.81%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1800      +/-   ##
==========================================
+ Coverage   62.50%   63.81%   +1.31%     
==========================================
  Files         106      106              
  Lines       13417    13508      +91     
==========================================
+ Hits         8386     8620     +234     
+ Misses       4244     4077     -167     
- Partials      787      811      +24     
Flag Coverage Δ
e2e-test 37.44% <0.00%> (-0.27%) ⬇️
e2e-test-oncluster 33.07% <0.00%> (-0.31%) ⬇️
e2e-test-oncluster-runtime 28.39% <0.00%> (?)
e2e-test-runtime-go 27.11% <0.00%> (?)
e2e-test-runtime-node 28.20% <0.00%> (?)
e2e-test-runtime-python 28.20% <0.00%> (?)
e2e-test-runtime-quarkus 28.32% <0.00%> (?)
e2e-test-runtime-springboot 27.29% <0.00%> (?)
e2e-test-runtime-typescript 28.32% <0.00%> (?)
integration-tests 52.34% <89.38%> (+3.91%) ⬆️
unit-tests-macos-latest 49.56% <0.00%> (?)
unit-tests-ubuntu-latest 50.39% <0.00%> (-0.29%) ⬇️
unit-tests-windows-latest 49.61% <0.00%> (-0.34%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/k8s/dialer.go 78.36% <89.38%> (+4.53%) ⬆️

... and 10 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 8, 2023
Connections were closed from wrong end of io.Pipe
which resulted in confusing error logs.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
Now DialContext() returns some errors immediately
instead of deferring it Read/Write operation on the returned connection.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
Now ContextDial() tries to parse socat's stderr and translate it to Go's net.OpError
instead of just creating error with whole stderr embedded in it.

Signed-off-by: Matej Vasek <mvasek@redhat.com>
@matejvasek matejvasek changed the title [WIP] fix: bad connection handling for in cluster dialer fix: bad connection handling for in cluster dialer Jun 8, 2023
@matejvasek matejvasek marked this pull request as ready for review June 8, 2023 23:01
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 8, 2023
@knative-prow knative-prow bot requested a review from nainaz June 8, 2023 23:01
@matejvasek matejvasek requested review from zroubalik, lance, jrangelramos and lkingland and removed request for nainaz, dsimansk and navidshaikh June 8, 2023 23:02
@matejvasek
Copy link
Contributor Author

I recommend review each commit separately.

@matejvasek
Copy link
Contributor Author

@jrangelramos @lance PTAL

pkg/k8s/dialer.go Show resolved Hide resolved
pkg/k8s/dialer.go Show resolved Hide resolved
pkg/k8s/dialer_test.go Outdated Show resolved Hide resolved
pkg/k8s/dialer_test.go Outdated Show resolved Hide resolved
Co-authored-by: Lance Ball <lball@redhat.com>
@matejvasek
Copy link
Contributor Author

PTAL @zroubalik

@matejvasek
Copy link
Contributor Author

@zroubalik @lance we need to override the linter error here.

@matejvasek
Copy link
Contributor Author

@lkingland PTAL

@lance
Copy link
Member

lance commented Jun 13, 2023

/override "style / suggester / shell"
/override "style / suggester / yaml"
/override "style / suggester / github_actions"

@knative-prow
Copy link

knative-prow bot commented Jun 13, 2023

@lance: Overrode contexts on behalf of lance: style / suggester / github_actions, style / suggester / shell, style / suggester / yaml

In response to this:

/override "style / suggester / shell"
/override "style / suggester / yaml"
/override "style / suggester / github_actions"

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@matejvasek
Copy link
Contributor Author

/ok-to-test

@knative-prow knative-prow bot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Jun 14, 2023
@matejvasek
Copy link
Contributor Author

/test unit-tests_func_main
/test integration-tests_func_main
/test integration-tests-latest-release_func_main

@knative-prow
Copy link

knative-prow bot commented Jun 14, 2023

@matejvasek: No presubmit jobs available for knative/func@main

In response to this:

/test unit-tests_func_main
/test integration-tests_func_main
/test integration-tests-latest-release_func_main

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jun 19, 2023
@knative-prow
Copy link

knative-prow bot commented Jun 19, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lkingland, matejvasek

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:
  • OWNERS [lkingland,matejvasek]

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

@knative-prow knative-prow bot merged commit 3d11766 into knative:main Jun 19, 2023
41 checks passed
matejvasek added a commit to matejvasek/faas that referenced this pull request Aug 23, 2023
* fix: bad connection handling for in cluster dialer

Connections were closed from wrong end of io.Pipe
which resulted in confusing error logs.

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* feat: DialContext() better error handling

Now DialContext() returns some errors immediately
instead of deferring it Read/Write operation on the returned connection.

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* feat: DialContext() more better error handling

Now ContextDial() tries to parse socat's stderr and translate it to Go's net.OpError
instead of just creating error with whole stderr embedded in it.

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Apply suggestions from code review

Co-authored-by: Lance Ball <lball@redhat.com>

---------

Signed-off-by: Matej Vasek <mvasek@redhat.com>
Co-authored-by: Lance Ball <lball@redhat.com>
openshift-merge-robot pushed a commit to openshift-knative/kn-plugin-func that referenced this pull request Aug 24, 2023
…647)

* fix: bad connection handling for in cluster dialer (knative#1800)

* fix: bad connection handling for in cluster dialer

Connections were closed from wrong end of io.Pipe
which resulted in confusing error logs.

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* feat: DialContext() better error handling

Now DialContext() returns some errors immediately
instead of deferring it Read/Write operation on the returned connection.

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* feat: DialContext() more better error handling

Now ContextDial() tries to parse socat's stderr and translate it to Go's net.OpError
instead of just creating error with whole stderr embedded in it.

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* Apply suggestions from code review

Co-authored-by: Lance Ball <lball@redhat.com>

---------

Signed-off-by: Matej Vasek <mvasek@redhat.com>
Co-authored-by: Lance Ball <lball@redhat.com>

* fixup: update golangci-lit version

Signed-off-by: Matej Vasek <mvasek@redhat.com>

* fixup: update CI Go version

Signed-off-by: Matej Vasek <mvasek@redhat.com>

---------

Signed-off-by: Matej Vasek <mvasek@redhat.com>
Co-authored-by: Lance Ball <lball@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

io: read/write on closed pipe when in cluster OpenShift registry is used
3 participants