@@ -2,7 +2,7 @@ import { V1Namespace } from '@kubernetes/client-node';
22
33import { logger } from '../../common/logger' ;
44import { config } from '../../common/config' ;
5- import { WorkloadKind } from '../types' ;
5+ import { NamespaceResponse , WorkloadKind } from '../types' ;
66import { setupNamespacedInformer , setupClusterInformer } from './handlers' ;
77import { k8sApi } from '../cluster' ;
88import { extractNamespaceName } from './internal-namespaces' ;
@@ -60,9 +60,18 @@ export async function beginWatchingWorkloads(): Promise<void> {
6060 { namespace : config . WATCH_NAMESPACE } ,
6161 'kubernetes-monitor restricted to specific namespace' ,
6262 ) ;
63- const namespaceResponse = await k8sApi . coreClient . readNamespace (
64- config . WATCH_NAMESPACE ,
65- ) ;
63+ let namespaceResponse : NamespaceResponse | undefined ;
64+ try {
65+ namespaceResponse = await k8sApi . coreClient . readNamespace (
66+ config . WATCH_NAMESPACE ,
67+ ) ;
68+ } catch ( err ) {
69+ logger . error (
70+ { watchedNamespace : config . WATCH_NAMESPACE , err } ,
71+ 'failed to read the namespace' ,
72+ ) ;
73+ return ;
74+ }
6675 const namespace = namespaceResponse . body ;
6776 await setupWatchesForNamespace ( namespace ) ;
6877 return ;
0 commit comments