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
9d3c8b36
Commit
9d3c8b36
authored
Jul 01, 2019
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apiextensions: 404 if request scope does not match crd scope
parent
f3fe4478
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
customresource_handler.go
...ensions-apiserver/pkg/apiserver/customresource_handler.go
+18
-0
No files found.
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go
View file @
9d3c8b36
...
@@ -192,6 +192,10 @@ func NewCustomResourceDefinitionHandler(
...
@@ -192,6 +192,10 @@ func NewCustomResourceDefinitionHandler(
// and on the client side (by restarting the watch)
// and on the client side (by restarting the watch)
var
longRunningFilter
=
genericfilters
.
BasicLongRunningRequestCheck
(
sets
.
NewString
(
"watch"
),
sets
.
NewString
())
var
longRunningFilter
=
genericfilters
.
BasicLongRunningRequestCheck
(
sets
.
NewString
(
"watch"
),
sets
.
NewString
())
// possiblyAcrossAllNamespacesVerbs contains those verbs which can be per-namespace and across all
// namespaces for namespaces resources. I.e. for these an empty namespace in the requestInfo is fine.
var
possiblyAcrossAllNamespacesVerbs
=
sets
.
NewString
(
"list"
,
"watch"
)
func
(
r
*
crdHandler
)
ServeHTTP
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
(
r
*
crdHandler
)
ServeHTTP
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
ctx
:=
req
.
Context
()
ctx
:=
req
.
Context
()
requestInfo
,
ok
:=
apirequest
.
RequestInfoFrom
(
ctx
)
requestInfo
,
ok
:=
apirequest
.
RequestInfoFrom
(
ctx
)
...
@@ -227,10 +231,24 @@ func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
...
@@ -227,10 +231,24 @@ func (r *crdHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
return
return
}
}
// if the scope in the CRD and the scope in request differ (with exception of the verbs in possiblyAcrossAllNamespacesVerbs
// for namespaced resources), pass request to the delegate, which is supposed to lead to a 404.
namespacedCRD
,
namespacedReq
:=
crd
.
Spec
.
Scope
==
apiextensions
.
NamespaceScoped
,
len
(
requestInfo
.
Namespace
)
>
0
if
!
namespacedCRD
&&
namespacedReq
{
r
.
delegate
.
ServeHTTP
(
w
,
req
)
return
}
if
namespacedCRD
&&
!
namespacedReq
&&
!
possiblyAcrossAllNamespacesVerbs
.
Has
(
requestInfo
.
Verb
)
{
r
.
delegate
.
ServeHTTP
(
w
,
req
)
return
}
if
!
apiextensions
.
HasServedCRDVersion
(
crd
,
requestInfo
.
APIVersion
)
{
if
!
apiextensions
.
HasServedCRDVersion
(
crd
,
requestInfo
.
APIVersion
)
{
r
.
delegate
.
ServeHTTP
(
w
,
req
)
r
.
delegate
.
ServeHTTP
(
w
,
req
)
return
return
}
}
// There is a small chance that a CRD is being served because NamesAccepted condition is true,
// There is a small chance that a CRD is being served because NamesAccepted condition is true,
// but it becomes "unserved" because another names update leads to a conflict
// but it becomes "unserved" because another names update leads to a conflict
// and EstablishingController wasn't fast enough to put the CRD into the Established condition.
// and EstablishingController wasn't fast enough to put the CRD into the Established condition.
...
...
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