Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #78 from JupiterOne/INT-11153
Browse files Browse the repository at this point in the history
Prevent nodes with missing metadata to be created
  • Loading branch information
Gonzalo-Avalos-Ribas authored Aug 13, 2024
2 parents 635e7a9 + b91330f commit b82f1ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jupiterone/graph-kubernetes",
"version": "2.3.1",
"version": "2.3.2",
"description": "A JupiterOne Integration for Kubernetes",
"repository": {
"type": "git",
Expand Down
20 changes: 17 additions & 3 deletions src/steps/nodes/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
import { IntegrationStep } from '@jupiterone/integration-sdk-core';
import {
IntegrationStep,
IntegrationWarnEventName,
} from '@jupiterone/integration-sdk-core';
import { IntegrationConfig, IntegrationStepContext } from '../../config';
import { Entities, IntegrationSteps } from '../constants';
import { createNodeEntity } from './converters';
import { cacheNodeNameToUid } from '../../util/jobState';
import getOrCreateAPIClient from '../../kubernetes/getOrCreateAPIClient';
import { V1Node } from '@kubernetes/client-node';

export async function fetchNodes(
context: IntegrationStepContext,
): Promise<void> {
const { instance, jobState } = context;
const { instance, jobState, logger } = context;
const { config } = instance;
let nodesWithMissingMetadata = 0;

const client = getOrCreateAPIClient(config);

await client.iterateNodes(async (node) => {
await client.iterateNodes(async (node: V1Node) => {
if (!node.metadata) {
nodesWithMissingMetadata++;
return;
}
const nodeEntity = createNodeEntity(node);
await jobState.addEntity(nodeEntity);
await cacheNodeNameToUid(jobState, node);
});

logger.publishWarnEvent({
name: IntegrationWarnEventName.IngestionLimitEncountered,
description: `Found metadata missing for ${nodesWithMissingMetadata} nodes`,
});
}

export const nodeSteps: IntegrationStep<IntegrationConfig>[] = [
Expand Down

0 comments on commit b82f1ef

Please sign in to comment.