mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 22:40:35 +00:00
[apiserver] [126379]: replace call to HandleCrash with call to HandleCrashWithContext where ctx is available for caller
Signed-off-by: Nikita B <n2h9z4@gmail.com>
This commit is contained in:
@@ -174,7 +174,7 @@ func (c *RequestHeaderAuthRequestController) AllowedClientNames() []string {
|
||||
|
||||
// Run starts RequestHeaderAuthRequestController controller and blocks until stopCh is closed.
|
||||
func (c *RequestHeaderAuthRequestController) Run(ctx context.Context, workers int) {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
defer c.queue.ShutDown()
|
||||
|
||||
klog.Infof("Starting %s", c.name)
|
||||
|
||||
@@ -1263,7 +1263,7 @@ func (e *Store) DeleteCollection(ctx context.Context, deleteValidation rest.Vali
|
||||
for i := 0; i < workersNumber; i++ {
|
||||
go func() {
|
||||
// panics don't cross goroutine boundaries
|
||||
defer utilruntime.HandleCrash(func(panicReason interface{}) {
|
||||
defer utilruntime.HandleCrashWithContext(ctx, func(_ context.Context, panicReason interface{}) {
|
||||
errs <- fmt.Errorf("DeleteCollection goroutine panicked: %v", panicReason)
|
||||
})
|
||||
defer wg.Done()
|
||||
@@ -1288,7 +1288,7 @@ func (e *Store) DeleteCollection(ctx context.Context, deleteValidation rest.Vali
|
||||
}
|
||||
// In case of all workers exit, notify distributor.
|
||||
go func() {
|
||||
defer utilruntime.HandleCrash(func(panicReason interface{}) {
|
||||
defer utilruntime.HandleCrashWithContext(ctx, func(_ context.Context, panicReason interface{}) {
|
||||
errs <- fmt.Errorf("DeleteCollection workers closer panicked: %v", panicReason)
|
||||
})
|
||||
wg.Wait()
|
||||
|
||||
@@ -199,7 +199,7 @@ func (c *ConfigMapCAController) RunOnce(ctx context.Context) error {
|
||||
|
||||
// Run starts the kube-apiserver and blocks until stopCh is closed.
|
||||
func (c *ConfigMapCAController) Run(ctx context.Context, workers int) {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
defer c.queue.ShutDown()
|
||||
|
||||
klog.InfoS("Starting controller", "name", c.name)
|
||||
|
||||
@@ -155,7 +155,7 @@ func (c *DynamicFileCAContent) RunOnce(ctx context.Context) error {
|
||||
|
||||
// Run starts the controller and blocks until stopCh is closed.
|
||||
func (c *DynamicFileCAContent) Run(ctx context.Context, workers int) {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
defer c.queue.ShutDown()
|
||||
|
||||
klog.InfoS("Starting controller", "name", c.name)
|
||||
|
||||
@@ -129,7 +129,7 @@ func (c *DynamicCertKeyPairContent) RunOnce(ctx context.Context) error {
|
||||
|
||||
// Run starts the controller and blocks until context is killed.
|
||||
func (c *DynamicCertKeyPairContent) Run(ctx context.Context, workers int) {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
defer c.queue.ShutDown()
|
||||
|
||||
klog.InfoS("Starting controller", "name", c.name)
|
||||
|
||||
@@ -530,7 +530,7 @@ func (s preparedGenericAPIServer) RunWithContext(ctx context.Context) error {
|
||||
// If UDS profiling is enabled, start a local http server listening on that socket
|
||||
if s.UnprotectedDebugSocket != nil {
|
||||
go func() {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
klog.Error(s.UnprotectedDebugSocket.RunWithContext(ctx))
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ func runPostStartHook(name string, entry postStartHookEntry, context PostStartHo
|
||||
var err error
|
||||
func() {
|
||||
// don't let the hook *accidentally* panic and kill the server
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(context)
|
||||
err = entry.hook(context)
|
||||
}()
|
||||
// if the hook intentionally wants to kill server, let it.
|
||||
|
||||
@@ -92,7 +92,7 @@ func NewDynamicEncryptionConfiguration(
|
||||
|
||||
// Run starts the controller and blocks until ctx is canceled.
|
||||
func (d *DynamicEncryptionConfigContent) Run(ctx context.Context) {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
|
||||
klog.InfoS("Starting controller", "name", d.name)
|
||||
defer klog.InfoS("Shutting down controller", "name", d.name)
|
||||
@@ -101,7 +101,7 @@ func (d *DynamicEncryptionConfigContent) Run(ctx context.Context) {
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
defer wg.Done()
|
||||
defer d.queue.ShutDown()
|
||||
<-ctx.Done()
|
||||
@@ -109,7 +109,7 @@ func (d *DynamicEncryptionConfigContent) Run(ctx context.Context) {
|
||||
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
defer wg.Done()
|
||||
d.runWorker(ctx)
|
||||
}()
|
||||
|
||||
@@ -434,7 +434,7 @@ func (c *cacheWatcher) sendWatchCacheEvent(event *watchCacheEvent) {
|
||||
}
|
||||
|
||||
func (c *cacheWatcher) processInterval(ctx context.Context, cacheInterval *watchCacheInterval, resourceVersion uint64) {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
defer close(c.result)
|
||||
defer c.Stop()
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ func (pr *ConditionalProgressRequester) Run(stopCh <-chan struct{}) {
|
||||
ctx = metadata.NewOutgoingContext(ctx, pr.contextMetadata)
|
||||
}
|
||||
go func() {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
<-stopCh
|
||||
pr.mux.Lock()
|
||||
defer pr.mux.Unlock()
|
||||
|
||||
@@ -109,7 +109,7 @@ func (f *defaultFeatureSupportChecker) checkClient(ctx context.Context, c client
|
||||
}
|
||||
f.checkingEndpoint[ep] = struct{}{}
|
||||
go func(ep string) {
|
||||
defer runtime.HandleCrash()
|
||||
defer runtime.HandleCrashWithContext(ctx)
|
||||
err := delayFunc.Until(ctx, true, true, func(ctx context.Context) (done bool, err error) {
|
||||
internalErr := f.clientSupportsRequestWatchProgress(ctx, c, ep)
|
||||
return internalErr == nil, nil
|
||||
|
||||
@@ -86,7 +86,7 @@ func NewGRPCService(ctx context.Context, endpoint string, callTimeout time.Durat
|
||||
s.kmsClient = kmsapi.NewKeyManagementServiceClient(s.connection)
|
||||
|
||||
go func() {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
|
||||
<-ctx.Done()
|
||||
_ = s.connection.Close()
|
||||
|
||||
@@ -83,7 +83,7 @@ func NewGRPCService(ctx context.Context, endpoint, providerName string, callTime
|
||||
s.kmsClient = kmsapi.NewKeyManagementServiceClient(s.connection)
|
||||
|
||||
go func() {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
|
||||
<-ctx.Done()
|
||||
_ = s.connection.Close()
|
||||
|
||||
@@ -42,7 +42,7 @@ const (
|
||||
)
|
||||
|
||||
func (h *peerProxyHandler) RunPeerDiscoveryCacheSync(ctx context.Context, workers int) {
|
||||
defer utilruntime.HandleCrash()
|
||||
defer utilruntime.HandleCrashWithContext(ctx)
|
||||
defer h.peerLeaseQueue.ShutDown()
|
||||
defer func() {
|
||||
err := h.apiserverIdentityInformer.Informer().RemoveEventHandler(h.leaseRegistration)
|
||||
|
||||
Reference in New Issue
Block a user