Skip to content

Commit b2ab32c

Browse files
committed
feat: completely skip processing Jobs if requested via flag
1 parent 82e7928 commit b2ab32c

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/supervisor/metadata-extractor.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ import {
55
V1ContainerStatus,
66
V1PodSpec,
77
} from '@kubernetes/client-node';
8-
import { IWorkload, ILocalWorkloadLocator } from '../transmitter/types';
98
import { currentClusterName } from './cluster';
10-
import { IKubeObjectMetadata } from './types';
9+
import { WorkloadKind } from './types';
1110
import { getSupportedWorkload, getWorkloadReader } from './workload-reader';
1211
import { 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

1417
const 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,

0 commit comments

Comments
 (0)