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

Decouple remotecommand #41543

Merged
merged 1 commit into from
Apr 14, 2017

Conversation

dshulyak
Copy link
Contributor

Refactored unversioned/remotecommand to decouple it from undesirable dependencies:

  • term package now is not required, and functionality required to resize terminal size can be plugged in directly in kubectl
  • in order to remove dependency on kubelet package - constants from kubelet/server/remotecommand were moved to separate util package (pkg/util/remotecommand)
  • remotecommand_test.go moved to pkg/client/tests module

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 16, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-label-needed labels Feb 16, 2017
@dshulyak
Copy link
Contributor Author

@sttts @caesarxuchao @deads2k I moved changes related to remotecommand refactoring into separate PR, perhaps it will be easier for you to review it this way

@sttts sttts added release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Feb 16, 2017
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 30, 2017
"io"

"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/kubernetes/pkg/util/term"
Copy link
Member

Choose a reason for hiding this comment

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

This way term is still depended by the package remotecommand. Can we move the definition of Size and TerminalSizeQueue to the package remotecommand to reverse the dependency direction?

limitations under the License.
*/

package remotecommand
Copy link
Member

Choose a reason for hiding this comment

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

I think you mentioned somewhere that these constants belonged to apimachinery, which I agree. pkg/util/remotecommand/constants.go seems the wrong place. cc @sttts @lavalamp

@caesarxuchao caesarxuchao self-assigned this Apr 4, 2017
@caesarxuchao
Copy link
Member

@dshulyak i left two comments, otherwise looks ok.

@dshulyak dshulyak force-pushed the decouple_remotecommand branch from 2fce8ba to 9e8ae5a Compare April 4, 2017 09:46
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 4, 2017
@dshulyak dshulyak force-pushed the decouple_remotecommand branch 4 times, most recently from 327f420 to 72ec16d Compare April 4, 2017 12:38
@dshulyak
Copy link
Contributor Author

dshulyak commented Apr 5, 2017

@caesarxuchao I addressed all issues, please take when you will have time

Copy link
Member

@caesarxuchao caesarxuchao left a comment

Choose a reason for hiding this comment

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

Generally looks good. A few nits.

