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

port-forward should be able to select ports by service name #5009

Merged
merged 4 commits into from
Nov 19, 2020

Conversation

anshlykov
Copy link
Contributor

@anshlykov anshlykov commented Nov 8, 2020

Fixes: #4464
Merge after: #5010

Description

This PR introduced the new type IntOrString and changed the type of PortForwardResource.Port to IntOrString. This change allows a named port or an int port to be used in the kubectl port-forward ... command.

Also, there are some breaking changes in the proto schema and changes in logging. I think this can be simply resolved but I have not done it yet because I want to validate my approach first (or maybe it is already OK)

@codecov
Copy link

codecov bot commented Nov 8, 2020

Codecov Report

Merging #5009 (57ce2f9) into master (8caebb9) will increase coverage by 0.06%.
The diff coverage is 90.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5009      +/-   ##
==========================================
+ Coverage   72.17%   72.24%   +0.06%     
==========================================
  Files         365      366       +1     
  Lines       12807    12885      +78     
==========================================
+ Hits         9244     9309      +65     
- Misses       2878     2885       +7     
- Partials      685      691       +6     
Impacted Files Coverage Δ
...kubernetes/portforward/port_forward_integration.go 0.00% <0.00%> (ø)
pkg/skaffold/schema/latest/config.go 100.00% <ø> (ø)
pkg/skaffold/schema/v2beta9/upgrade.go 100.00% <ø> (ø)
...affold/kubernetes/portforward/kubectl_forwarder.go 67.60% <84.61%> (+1.18%) ⬆️
pkg/skaffold/schema/util/int_string.go 87.09% <87.09%> (ø)
pkg/skaffold/event/event.go 91.88% <100.00%> (+0.11%) ⬆️
...g/skaffold/kubernetes/portforward/entry_manager.go 92.00% <100.00%> (ø)
...g/skaffold/kubernetes/portforward/pod_forwarder.go 82.00% <100.00%> (ø)
...ffold/kubernetes/portforward/port_forward_entry.go 100.00% <100.00%> (ø)
...ffold/kubernetes/portforward/resource_forwarder.go 86.00% <100.00%> (ø)
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8caebb9...57ce2f9. Read the comment docs.

Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

This change looks good to me except for the change in the skaffold.proto.
we have existing clients who use this event and changing int to StringOrInt may be break integration.

I will follow up with manually testing the new skaffold event on the CC IDEs side.

Meanwhile, can you instead use a new field and deprecate the existing field.

@@ -190,7 +190,7 @@ message ResourceStatusCheckEvent {
// PortEvent Event describes each port forwarding event.
message PortEvent {
int32 localPort = 1; // local port for forwarded resource
int32 remotePort = 2; // remote port is the resource port that will be forwarded.
IntOrString remotePort = 2; // remote port is the resource port that will be forwarded.
Copy link
Contributor

Choose a reason for hiding this comment

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

unfortunately, this will be a backward incompatible change. Can we instead add a another field and mark this as deprecated.

handler.handle(&proto.Event{
EventType: &proto.Event_PortEvent{
PortEvent: &proto.PortEvent{
RemotePort: &proto.IntOrString{
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep remote port as is if its of type int and use new field to populate the intOrString port value.

@tejal29
Copy link
Contributor

tejal29 commented Nov 12, 2020

@anshlykov Can you please rebase ? Would love to get this in before next release since we already merged the PR to upgrade skaffold config.

@tejal29 tejal29 marked this pull request as ready for review November 12, 2020 18:11
@tejal29 tejal29 requested a review from a team as a code owner November 12, 2020 18:11
@tejal29 tejal29 requested a review from briandealwis November 12, 2020 18:11
@anshlykov
Copy link
Contributor Author

I have rebased and added changes to the proto schema.

Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

LGTM.

Pending Manual verification.

@tejal29 tejal29 added the kokoro:run runs the kokoro jobs on a PR label Nov 13, 2020
@kokoro-team kokoro-team removed the kokoro:run runs the kokoro jobs on a PR label Nov 13, 2020
Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

Manually verified this

  1. Integration test sample

@tejal29 tejal29 merged commit 7a0b12f into GoogleContainerTools:master Nov 19, 2020
@anshlykov anshlykov deleted the gh-4464 branch November 19, 2020 21:23
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.

port-forward should be able to select ports by service name
3 participants