mirror of
https://github.com/actions/actions-runner-controller.git
synced 2025-12-20 06:56:51 +00:00
Shutdown metrics server when listener exits (#3445)
This commit is contained in:
@@ -174,8 +174,8 @@ func (l *Listener) Listen(ctx context.Context, handler Handler) error {
|
||||
continue
|
||||
}
|
||||
|
||||
// New context is created to avoid cancelation during message handling.
|
||||
if err := l.handleMessage(context.Background(), handler, msg); err != nil {
|
||||
// Remove cancellation from the context to avoid cancelling the message handling.
|
||||
if err := l.handleMessage(context.WithoutCancel(ctx), handler, msg); err != nil {
|
||||
return fmt.Errorf("failed to handle message: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -484,8 +484,8 @@ func TestListener_Listen(t *testing.T) {
|
||||
).
|
||||
Once()
|
||||
|
||||
// Ensure delete message is called with background context
|
||||
client.On("DeleteMessage", context.Background(), mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()
|
||||
// Ensure delete message is called without cancel
|
||||
client.On("DeleteMessage", context.WithoutCancel(ctx), mock.Anything, mock.Anything, mock.Anything).Return(nil).Once()
|
||||
|
||||
config.Client = client
|
||||
|
||||
|
||||
Reference in New Issue
Block a user