Merge pull request #38119 from liggitt/long-running
Automatic merge from submit-queue (batch tested with PRs 37032, 38119, 38186, 38200, 38139) Detect long-running requests from parsed request info Follow up to https://github.com/kubernetes/kubernetes/pull/36064 Uses parsed request info to more tightly match verbs and subresources Removes regex-based long-running request path matching (which is easily fooled) ```release-note The --long-running-request-regexp flag to kube-apiserver is deprecated and will be removed in a future release. Long-running requests are now detected based on specific verbs (watch, proxy) or subresources (proxy, portforward, log, exec, attach). ```
This commit is contained in:
@@ -22,7 +22,6 @@ import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -37,47 +36,6 @@ import (
|
||||
"k8s.io/kubernetes/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
func TestLongRunningRequestRegexp(t *testing.T) {
|
||||
regexp := regexp.MustCompile(options.NewServerRunOptions().GenericServerRunOptions.LongRunningRequestRE)
|
||||
dontMatch := []string{
|
||||
"/api/v1/watch-namespace/",
|
||||
"/api/v1/namespace-proxy/",
|
||||
"/api/v1/namespace-watch",
|
||||
"/api/v1/namespace-proxy",
|
||||
"/api/v1/namespace-portforward/pods",
|
||||
"/api/v1/portforward/pods",
|
||||
". anything",
|
||||
"/ that",
|
||||
}
|
||||
doMatch := []string{
|
||||
"/api/v1/pods/watch",
|
||||
"/api/v1/watch/stuff",
|
||||
"/api/v1/default/service/proxy",
|
||||
"/api/v1/pods/proxy/path/to/thing",
|
||||
"/api/v1/namespaces/myns/pods/mypod/log",
|
||||
"/api/v1/namespaces/myns/pods/mypod/logs",
|
||||
"/api/v1/namespaces/myns/pods/mypod/portforward",
|
||||
"/api/v1/namespaces/myns/pods/mypod/exec",
|
||||
"/api/v1/namespaces/myns/pods/mypod/attach",
|
||||
"/api/v1/namespaces/myns/pods/mypod/log/",
|
||||
"/api/v1/namespaces/myns/pods/mypod/logs/",
|
||||
"/api/v1/namespaces/myns/pods/mypod/portforward/",
|
||||
"/api/v1/namespaces/myns/pods/mypod/exec/",
|
||||
"/api/v1/namespaces/myns/pods/mypod/attach/",
|
||||
"/api/v1/watch/namespaces/myns/pods",
|
||||
}
|
||||
for _, path := range dontMatch {
|
||||
if regexp.MatchString(path) {
|
||||
t.Errorf("path should not have match regexp but did: %s", path)
|
||||
}
|
||||
}
|
||||
for _, path := range doMatch {
|
||||
if !regexp.MatchString(path) {
|
||||
t.Errorf("path should have match regexp did not: %s", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var securePort = 6443 + 2
|
||||
var insecurePort = 8080 + 2
|
||||
var serverIP = fmt.Sprintf("http://localhost:%v", insecurePort)
|
||||
|
Reference in New Issue
Block a user