• k8s-merge-robot's avatar
    Merge pull request #27600 from caesarxuchao/rc-gc · e7e434b1
    k8s-merge-robot authored
    Automatic merge from submit-queue
    
    [GarbageCollector] Let the RC manager set/remove ControllerRef
    
    What's done:
    * RC manager sets Controller Ref when creating new pods
    * RC manager sets Controller Ref when adopting pods with matching labels but having no controller
    * RC manager clears Controller Ref when pod labels change
    * RC manager clears pods' Controller Ref when rc's selector changes
    * RC manager stops adoption/creating/deleting pods when rc's DeletionTimestamp is set
    * RC manager bumps up ObservedGeneration: The [original code](https://github.com/kubernetes/kubernetes/blob/master/pkg/controller/replication/replication_controller_utils.go#L36) will do this.
    * Integration tests:
      * verifies that changing RC's selector or Pod's Labels triggers adoption/abandoning
    * e2e tests (separated to #27151):
      * verifies GC deletes the pods created by RC if DeleteOptions.OrphanDependents=false, and orphans the pods if DeleteOptions.OrphanDependents=true.
    
    TODO:
    
    - [x] we need to be able to select Pods that have a specific ControllerRef. Then each time we sync the RC, we will iterate through all the Pods that has a controllerRef pointing the RC, event if the labels of the Pod doesn't match the selector of RC anymore. This will prevent a Pod from stuck with a stale controllerRef, which could be caused by the race between abandoner (the goroutine that removes controllerRef) and worker the goroutine that add controllerRef to pods).
    - [ ] use controllerRef instead of calling `getPodController`. This might be carried out by the control-plane team.
    - [ ] according to the controllerRef proposal (#25256): "For debugging purposes we want to add an adoptionTime annotation prefixed with kubernetes.io/ which will keep the time of last controller ownership transfer." This might be carried out by the control-plane team.
    
    cc @lavalamp @gmarek
    e7e434b1
Name
Last commit
Last update
..
daemon Loading commit data...
deployment Loading commit data...
endpoint Loading commit data...
framework Loading commit data...
garbagecollector Loading commit data...
job Loading commit data...
namespace Loading commit data...
node Loading commit data...
petset Loading commit data...
podautoscaler Loading commit data...
podgc Loading commit data...
replicaset Loading commit data...
replication Loading commit data...
resourcequota Loading commit data...
route Loading commit data...
service Loading commit data...
serviceaccount Loading commit data...
volume Loading commit data...
OWNERS Loading commit data...
controller_ref_manager.go Loading commit data...
controller_utils.go Loading commit data...
controller_utils_test.go Loading commit data...
doc.go Loading commit data...
lookup_cache.go Loading commit data...