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
0898f62b
Commit
0898f62b
authored
Sep 22, 2016
by
Dr. Stefan Schimanski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add locking around apiGroupsForDiscovery
parent
430b897f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
genericapiserver.go
pkg/genericapiserver/genericapiserver.go
+11
-1
No files found.
pkg/genericapiserver/genericapiserver.go
View file @
0898f62b
...
@@ -152,7 +152,8 @@ type GenericAPIServer struct {
...
@@ -152,7 +152,8 @@ type GenericAPIServer struct {
// Map storing information about all groups to be exposed in discovery response.
// Map storing information about all groups to be exposed in discovery response.
// The map is from name to the group.
// The map is from name to the group.
apiGroupsForDiscovery
map
[
string
]
unversioned
.
APIGroup
apiGroupsForDiscoveryLock
sync
.
RWMutex
apiGroupsForDiscovery
map
[
string
]
unversioned
.
APIGroup
// See Config.$name for documentation of these flags
// See Config.$name for documentation of these flags
...
@@ -228,6 +229,9 @@ func (s *GenericAPIServer) InstallAPIGroups(groupsInfo []APIGroupInfo) error {
...
@@ -228,6 +229,9 @@ func (s *GenericAPIServer) InstallAPIGroups(groupsInfo []APIGroupInfo) error {
// Installs handler at /apis to list all group versions for discovery
// Installs handler at /apis to list all group versions for discovery
func
(
s
*
GenericAPIServer
)
installGroupsDiscoveryHandler
()
{
func
(
s
*
GenericAPIServer
)
installGroupsDiscoveryHandler
()
{
apiserver
.
AddApisWebService
(
s
.
Serializer
,
s
.
HandlerContainer
,
s
.
apiPrefix
,
func
(
req
*
restful
.
Request
)
[]
unversioned
.
APIGroup
{
apiserver
.
AddApisWebService
(
s
.
Serializer
,
s
.
HandlerContainer
,
s
.
apiPrefix
,
func
(
req
*
restful
.
Request
)
[]
unversioned
.
APIGroup
{
s
.
apiGroupsForDiscoveryLock
.
RLock
()
defer
s
.
apiGroupsForDiscoveryLock
.
RUnlock
()
// Return the list of supported groups in sorted order (to have a deterministic order).
// Return the list of supported groups in sorted order (to have a deterministic order).
groups
:=
[]
unversioned
.
APIGroup
{}
groups
:=
[]
unversioned
.
APIGroup
{}
groupNames
:=
make
([]
string
,
len
(
s
.
apiGroupsForDiscovery
))
groupNames
:=
make
([]
string
,
len
(
s
.
apiGroupsForDiscovery
))
...
@@ -454,10 +458,16 @@ func (s *GenericAPIServer) InstallAPIGroup(apiGroupInfo *APIGroupInfo) error {
...
@@ -454,10 +458,16 @@ func (s *GenericAPIServer) InstallAPIGroup(apiGroupInfo *APIGroupInfo) error {
}
}
func
(
s
*
GenericAPIServer
)
AddAPIGroupForDiscovery
(
apiGroup
unversioned
.
APIGroup
)
{
func
(
s
*
GenericAPIServer
)
AddAPIGroupForDiscovery
(
apiGroup
unversioned
.
APIGroup
)
{
s
.
apiGroupsForDiscoveryLock
.
Lock
()
defer
s
.
apiGroupsForDiscoveryLock
.
Unlock
()
s
.
apiGroupsForDiscovery
[
apiGroup
.
Name
]
=
apiGroup
s
.
apiGroupsForDiscovery
[
apiGroup
.
Name
]
=
apiGroup
}
}
func
(
s
*
GenericAPIServer
)
RemoveAPIGroupForDiscovery
(
groupName
string
)
{
func
(
s
*
GenericAPIServer
)
RemoveAPIGroupForDiscovery
(
groupName
string
)
{
s
.
apiGroupsForDiscoveryLock
.
Lock
()
defer
s
.
apiGroupsForDiscoveryLock
.
Unlock
()
delete
(
s
.
apiGroupsForDiscovery
,
groupName
)
delete
(
s
.
apiGroupsForDiscovery
,
groupName
)
}
}
...
...
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