@@ -221,7 +221,7 @@ func TestStream(t *testing.T) {
url, _ := url.ParseRequestURI(server.URL)
config := restclient.ContentConfig{
GroupVersion: &schema.GroupVersion{Group: "x"},
NegotiatedSerializer: testapi.Default.NegotiatedSerializer(),
NegotiatedSerializer: api.Codecs,
Copy link
Member

Choose a reason for hiding this comment

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

Why is this change necessary?

I know testapi is a mess, but api.Codecs is a global variable we want to get rid of, every new use of it increases our tech debt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cant recally why i had to change it, will revert

}

// GetResizeFunc will return function that handles terminal resize
func GetResizeFunc(resizeQueue TerminalSizeQueue) func(io.Writer) {
Copy link
Member

Choose a reason for hiding this comment

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

It looks unnecessary to abstract the anonymous func to the GetResizeFunc. Actually I found the original code to be easier to read. Could you revert this part?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah right, it was needed when resize was separate package and TerminalSizeQueue was a part of term package

@@ -41,6 +45,9 @@ const (
// attachment/execution. It is the 4th version of the subprotocol and
// adds support for exit codes.
StreamProtocolV4Name = "v4.channel.k8s.io"

NonZeroExitCodeReason = metav1.StatusReason("NonZeroExitCode")
ExitCodeCauseType = metav1.CauseType("ExitCode")
Copy link
Member

Choose a reason for hiding this comment

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

Where do these two lines come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

they were defined in pkg/kubelet/server/remotecommand/exec.go. I had to move them as well cause they are used by client/remotecommand

)

// Size represents the width and height of a terminal.
type Size struct {
Copy link
Member

Choose a reason for hiding this comment

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

@sttts are you ok with moving definition of Size and TerminalSizeQueue to client-go/tool/remotecommand? We did the move to break the dependency on pkg/util/terms.

"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
DefaultStreamCreationTimeout = 30 * time.Second
Copy link
Member

Choose a reason for hiding this comment

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

@sttts @deads2k are you ok with moving these constants to apimachinery? @dshulyak seemed to be following @deads2k's suggestion (#41331 (comment)).

@caesarxuchao
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 6, 2017
@caesarxuchao
Copy link
Member

/approve

@caesarxuchao
Copy link
Member

@lavalamp could you approve the change? It's a step required to support exec, attach, port-forward in client-go. Thanks.

@caesarxuchao
Copy link
Member

Thank you, @dshulyak

@caesarxuchao
Copy link
Member

@lavalamp could you approve this PR? Thanks.

Copy link
Member

@lavalamp lavalamp left a comment

Choose a reason for hiding this comment

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

Sorry, I have a few change requests. Also I think many of the commits in this PR should be squashed.

@@ -41,6 +41,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
consts "k8s.io/apimachinery/pkg/util/remotecommand"
Copy link
Member

Choose a reason for hiding this comment

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

Don't call this "consts", it's very confusing. (Maybe make a remotecommand/consts package if you really want to, but I don't think that's necessary.)

Multiple places.

package remotecommand

// Size represents the width and height of a terminal.
type Size struct {
Copy link
Member

Choose a reason for hiding this comment

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

If you move this out of the term package, you need to change the name to TerminalSize, and probably explain why it's needed in the comment.

@@ -1,5 +1,5 @@
/*
Copyright 2016 The Kubernetes Authors.
Copyright 2017 The Kubernetes Authors.
Copy link
Member

Choose a reason for hiding this comment

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

Do not change years in headers.

"k8s.io/kubernetes/pkg/kubelet/cm"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/server/portforward"
"k8s.io/kubernetes/pkg/kubelet/server/remotecommand"
remotecommandserver "k8s.io/kubernetes/pkg/kubelet/server/remotecommand"
Copy link
Member

Choose a reason for hiding this comment

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

I guess I would have expected remotecommand/server, remotecommand/client, and maybe remotecommand/consts (or /public), none of those being under the kubelet package. Not asking for a change in this PR, just noting.

In order to move client/unversioned/remotecommand to client-go as a followup
for this change we have to decouple it from tons of dependencies
@dshulyak dshulyak force-pushed the decouple_remotecommand branch from 7b99cde to f50480c Compare April 13, 2017 12:58
@k8s-github-robot k8s-github-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 13, 2017
@lavalamp
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 13, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: caesarxuchao, dshulyak, lavalamp

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 13, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 44406, 41543, 44071, 44374, 44299)

@k8s-github-robot k8s-github-robot merged commit 4653a9b into kubernetes:master Apr 14, 2017
@ixdy
Copy link
Member

ixdy commented Apr 14, 2017

This PR appears to have broken the crossbuild:

I0414 11:07:29.245] # k8s.io/kubernetes/pkg/util/term
I0414 11:07:29.245] pkg/util/term/resizeevents_windows.go:28: undefined: Size
I0414 11:07:29.245] pkg/util/term/setsize_unsupported.go:21: undefined: Size

@caesarxuchao
Copy link
Member

That definition of Size has been moved to :https://github.com/kubernetes/kubernetes/pull/41543/files#diff-a730f0242b04da050b4932246123ae45R23.

It's interesting why this PR passes CI. It looks like https://github.com/kubernetes/kubernetes/blob/master/pkg/util/term/resizeevents_windows.go#L28 should always fail to compile.

@ixdy
Copy link
Member

ixdy commented Apr 14, 2017

PR testing by default only does fastbuild, i.e. only linux/amd64.

@caesarxuchao
Copy link
Member

i'm sending a fix.

@caesarxuchao caesarxuchao mentioned this pull request Apr 14, 2017
@caesarxuchao
Copy link
Member

Sent #44506

k8s-github-robot pushed a commit that referenced this pull request Apr 14, 2017
Automatic merge from submit-queue

fix cross-build

Fix #41543 (comment)
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. 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.

8 participants