-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Decouple remotecommand #41543
Conversation
@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 |
"io" | ||
|
||
"k8s.io/apimachinery/pkg/util/runtime" | ||
"k8s.io/kubernetes/pkg/util/term" |
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.
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?
pkg/util/remotecommand/constants.go
Outdated
limitations under the License. | ||
*/ | ||
|
||
package remotecommand |
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.
@dshulyak i left two comments, otherwise looks ok. |
2fce8ba
to
9e8ae5a
Compare
327f420
to
72ec16d
Compare
@caesarxuchao I addressed all issues, please take when you will have time |
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.
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, |
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.
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.
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.
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) { |
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 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?
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.
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") |
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.
Where do these two lines come from?
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.
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 { |
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.
@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 |
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.
@sttts @deads2k are you ok with moving these constants to apimachinery? @dshulyak seemed to be following @deads2k's suggestion (#41331 (comment)).
/lgtm |
/approve |
@lavalamp could you approve the change? It's a step required to support exec, attach, port-forward in client-go. Thanks. |
Thank you, @dshulyak |
@lavalamp could you approve this PR? Thanks. |
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.
Sorry, I have a few change requests. Also I think many of the commits in this PR should be squashed.
pkg/kubelet/server/server.go
Outdated
@@ -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" |
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.
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 { |
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 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. |
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.
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" |
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.
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
7b99cde
to
f50480c
Compare
/lgtm |
[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 |
Automatic merge from submit-queue (batch tested with PRs 44406, 41543, 44071, 44374, 44299) |
This PR appears to have broken the crossbuild:
|
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. |
PR testing by default only does fastbuild, i.e. only linux/amd64. |
i'm sending a fix. |
Sent #44506 |
Automatic merge from submit-queue fix cross-build Fix #41543 (comment)
Refactored unversioned/remotecommand to decouple it from undesirable dependencies: