Skip to content

engine: improve error handling and retry logic in portforwarding. Fixes #2099#2198

Merged
nicks merged 1 commit into
masterfrom
nicks/issue2099
Sep 16, 2019
Merged

engine: improve error handling and retry logic in portforwarding. Fixes #2099#2198
nicks merged 1 commit into
masterfrom
nicks/issue2099

Conversation

@nicks

@nicks nicks commented Sep 13, 2019

Copy link
Copy Markdown
Contributor

Hello @landism, @maiamcc,

Please review the following commits I made in branch nicks/issue2099:

1b708ec (2019-09-13 15:48:00 -0400)
engine: improve error handling and retry logic in portforwarding. Fixes #2099

@maiamcc maiamcc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🙌

Comment thread internal/k8s/portforward.go Outdated
type PortForwardClient interface {
Create(ctx context.Context, namespace Namespace, podID PodID, localPort int, remotePort int) (closer func(), err error)
// Creates a new port-forwarder that's bound to the given context's lifecycle.
// Then the context is canceled, the port-forwarder will close.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Then the context is canceled, the port-forwarder will close.
// When the context is canceled, the port-forwarder will close.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread internal/k8s/portforward.go Outdated
Create(ctx context.Context, namespace Namespace, podID PodID, localPort int, remotePort int) (closer func(), err error)
// Creates a new port-forwarder that's bound to the given context's lifecycle.
// Then the context is canceled, the port-forwarder will close.
Create(ctx context.Context, namespace Namespace, podID PodID, localPort int, remotePort int) (PortForwarder, error)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Better named NewPortForwarderer or something, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


// Otherwise, repeat the loop, maybe logging the error
if err != nil {
logger.Get(ctx).Infof("Error port-forwarding %s: %v", entry.name, err)

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.

Maybe add a "Reconnecting..." here, to reduce the chance a user thinks they need to take action

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

ns := entry.namespace
podID := entry.podID

// TODO(nick): Add exponential retry & backoff

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.

is this still relevant, or is it taken care of by startPortForwardLoop?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@nicks
nicks force-pushed the nicks/issue2099 branch 2 times, most recently from a18cc39 to 5970291 Compare September 16, 2019 17:31
@nicks
nicks merged commit 860fbb5 into master Sep 16, 2019
@nicks
nicks deleted the nicks/issue2099 branch September 16, 2019 20:06
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.

[ BUGish ] Port-forward breaks, doesn't come back

3 participants