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
4c8e9de2
Commit
4c8e9de2
authored
Aug 15, 2018
by
David Eads
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow failed discovery on initial quota controller start
parent
6a12a280
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
7 deletions
+22
-7
resource_quota_controller.go
pkg/controller/resourcequota/resource_quota_controller.go
+22
-7
No files found.
pkg/controller/resourcequota/resource_quota_controller.go
View file @
4c8e9de2
...
@@ -161,11 +161,14 @@ func NewResourceQuotaController(options *ResourceQuotaControllerOptions) (*Resou
...
@@ -161,11 +161,14 @@ func NewResourceQuotaController(options *ResourceQuotaControllerOptions) (*Resou
rq
.
quotaMonitor
=
qm
rq
.
quotaMonitor
=
qm
// do initial quota monitor setup
// do initial quota monitor setup
. If we have a discovery failure here, it's ok. We'll discover more resources when a later sync happens.
resources
,
err
:=
GetQuotableResources
(
options
.
DiscoveryFunc
)
resources
,
err
:=
GetQuotableResources
(
options
.
DiscoveryFunc
)
if
err
!=
nil
{
if
discovery
.
IsGroupDiscoveryFailedError
(
err
)
{
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"initial discovery check failure, continuing and counting on future sync update: %v"
,
err
))
}
else
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
if
err
=
qm
.
SyncMonitors
(
resources
);
err
!=
nil
{
if
err
=
qm
.
SyncMonitors
(
resources
);
err
!=
nil
{
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"initial monitor sync has error: %v"
,
err
))
utilruntime
.
HandleError
(
fmt
.
Errorf
(
"initial monitor sync has error: %v"
,
err
))
}
}
...
@@ -425,7 +428,16 @@ func (rq *ResourceQuotaController) Sync(discoveryFunc NamespacedResourcesFunc, p
...
@@ -425,7 +428,16 @@ func (rq *ResourceQuotaController) Sync(discoveryFunc NamespacedResourcesFunc, p
newResources
,
err
:=
GetQuotableResources
(
discoveryFunc
)
newResources
,
err
:=
GetQuotableResources
(
discoveryFunc
)
if
err
!=
nil
{
if
err
!=
nil
{
utilruntime
.
HandleError
(
err
)
utilruntime
.
HandleError
(
err
)
return
if
discovery
.
IsGroupDiscoveryFailedError
(
err
)
&&
len
(
newResources
)
>
0
{
// In partial discovery cases, don't remove any existing informers, just add new ones
for
k
,
v
:=
range
oldResources
{
newResources
[
k
]
=
v
}
}
else
{
// short circuit in non-discovery error cases or if discovery returned zero resources
return
}
}
}
// Decide whether discovery has reported a change.
// Decide whether discovery has reported a change.
...
@@ -470,15 +482,18 @@ func (rq *ResourceQuotaController) resyncMonitors(resources map[schema.GroupVers
...
@@ -470,15 +482,18 @@ func (rq *ResourceQuotaController) resyncMonitors(resources map[schema.GroupVers
// GetQuotableResources returns all resources that the quota system should recognize.
// GetQuotableResources returns all resources that the quota system should recognize.
// It requires a resource supports the following verbs: 'create','list','delete'
// It requires a resource supports the following verbs: 'create','list','delete'
// This function may return both results and an error. If that happens, it means that the discovery calls were only
// partially successful. A decision about whether to proceed or not is left to the caller.
func
GetQuotableResources
(
discoveryFunc
NamespacedResourcesFunc
)
(
map
[
schema
.
GroupVersionResource
]
struct
{},
error
)
{
func
GetQuotableResources
(
discoveryFunc
NamespacedResourcesFunc
)
(
map
[
schema
.
GroupVersionResource
]
struct
{},
error
)
{
possibleResources
,
e
rr
:=
discoveryFunc
()
possibleResources
,
discoveryE
rr
:=
discoveryFunc
()
if
err
!=
nil
{
if
discoveryErr
!=
nil
&&
len
(
possibleResources
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"failed to discover resources: %v"
,
e
rr
)
return
nil
,
fmt
.
Errorf
(
"failed to discover resources: %v"
,
discoveryE
rr
)
}
}
quotableResources
:=
discovery
.
FilteredBy
(
discovery
.
SupportsAllVerbs
{
Verbs
:
[]
string
{
"create"
,
"list"
,
"watch"
,
"delete"
}},
possibleResources
)
quotableResources
:=
discovery
.
FilteredBy
(
discovery
.
SupportsAllVerbs
{
Verbs
:
[]
string
{
"create"
,
"list"
,
"watch"
,
"delete"
}},
possibleResources
)
quotableGroupVersionResources
,
err
:=
discovery
.
GroupVersionResources
(
quotableResources
)
quotableGroupVersionResources
,
err
:=
discovery
.
GroupVersionResources
(
quotableResources
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed to parse resources: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"Failed to parse resources: %v"
,
err
)
}
}
return
quotableGroupVersionResources
,
nil
// return the original discovery error (if any) in addition to the list
return
quotableGroupVersionResources
,
discoveryErr
}
}
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