File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 11import * as SourceMapSupport from 'source-map-support' ;
2+
3+ import * as state from './state' ;
24import logger = require( './common/logger' ) ;
35import { currentClusterName } from './supervisor/cluster' ;
46import { beginWatchingWorkloads } from './supervisor/watchers' ;
57
68process . on ( 'uncaughtException' , ( err ) => {
9+ if ( state . shutdownInProgress ) {
10+ return ;
11+ }
12+
713 try {
814 logger . error ( { err} , 'UNCAUGHT EXCEPTION!' ) ;
915 } catch ( ignore ) {
@@ -14,6 +20,10 @@ process.on('uncaughtException', (err) => {
1420} ) ;
1521
1622process . on ( 'unhandledRejection' , ( reason ) => {
23+ if ( state . shutdownInProgress ) {
24+ return ;
25+ }
26+
1727 try {
1828 logger . error ( { reason} , 'UNHANDLED REJECTION!' ) ;
1929 } catch ( ignore ) {
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const workloadsLruCacheOptions = {
2121} ;
2222
2323const state = {
24+ shutdownInProgress : false ,
2425 imagesAlreadyScanned : new lruCache < string , string > ( imagesLruCacheOptions ) ,
2526 workloadsAlreadyScanned : new lruCache < string , string > ( workloadsLruCacheOptions ) ,
2627} ;
Original file line number Diff line number Diff line change @@ -97,5 +97,10 @@ tap.test('Kubernetes-Monitor with KinD', async (t) => {
9797 // additional asserts?
9898 t . ok ( nock . isDone ( ) , 'all outgoing calls were made' ) ;
9999
100+ // instruct the Monitor to ignore errors from this point
101+ // eslint-disable-next-line @typescript-eslint/no-var-requires
102+ const kubernetesMonitorState = require ( '../../src/state' ) ;
103+ kubernetesMonitorState . shutdownInProgress = true ;
104+
100105 // TODO cleanup the images we saved to /var/tmp?
101106} ) ;
You can’t perform that action at this time.
0 commit comments