File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -5,11 +5,14 @@ import {
55 V1ContainerStatus ,
66 V1PodSpec ,
77} from '@kubernetes/client-node' ;
8- import { IWorkload , ILocalWorkloadLocator } from '../transmitter/types' ;
98import { currentClusterName } from './cluster' ;
10- import { IKubeObjectMetadata } from './types' ;
9+ import { WorkloadKind } from './types' ;
1110import { getSupportedWorkload , getWorkloadReader } from './workload-reader' ;
1211import { logger } from '../common/logger' ;
12+ import { config } from '../common/config' ;
13+
14+ import type { IKubeObjectMetadata } from './types' ;
15+ import type { IWorkload , ILocalWorkloadLocator } from '../transmitter/types' ;
1316
1417const loopingThreshold = 20 ;
1518
@@ -170,6 +173,17 @@ export async function buildMetadataForWorkload(
170173 ) ;
171174 }
172175
176+ const hasJobOwnerRef = pod . metadata ?. ownerReferences ?. find (
177+ ( owner ) => owner . kind === WorkloadKind . Job ,
178+ ) ;
179+ if ( hasJobOwnerRef && config . SKIP_K8S_JOBS ) {
180+ logger . info (
181+ { podMetadata : pod . metadata } ,
182+ 'pod associated with job but jobs are skipped from processing. not building metadata.' ,
183+ ) ;
184+ return undefined ;
185+ }
186+
173187 const podOwner : IKubeObjectMetadata | undefined = await findParentWorkload (
174188 pod . spec ,
175189 pod . metadata . ownerReferences ,
You can’t perform that action at this time.
0 commit comments