mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Record an event when a pod does not have exactly 1 controller.
This commit is contained in:
		@@ -502,9 +502,11 @@ func (dc *DisruptionController) getExpectedPodCount(pdb *policy.PodDisruptionBud
 | 
			
		||||
			}
 | 
			
		||||
			if controllerCount == 0 {
 | 
			
		||||
				err = fmt.Errorf("asked for percentage, but found no controllers for pod %q", pod.Name)
 | 
			
		||||
				dc.recorder.Event(pdb, api.EventTypeWarning, "NoControllers", err.Error())
 | 
			
		||||
				return
 | 
			
		||||
			} else if controllerCount > 1 {
 | 
			
		||||
				err = fmt.Errorf("pod %q has %v>1 controllers", pod.Name, controllerCount)
 | 
			
		||||
				dc.recorder.Event(pdb, api.EventTypeWarning, "TooManyControllers", err.Error())
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,7 @@ import (
 | 
			
		||||
	"k8s.io/kubernetes/pkg/apis/extensions"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/apis/policy"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/client/cache"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/client/record"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/controller"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/util/intstr"
 | 
			
		||||
	"k8s.io/kubernetes/pkg/util/uuid"
 | 
			
		||||
@@ -76,14 +77,17 @@ func newFakeDisruptionController() (*DisruptionController, *pdbStates) {
 | 
			
		||||
	ps := &pdbStates{}
 | 
			
		||||
 | 
			
		||||
	dc := &DisruptionController{
 | 
			
		||||
		pdbLister:  cache.StoreToPodDisruptionBudgetLister{Store: cache.NewStore(controller.KeyFunc)},
 | 
			
		||||
		podLister:  cache.StoreToPodLister{Indexer: cache.NewIndexer(controller.KeyFunc, cache.Indexers{})},
 | 
			
		||||
		rcLister:   cache.StoreToReplicationControllerLister{Indexer: cache.NewIndexer(controller.KeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})},
 | 
			
		||||
		rsLister:   cache.StoreToReplicaSetLister{Store: cache.NewStore(controller.KeyFunc)},
 | 
			
		||||
		dLister:    cache.StoreToDeploymentLister{Store: cache.NewStore(controller.KeyFunc)},
 | 
			
		||||
		getUpdater: func() updater { return ps.Set },
 | 
			
		||||
		pdbLister:   cache.StoreToPodDisruptionBudgetLister{Store: cache.NewStore(controller.KeyFunc)},
 | 
			
		||||
		podLister:   cache.StoreToPodLister{Indexer: cache.NewIndexer(controller.KeyFunc, cache.Indexers{})},
 | 
			
		||||
		rcLister:    cache.StoreToReplicationControllerLister{Indexer: cache.NewIndexer(controller.KeyFunc, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})},
 | 
			
		||||
		rsLister:    cache.StoreToReplicaSetLister{Store: cache.NewStore(controller.KeyFunc)},
 | 
			
		||||
		dLister:     cache.StoreToDeploymentLister{Store: cache.NewStore(controller.KeyFunc)},
 | 
			
		||||
		getUpdater:  func() updater { return ps.Set },
 | 
			
		||||
		broadcaster: record.NewBroadcaster(),
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	dc.recorder = dc.broadcaster.NewRecorder(api.EventSource{Component: "disruption_test"})
 | 
			
		||||
 | 
			
		||||
	return dc, ps
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user