k3s/pkg/controller
Kubernetes Submit Queue f8f67da082
Merge pull request #61201 from jennybuckley/fix-gc-empty-map
Automatic merge from submit-queue (batch tested with PRs 61284, 61119, 61201). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Prevent garbage collector from attempting to sync with 0 resources

**What this PR does / why we need it**:
As of #55259 we enabled garbagecollector.GetDeletableResources to return partial discovery results (including an empty set of discovery results).
This had the unintended consequence of allowing the garbage collector to enter a blocked state that can only be fixed by restarting.

From [this comment](https://github.com/kubernetes/kubernetes/issues/60037#issuecomment-372801088):

> 1. The Sync function periodically calls GetDeletableResources
>
> 2. According to the comment above GetDeletableResources, All discovery errors are considered temporary. Upon encountering any error, GetDeletableResources will log and return any discovered resources it was able to process (which may be none)., an error in discovery causes the discovery client to no longer discover resources in the cluster, but instead of failing and returning an error, it simply logs the error as garbagecollector.go:601] failed to discover preferred resources: %vthe server was unable to return a response in the time allotted, but may still be processing the request and returns an empty list of resources
>
> 3. The Sync function, upon recieving an empty resource list from discovery, detects that the resources have changed, and calls resyncMonitors, which calls dependencyGraphBuilder.syncMonitors with map[] as the argument as shown in the log as garbagecollector.go:189] syncing garbage collector with updated resources from discovery: map[], which sets the list of monitors to an empty list because it thinks there are no resources to monitor.
>
> 4. Lastly the Sync function calls controller.WaitForCacheSync, which calls cache.WaitForCacheSync, which will continually retry the garbagecollector.IsSynced function until it returns true, but it will always return false because len(gb.monitors) is 0.

This PR prevents that specific race condition from arising.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #60037

**Release note**:
```release-note
Fix bug allowing garbage collector to enter a broken state that could only be fixed by restarting the controller-manager.
```
2018-03-16 16:56:03 -07:00
..
bootstrap Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
certificates Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
cloud Merge pull request #59842 from ixdy/update-rules_go-02-2018 2018-02-19 22:23:05 -08:00
clusterroleaggregation Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
cronjob Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
daemon Added unscheduable taint. 2018-03-16 09:13:08 +08:00
deployment Add tests for Deployments Recreate strategy when there are pods in terminal state present 2018-02-24 14:29:56 +01:00
disruption Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
endpoint Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
garbagecollector Prevent garbage collector from attempting to sync with 0 resources 2018-03-16 11:44:09 -07:00
history Merge pull request #59365 from ayushpateria/patch-sts 2018-02-27 10:21:00 -08:00
job Backoff only when failed pod shows up 2018-03-14 11:49:13 +01:00
namespace Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
nodeipam Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
nodelifecycle Added unscheduable taint. 2018-03-16 09:13:08 +08:00
podautoscaler Do not count failed pods as unready in HPA controller 2018-03-01 16:21:02 +01:00
podgc Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
replicaset Merge pull request #59634 from WanLinghao/replica_set_unused_function_remove 2018-02-20 12:18:19 -08:00
replication Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
resourcequota Merge pull request #57302 from lichuqiang/resourceQuota4extendedResource 2018-02-20 14:10:46 -08:00
route Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
service Merge pull request #60555 from zhangxiaoyu-zidif/add-unit-test-for-nodenames-slice-comparison 2018-02-28 10:39:18 -08:00
serviceaccount implement token authenticator for new id tokens 2018-02-27 17:20:46 -08:00
statefulset Increase loging verbosity for deleting stateful set pods 2018-03-01 09:33:18 +00:00
testutil Revert "add node shutdown taint" 2018-02-16 12:24:27 +01:00
ttl Autogenerated: hack/update-bazel.sh 2018-02-16 13:43:01 -08:00
util/node Revert "add node shutdown taint" 2018-02-16 12:24:27 +01:00
volume Increase verbosity of frequently printed logline in scheduler_binder 2018-03-08 19:25:01 +01:00
.import-restrictions
BUILD generated code 2018-02-23 08:06:42 -08:00
OWNERS
client_builder.go
controller_ref_manager.go Update the DaemonSet controller to use the apps/v1 API 2018-02-22 11:38:54 -08:00
controller_ref_manager_test.go
controller_utils.go fix all the typos across the project 2018-02-11 11:04:14 +08:00
controller_utils_test.go
doc.go
lookup_cache.go