-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
minikube tunnel #3015
minikube tunnel #3015
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. I understand the commands that are listed here. |
Can one of the admins verify this patch? |
c0314fd
to
ed3b4ba
Compare
cla signed. |
cc @dlorenc |
Couple of things while I was working on the comments: |
A lot changed in the last month:
I still have some outstanding tasks:
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: balopat 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 |
pkg/minikube/tunnel/registry.go
Outdated
return e | ||
} | ||
} | ||
defer f.Close() |
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.
If the content of this JSON file has any importance, check the error from f.Close().
pkg/minikube/tunnel/registry.go
Outdated
if err != nil { | ||
return fmt.Errorf("error removing tunnel %s", err) | ||
} | ||
defer f.Close() |
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.
Check the error here too.
pkg/minikube/tunnel/registry_test.go
Outdated
}, | ||
{ | ||
name: "Register + Remove + List", | ||
test: func(t *testing.T, reg *persistentRegistry) { |
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.
Still this. table driven tests should never contain test-specific logic: http://go/gotestcomments#when-to-use-table-driven-tests
pkg/minikube/tunnel/registry_test.go
Outdated
}, | ||
{ | ||
name: "Register + Remove + List", | ||
test: func(t *testing.T, reg *persistentRegistry) { |
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.
Name your errors 'err' when possible.
pkg/minikube/tunnel/tunnel.go
Outdated
func (t *minikubeTunnel) updateTunnelStatus() *Status { | ||
glog.V(3).Info("updating tunnel status...") | ||
t.status.MinikubeState, _, t.status.MinikubeError = t.clusterInspector.getStateAndHost() | ||
//TODO(balintp): clean this up to be more self contained |
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.
Clean this up, or remove the TODO. The grossness is self-evident.
pkg/minikube/tunnel/tunnel.go
Outdated
machineAPI libmachine.API, | ||
configLoader config.Loader, | ||
v1Core v1.CoreV1Interface, registry *persistentRegistry, router router) (*minikubeTunnel, error) { | ||
clusterInspector := &clusterInspector{ |
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.
name this "ci" so we don't have to guess if you mean the struct name or the local variable.
return fmt.Errorf("there is already a running tunnel for this machine: %s", id) | ||
} | ||
|
||
func newTunnel(machineName string, |
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.
Keep function signatures as a single line when possible. When it isn't possible, there is your hint that you should take a config struct.
pkg/minikube/tunnel/tunnel.go
Outdated
|
||
} | ||
|
||
type minikubeTunnel struct { |
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.
It's difficult to tell the difference between the minikubeTunnel
struct and tunnel
struct. Can you adjust one of the names to be more distinct?
minikube.tunnel.minikubeTunnel
is a rather perverse naming stutter, but since the struct name is private I won't worry too much about this.
pkg/minikube/tunnel/tunnel.go
Outdated
|
||
exists, conflict, _, err := t.router.Inspect(t.status.TunnelID.Route) | ||
if err != nil { | ||
t.status.RouteError = fmt.Errorf("error checking for route state: %s", err) |
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.
Can this call return now? That would help to de-indent the non-error flow.
Same elsewhere in this function. https://github.com/golang/go/wiki/CodeReviewComments#indent-error-flow
|
||
func NewManager() *Manager { | ||
return &Manager{ | ||
delay: 5 * time.Second, |
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.
Move this magic number to a const so that it's self-documenting.
Approved with minor nitpicks. Thanks! |
Looking forward to giving this a spin, thanks for the hard work here! |
This looks very interesting and I am keen to give it a crack, any chance this could be cut into a release? |
An implementation of
minikube tunnel
based on #2413.