Skip to content

Commit

Permalink
Improve/fix checks (#2727)
Browse files Browse the repository at this point in the history
* Improve checks logging

* fix scrub check

* Monitor on error
  • Loading branch information
spolu authored Nov 30, 2023
1 parent 822a880 commit a025a23
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ export const managedDataSourceGCGdriveCheck: CheckFunction = async (
);
if (notDeleted.length > 0) {
reportFailure(
{ notDeleted },
{ notDeleted, connectorId: ds.connectorId },
"Google Drive documents not properly Garbage collected"
);
} else {
reportSuccess({});
reportSuccess({
connectorId: ds.connectorId,
});
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ export const scrubDeletedCoreDocumentVersionsCheck: CheckFunction = async (
hash: string;
}[];

logger.info("Found deleted core documents to scrub", {
documentCount: deletedDocuments.length,
});
logger.info(
{
documentCount: deletedDocuments.length,
},
"Found deleted core documents to scrub"
);

const chunks = [];
for (let i = 0; i < deletedDocuments.length; i += 32) {
Expand All @@ -46,10 +49,6 @@ export const scrubDeletedCoreDocumentVersionsCheck: CheckFunction = async (
let deletedCount = 0;

for (let i = 0; i < chunks.length; i++) {
logger.info("Processing chunk", {
chunkIndex: i,
chunksCount: chunks.length,
});
const chunk = chunks[i];
await Promise.all(
chunk.map((d) => {
Expand All @@ -71,11 +70,16 @@ export const scrubDeletedCoreDocumentVersionsCheck: CheckFunction = async (
);
}

logger.info("Done scrubbing deleted core document versions", {
logger.info(
{
deletedCount,
},
"Done scrubbing deleted core document versions"
);

reportSuccess({
deletedCount,
});

reportSuccess({});
};

async function scrubDocument(
Expand Down Expand Up @@ -151,14 +155,18 @@ async function scrubDocument(
await Promise.all(
files.map((f) => {
if (!seen.has(f.name)) {
logger.info("Scrubbing", {
path: f.name,
documentId: document_id,
documentHash: hash,
dataSourceProject: dataSource.project,
dataSourceInternalId: dataSource.internal_id,
dataSourceId: dataSource.id,
});
seen.add(f.name);
logger.info(
{
path: f.name,
documentId: document_id,
documentHash: hash,
dataSourceProject: dataSource.project,
dataSourceInternalId: dataSource.internal_id,
dataSourceId: dataSource.id,
},
"Scrubbing"
);

return f.delete();
}
Expand All @@ -176,18 +184,18 @@ async function scrubDocument(
}
);

logger.info("Scrubbed deleted versions", {
documentId: document_id,
documentHash: hash,
dataSourceProject: dataSource.project,
dataSourceInternalId: dataSource.internal_id,
dataSourceId: dataSource.id,
filesCount: files.length,
});
logger.info(
{
documentId: document_id,
documentHash: hash,
dataSourceProject: dataSource.project,
dataSourceInternalId: dataSource.internal_id,
dataSourceId: dataSource.id,
filesCount: files.length,
},
"Scrubbed deleted versions"
);

files.forEach((f) => {
seen.add(f.name);
});
seen.add(uid);

return true;
Expand Down
4 changes: 2 additions & 2 deletions front/production_checks/temporal/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ async function runAllChecks(checks: Check[]) {
for (const check of checks) {
const uuid = uuidv4();
const logger = mainLogger.child({
name: check.name,
checkName: check.name,
uuid,
});
try {
Expand Down Expand Up @@ -75,7 +75,7 @@ async function runAllChecks(checks: Check[]) {
logger.info("Check done");
}
} catch (e) {
logger.error({ error: e }, "Check failed");
logger.error({ error: e }, "Production check failed");
}
}
mainLogger.info({ uuid: allCheckUuid }, "Done running all checks");
Expand Down

0 comments on commit a025a23

Please sign in to comment.