mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Remove version check for kubectl portfoward.
This commit is contained in:
parent
0242de0c5d
commit
eb27e1c471
@ -22,7 +22,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -36,7 +35,6 @@ import (
|
|||||||
"k8s.io/api/core/v1"
|
"k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
utilversion "k8s.io/kubernetes/pkg/util/version"
|
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
testutils "k8s.io/kubernetes/test/utils"
|
testutils "k8s.io/kubernetes/test/utils"
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
@ -51,8 +49,7 @@ const (
|
|||||||
|
|
||||||
// TODO support other ports besides 80
|
// TODO support other ports besides 80
|
||||||
var (
|
var (
|
||||||
portForwardRegexp = regexp.MustCompile("Forwarding from 127.0.0.1:([0-9]+) -> 80")
|
portForwardRegexp = regexp.MustCompile("Forwarding from 127.0.0.1:([0-9]+) -> 80")
|
||||||
portForwardPortToStdOutV = utilversion.MustParseSemantic("v1.3.0-alpha.4")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func pfPod(expectedClientData, chunks, chunkSize, chunkIntervalMillis string, bindAddress string) *v1.Pod {
|
func pfPod(expectedClientData, chunks, chunkSize, chunkIntervalMillis string, bindAddress string) *v1.Pod {
|
||||||
@ -167,25 +164,13 @@ func runPortForward(ns, podName string, port int) *portForwardCommand {
|
|||||||
// by the port-forward command. We don't want to hard code the port as we have no
|
// by the port-forward command. We don't want to hard code the port as we have no
|
||||||
// way of guaranteeing we can pick one that isn't in use, particularly on Jenkins.
|
// way of guaranteeing we can pick one that isn't in use, particularly on Jenkins.
|
||||||
framework.Logf("starting port-forward command and streaming output")
|
framework.Logf("starting port-forward command and streaming output")
|
||||||
stdout, stderr, err := framework.StartCmdAndStreamOutput(cmd)
|
portOutput, _, err := framework.StartCmdAndStreamOutput(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Failf("Failed to start port-forward command: %v", err)
|
framework.Failf("Failed to start port-forward command: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, 128)
|
buf := make([]byte, 128)
|
||||||
|
|
||||||
// After v1.3.0-alpha.4 (#17030), kubectl port-forward outputs port
|
|
||||||
// info to stdout, not stderr, so for version-skewed tests, look there
|
|
||||||
// instead.
|
|
||||||
var portOutput io.ReadCloser
|
|
||||||
if useStdOut, err := framework.KubectlVersionGTE(portForwardPortToStdOutV); err != nil {
|
|
||||||
framework.Failf("Failed to get kubectl version: %v", err)
|
|
||||||
} else if useStdOut {
|
|
||||||
portOutput = stdout
|
|
||||||
} else {
|
|
||||||
portOutput = stderr
|
|
||||||
}
|
|
||||||
|
|
||||||
var n int
|
var n int
|
||||||
framework.Logf("reading from `kubectl port-forward` command's stdout")
|
framework.Logf("reading from `kubectl port-forward` command's stdout")
|
||||||
if n, err = portOutput.Read(buf); err != nil {
|
if n, err = portOutput.Read(buf); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user