Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
76acfd4b
Commit
76acfd4b
authored
Mar 22, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #22916 from liggitt/namespace-subresources
Auto commit by PR queue bot
parents
7e8a8985
ad20045c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
handlers.go
pkg/apiserver/handlers.go
+8
-1
handlers_test.go
pkg/apiserver/handlers_test.go
+2
-1
master_test.go
pkg/master/master_test.go
+22
-0
No files found.
pkg/apiserver/handlers.go
View file @
76acfd4b
...
@@ -45,6 +45,13 @@ var specialVerbs = sets.NewString("proxy", "redirect", "watch")
...
@@ -45,6 +45,13 @@ var specialVerbs = sets.NewString("proxy", "redirect", "watch")
// specialVerbsNoSubresources contains root verbs which do not allow subresources
// specialVerbsNoSubresources contains root verbs which do not allow subresources
var
specialVerbsNoSubresources
=
sets
.
NewString
(
"proxy"
,
"redirect"
)
var
specialVerbsNoSubresources
=
sets
.
NewString
(
"proxy"
,
"redirect"
)
// namespaceSubresources contains subresources of namespace
// this list allows the parser to distinguish between a namespace subresource, and a namespaced resource
var
namespaceSubresources
=
sets
.
NewString
(
"status"
,
"finalize"
)
// NamespaceSubResourcesForTest exports namespaceSubresources for testing in pkg/master/master_test.go, so we never drift
var
NamespaceSubResourcesForTest
=
sets
.
NewString
(
namespaceSubresources
.
List
()
...
)
// Constant for the retry-after interval on rate limiting.
// Constant for the retry-after interval on rate limiting.
// TODO: maybe make this dynamic? or user-adjustable?
// TODO: maybe make this dynamic? or user-adjustable?
const
RetryAfter
=
"1"
const
RetryAfter
=
"1"
...
@@ -549,7 +556,7 @@ func (r *RequestInfoResolver) GetRequestInfo(req *http.Request) (RequestInfo, er
...
@@ -549,7 +556,7 @@ func (r *RequestInfoResolver) GetRequestInfo(req *http.Request) (RequestInfo, er
// if there is another step after the namespace name and it is not a known namespace subresource
// if there is another step after the namespace name and it is not a known namespace subresource
// move currentParts to include it as a resource in its own right
// move currentParts to include it as a resource in its own right
if
len
(
currentParts
)
>
2
{
if
len
(
currentParts
)
>
2
&&
!
namespaceSubresources
.
Has
(
currentParts
[
2
])
{
currentParts
=
currentParts
[
2
:
]
currentParts
=
currentParts
[
2
:
]
}
}
}
}
...
...
pkg/apiserver/handlers_test.go
View file @
76acfd4b
...
@@ -358,7 +358,8 @@ func TestGetAPIRequestInfo(t *testing.T) {
...
@@ -358,7 +358,8 @@ func TestGetAPIRequestInfo(t *testing.T) {
// subresource identification
// subresource identification
{
"GET"
,
"/api/v1/namespaces/other/pods/foo/status"
,
"get"
,
"api"
,
""
,
"v1"
,
"other"
,
"pods"
,
"status"
,
"foo"
,
[]
string
{
"pods"
,
"foo"
,
"status"
}},
{
"GET"
,
"/api/v1/namespaces/other/pods/foo/status"
,
"get"
,
"api"
,
""
,
"v1"
,
"other"
,
"pods"
,
"status"
,
"foo"
,
[]
string
{
"pods"
,
"foo"
,
"status"
}},
{
"GET"
,
"/api/v1/namespaces/other/pods/foo/proxy/subpath"
,
"get"
,
"api"
,
""
,
"v1"
,
"other"
,
"pods"
,
"proxy"
,
"foo"
,
[]
string
{
"pods"
,
"foo"
,
"proxy"
,
"subpath"
}},
{
"GET"
,
"/api/v1/namespaces/other/pods/foo/proxy/subpath"
,
"get"
,
"api"
,
""
,
"v1"
,
"other"
,
"pods"
,
"proxy"
,
"foo"
,
[]
string
{
"pods"
,
"foo"
,
"proxy"
,
"subpath"
}},
{
"PUT"
,
"/api/v1/namespaces/other/finalize"
,
"update"
,
"api"
,
""
,
"v1"
,
"other"
,
"finalize"
,
""
,
""
,
[]
string
{
"finalize"
}},
{
"PUT"
,
"/api/v1/namespaces/other/finalize"
,
"update"
,
"api"
,
""
,
"v1"
,
"other"
,
"namespaces"
,
"finalize"
,
"other"
,
[]
string
{
"namespaces"
,
"other"
,
"finalize"
}},
{
"PUT"
,
"/api/v1/namespaces/other/status"
,
"update"
,
"api"
,
""
,
"v1"
,
"other"
,
"namespaces"
,
"status"
,
"other"
,
[]
string
{
"namespaces"
,
"other"
,
"status"
}},
// verb identification
// verb identification
{
"PATCH"
,
"/api/v1/namespaces/other/pods/foo"
,
"patch"
,
"api"
,
""
,
"v1"
,
"other"
,
"pods"
,
""
,
"foo"
,
[]
string
{
"pods"
,
"foo"
}},
{
"PATCH"
,
"/api/v1/namespaces/other/pods/foo"
,
"patch"
,
"api"
,
""
,
"v1"
,
"other"
,
"pods"
,
""
,
"foo"
,
[]
string
{
"pods"
,
"foo"
}},
...
...
pkg/master/master_test.go
View file @
76acfd4b
...
@@ -32,7 +32,9 @@ import (
...
@@ -32,7 +32,9 @@ import (
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/testapi"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/api/unversioned"
"k8s.io/kubernetes/pkg/apiserver"
utilnet
"k8s.io/kubernetes/pkg/util/net"
utilnet
"k8s.io/kubernetes/pkg/util/net"
"k8s.io/kubernetes/pkg/util/sets"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/autoscaling"
"k8s.io/kubernetes/pkg/apis/batch"
"k8s.io/kubernetes/pkg/apis/batch"
...
@@ -132,6 +134,26 @@ func TestNew(t *testing.T) {
...
@@ -132,6 +134,26 @@ func TestNew(t *testing.T) {
assert
.
Equal
(
master
.
ProxyTransport
.
(
*
http
.
Transport
)
.
TLSClientConfig
,
config
.
ProxyTLSClientConfig
)
assert
.
Equal
(
master
.
ProxyTransport
.
(
*
http
.
Transport
)
.
TLSClientConfig
,
config
.
ProxyTLSClientConfig
)
}
}
// TestNamespaceSubresources ensures the namespace subresource parsing in apiserver/handlers.go doesn't drift
func
TestNamespaceSubresources
(
t
*
testing
.
T
)
{
master
,
etcdserver
,
_
,
_
:=
newMaster
(
t
)
defer
etcdserver
.
Terminate
(
t
)
expectedSubresources
:=
apiserver
.
NamespaceSubResourcesForTest
foundSubresources
:=
sets
.
NewString
()
for
k
:=
range
master
.
v1ResourcesStorage
{
parts
:=
strings
.
Split
(
k
,
"/"
)
if
len
(
parts
)
==
2
&&
parts
[
0
]
==
"namespaces"
{
foundSubresources
.
Insert
(
parts
[
1
])
}
}
if
!
reflect
.
DeepEqual
(
expectedSubresources
.
List
(),
foundSubresources
.
List
())
{
t
.
Errorf
(
"Expected namespace subresources %#v, got %#v. Update apiserver/handlers.go#namespaceSubresources"
,
expectedSubresources
.
List
(),
foundSubresources
.
List
())
}
}
// TestGetServersToValidate verifies the unexported getServersToValidate function
// TestGetServersToValidate verifies the unexported getServersToValidate function
func
TestGetServersToValidate
(
t
*
testing
.
T
)
{
func
TestGetServersToValidate
(
t
*
testing
.
T
)
{
master
,
etcdserver
,
config
,
assert
:=
setUp
(
t
)
master
,
etcdserver
,
config
,
assert
:=
setUp
(
t
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment