mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 03:03:59 +00:00
RC/RS: Don't log Pod events unless some RC/RS actually cares.
This commit is contained in:
parent
01d025a7cc
commit
2c2fc9c707
@ -171,7 +171,6 @@ func (rsc *ReplicaSetController) Run(workers int, stopCh <-chan struct{}) {
|
|||||||
func (rsc *ReplicaSetController) getPodReplicaSets(pod *v1.Pod) []*extensions.ReplicaSet {
|
func (rsc *ReplicaSetController) getPodReplicaSets(pod *v1.Pod) []*extensions.ReplicaSet {
|
||||||
rss, err := rsc.rsLister.GetPodReplicaSets(pod)
|
rss, err := rsc.rsLister.GetPodReplicaSets(pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(4).Infof("No ReplicaSets found for pod %v, ReplicaSet controller will avoid syncing", pod.Name)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(rss) > 1 {
|
if len(rss) > 1 {
|
||||||
@ -208,7 +207,6 @@ func (rsc *ReplicaSetController) updateRS(old, cur interface{}) {
|
|||||||
// When a pod is created, enqueue the replica set that manages it and update its expectations.
|
// When a pod is created, enqueue the replica set that manages it and update its expectations.
|
||||||
func (rsc *ReplicaSetController) addPod(obj interface{}) {
|
func (rsc *ReplicaSetController) addPod(obj interface{}) {
|
||||||
pod := obj.(*v1.Pod)
|
pod := obj.(*v1.Pod)
|
||||||
glog.V(4).Infof("Pod %s created: %#v.", pod.Name, pod)
|
|
||||||
|
|
||||||
if pod.DeletionTimestamp != nil {
|
if pod.DeletionTimestamp != nil {
|
||||||
// on a restart of the controller manager, it's possible a new pod shows up in a state that
|
// on a restart of the controller manager, it's possible a new pod shows up in a state that
|
||||||
@ -223,6 +221,7 @@ func (rsc *ReplicaSetController) addPod(obj interface{}) {
|
|||||||
// It's controlled by a different type of controller.
|
// It's controlled by a different type of controller.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
glog.V(4).Infof("Pod %s created: %#v.", pod.Name, pod)
|
||||||
rs, err := rsc.rsLister.ReplicaSets(pod.Namespace).Get(controllerRef.Name)
|
rs, err := rsc.rsLister.ReplicaSets(pod.Namespace).Get(controllerRef.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -240,7 +239,12 @@ func (rsc *ReplicaSetController) addPod(obj interface{}) {
|
|||||||
// them to see if anyone wants to adopt it.
|
// them to see if anyone wants to adopt it.
|
||||||
// DO NOT observe creation because no controller should be waiting for an
|
// DO NOT observe creation because no controller should be waiting for an
|
||||||
// orphan.
|
// orphan.
|
||||||
for _, rs := range rsc.getPodReplicaSets(pod) {
|
rss := rsc.getPodReplicaSets(pod)
|
||||||
|
if len(rss) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
glog.V(4).Infof("Orphan Pod %s created: %#v.", pod.Name, pod)
|
||||||
|
for _, rs := range rss {
|
||||||
rsc.enqueueReplicaSet(rs)
|
rsc.enqueueReplicaSet(rs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,7 +260,6 @@ func (rsc *ReplicaSetController) updatePod(old, cur interface{}) {
|
|||||||
// Two different versions of the same pod will always have different RVs.
|
// Two different versions of the same pod will always have different RVs.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
glog.V(4).Infof("Pod %s updated, objectMeta %+v -> %+v.", curPod.Name, oldPod.ObjectMeta, curPod.ObjectMeta)
|
|
||||||
|
|
||||||
labelChanged := !reflect.DeepEqual(curPod.Labels, oldPod.Labels)
|
labelChanged := !reflect.DeepEqual(curPod.Labels, oldPod.Labels)
|
||||||
if curPod.DeletionTimestamp != nil {
|
if curPod.DeletionTimestamp != nil {
|
||||||
@ -291,6 +294,7 @@ func (rsc *ReplicaSetController) updatePod(old, cur interface{}) {
|
|||||||
// It's controlled by a different type of controller.
|
// It's controlled by a different type of controller.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
glog.V(4).Infof("Pod %s updated, objectMeta %+v -> %+v.", curPod.Name, oldPod.ObjectMeta, curPod.ObjectMeta)
|
||||||
rs, err := rsc.rsLister.ReplicaSets(curPod.Namespace).Get(curControllerRef.Name)
|
rs, err := rsc.rsLister.ReplicaSets(curPod.Namespace).Get(curControllerRef.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -313,7 +317,12 @@ func (rsc *ReplicaSetController) updatePod(old, cur interface{}) {
|
|||||||
// Otherwise, it's an orphan. If anything changed, sync matching controllers
|
// Otherwise, it's an orphan. If anything changed, sync matching controllers
|
||||||
// to see if anyone wants to adopt it now.
|
// to see if anyone wants to adopt it now.
|
||||||
if labelChanged || controllerRefChanged {
|
if labelChanged || controllerRefChanged {
|
||||||
for _, rs := range rsc.getPodReplicaSets(curPod) {
|
rss := rsc.getPodReplicaSets(curPod)
|
||||||
|
if len(rss) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
glog.V(4).Infof("Orphan Pod %s updated, objectMeta %+v -> %+v.", curPod.Name, oldPod.ObjectMeta, curPod.ObjectMeta)
|
||||||
|
for _, rs := range rss {
|
||||||
rsc.enqueueReplicaSet(rs)
|
rsc.enqueueReplicaSet(rs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -340,7 +349,6 @@ func (rsc *ReplicaSetController) deletePod(obj interface{}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glog.V(4).Infof("Pod %s/%s deleted through %v, timestamp %+v: %#v.", pod.Namespace, pod.Name, utilruntime.GetCaller(), pod.DeletionTimestamp, pod)
|
|
||||||
|
|
||||||
controllerRef := controller.GetControllerOf(pod)
|
controllerRef := controller.GetControllerOf(pod)
|
||||||
if controllerRef == nil {
|
if controllerRef == nil {
|
||||||
@ -351,6 +359,7 @@ func (rsc *ReplicaSetController) deletePod(obj interface{}) {
|
|||||||
// It's controlled by a different type of controller.
|
// It's controlled by a different type of controller.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
glog.V(4).Infof("Pod %s/%s deleted through %v, timestamp %+v: %#v.", pod.Namespace, pod.Name, utilruntime.GetCaller(), pod.DeletionTimestamp, pod)
|
||||||
|
|
||||||
rs, err := rsc.rsLister.ReplicaSets(pod.Namespace).Get(controllerRef.Name)
|
rs, err := rsc.rsLister.ReplicaSets(pod.Namespace).Get(controllerRef.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -166,7 +166,6 @@ func (rm *ReplicationManager) Run(workers int, stopCh <-chan struct{}) {
|
|||||||
func (rm *ReplicationManager) getPodControllers(pod *v1.Pod) []*v1.ReplicationController {
|
func (rm *ReplicationManager) getPodControllers(pod *v1.Pod) []*v1.ReplicationController {
|
||||||
rcs, err := rm.rcLister.GetPodControllers(pod)
|
rcs, err := rm.rcLister.GetPodControllers(pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(4).Infof("No ReplicationControllers found for pod %v, controller will avoid syncing", pod.Name)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if len(rcs) > 1 {
|
if len(rcs) > 1 {
|
||||||
@ -207,7 +206,6 @@ func (rm *ReplicationManager) updateRC(old, cur interface{}) {
|
|||||||
// When a pod is created, enqueue the ReplicationController that manages it and update its expectations.
|
// When a pod is created, enqueue the ReplicationController that manages it and update its expectations.
|
||||||
func (rm *ReplicationManager) addPod(obj interface{}) {
|
func (rm *ReplicationManager) addPod(obj interface{}) {
|
||||||
pod := obj.(*v1.Pod)
|
pod := obj.(*v1.Pod)
|
||||||
glog.V(4).Infof("Pod %s created: %#v.", pod.Name, pod)
|
|
||||||
|
|
||||||
if pod.DeletionTimestamp != nil {
|
if pod.DeletionTimestamp != nil {
|
||||||
// on a restart of the controller manager, it's possible a new pod shows up in a state that
|
// on a restart of the controller manager, it's possible a new pod shows up in a state that
|
||||||
@ -222,6 +220,7 @@ func (rm *ReplicationManager) addPod(obj interface{}) {
|
|||||||
// It's controlled by a different type of controller.
|
// It's controlled by a different type of controller.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
glog.V(4).Infof("Pod %s created: %#v.", pod.Name, pod)
|
||||||
rc, err := rm.rcLister.ReplicationControllers(pod.Namespace).Get(controllerRef.Name)
|
rc, err := rm.rcLister.ReplicationControllers(pod.Namespace).Get(controllerRef.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -239,7 +238,12 @@ func (rm *ReplicationManager) addPod(obj interface{}) {
|
|||||||
// them to see if anyone wants to adopt it.
|
// them to see if anyone wants to adopt it.
|
||||||
// DO NOT observe creation because no controller should be waiting for an
|
// DO NOT observe creation because no controller should be waiting for an
|
||||||
// orphan.
|
// orphan.
|
||||||
for _, rc := range rm.getPodControllers(pod) {
|
rcs := rm.getPodControllers(pod)
|
||||||
|
if len(rcs) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
glog.V(4).Infof("Orphan Pod %s created: %#v.", pod.Name, pod)
|
||||||
|
for _, rc := range rcs {
|
||||||
rm.enqueueController(rc)
|
rm.enqueueController(rc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,7 +259,6 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
|
|||||||
// Two different versions of the same pod will always have different RVs.
|
// Two different versions of the same pod will always have different RVs.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
glog.V(4).Infof("Pod %s updated, objectMeta %+v -> %+v.", curPod.Name, oldPod.ObjectMeta, curPod.ObjectMeta)
|
|
||||||
|
|
||||||
labelChanged := !reflect.DeepEqual(curPod.Labels, oldPod.Labels)
|
labelChanged := !reflect.DeepEqual(curPod.Labels, oldPod.Labels)
|
||||||
if curPod.DeletionTimestamp != nil {
|
if curPod.DeletionTimestamp != nil {
|
||||||
@ -290,6 +293,7 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
|
|||||||
// It's controlled by a different type of controller.
|
// It's controlled by a different type of controller.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
glog.V(4).Infof("Pod %s updated, objectMeta %+v -> %+v.", curPod.Name, oldPod.ObjectMeta, curPod.ObjectMeta)
|
||||||
rc, err := rm.rcLister.ReplicationControllers(curPod.Namespace).Get(curControllerRef.Name)
|
rc, err := rm.rcLister.ReplicationControllers(curPod.Namespace).Get(curControllerRef.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -312,7 +316,12 @@ func (rm *ReplicationManager) updatePod(old, cur interface{}) {
|
|||||||
// Otherwise, it's an orphan. If anything changed, sync matching controllers
|
// Otherwise, it's an orphan. If anything changed, sync matching controllers
|
||||||
// to see if anyone wants to adopt it now.
|
// to see if anyone wants to adopt it now.
|
||||||
if labelChanged || controllerRefChanged {
|
if labelChanged || controllerRefChanged {
|
||||||
for _, rc := range rm.getPodControllers(curPod) {
|
rcs := rm.getPodControllers(curPod)
|
||||||
|
if len(rcs) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
glog.V(4).Infof("Orphan Pod %s updated, objectMeta %+v -> %+v.", curPod.Name, oldPod.ObjectMeta, curPod.ObjectMeta)
|
||||||
|
for _, rc := range rcs {
|
||||||
rm.enqueueController(rc)
|
rm.enqueueController(rc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,7 +348,6 @@ func (rm *ReplicationManager) deletePod(obj interface{}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glog.V(4).Infof("Pod %s/%s deleted through %v, timestamp %+v: %#v.", pod.Namespace, pod.Name, utilruntime.GetCaller(), pod.DeletionTimestamp, pod)
|
|
||||||
|
|
||||||
controllerRef := controller.GetControllerOf(pod)
|
controllerRef := controller.GetControllerOf(pod)
|
||||||
if controllerRef == nil {
|
if controllerRef == nil {
|
||||||
@ -350,6 +358,7 @@ func (rm *ReplicationManager) deletePod(obj interface{}) {
|
|||||||
// It's controlled by a different type of controller.
|
// It's controlled by a different type of controller.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
glog.V(4).Infof("Pod %s/%s deleted through %v, timestamp %+v: %#v.", pod.Namespace, pod.Name, utilruntime.GetCaller(), pod.DeletionTimestamp, pod)
|
||||||
|
|
||||||
rc, err := rm.rcLister.ReplicationControllers(pod.Namespace).Get(controllerRef.Name)
|
rc, err := rm.rcLister.ReplicationControllers(pod.Namespace).Get(controllerRef.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user