Clean shutdown of endpoints/endpointslice integration tests

This commit is contained in:
Wojciech Tyczyński
2022-05-28 21:51:14 +02:00
parent 3af4c74f37
commit c20f7cc4e1
4 changed files with 25 additions and 6 deletions

View File

@@ -86,8 +86,6 @@ func NewController(podInformer coreinformers.PodInformer,
endpointUpdatesBatchPeriod time.Duration,
) *Controller {
broadcaster := record.NewBroadcaster()
broadcaster.StartStructuredLogging(0)
broadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: client.CoreV1().Events("")})
recorder := broadcaster.NewRecorder(scheme.Scheme, v1.EventSource{Component: "endpoint-slice-controller"})
if client != nil && client.CoreV1().RESTClient().GetRateLimiter() != nil {
@@ -252,6 +250,12 @@ type Controller struct {
// Run will not return until stopCh is closed.
func (c *Controller) Run(workers int, stopCh <-chan struct{}) {
defer utilruntime.HandleCrash()
// Start events processing pipeline.
c.eventBroadcaster.StartLogging(klog.Infof)
c.eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: c.client.CoreV1().Events("")})
defer c.eventBroadcaster.Shutdown()
defer c.queue.ShutDown()
klog.Infof("Starting endpoint slice controller")