Skip to content

Consider disk usage of collDir instead of default /crawls #586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/crawler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,11 @@ self.__bx_behaviors.selectMainBehavior();

if (this.params.diskUtilization) {
// Check that disk usage isn't already or soon to be above threshold
const diskUtil = await checkDiskUtilization(this.params, size);
const diskUtil = await checkDiskUtilization(
this.collDir,
this.params,
size,
);
if (diskUtil.stop === true) {
interrupt = true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/util/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,15 @@ export async function getDirSize(dir: string) {
}

export async function checkDiskUtilization(
collDir: string,
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
params: Record<string, any>,
archiveDirSize: number,
dfOutput = null,
) {
const diskUsage: Record<string, string> = await getDiskUsage(
"/crawls",
collDir,
dfOutput,
);
const usedPercentage = parseInt(diskUsage["Use%"].slice(0, -1));
Expand Down
2 changes: 2 additions & 0 deletions tests/storage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ grpcfuse 1000000 285000 715000 28% /crawls`;
// with combineWARC + generateWACZ, projected is 285k + 4 * 5k = 310k = 31%
// does not exceed 90% threshold
const returnValue = await checkDiskUtilization(
'/crawls',
params,
5000 * 1024,
mockDfOutput,
Expand All @@ -55,6 +56,7 @@ grpcfuse 100000 85000 15000 85% /crawls`;
// with generateWACZ, projected is 85k + 3k x 2 = 91k = 91%
// exceeds 90% threshold
const returnValue = await checkDiskUtilization(
'/crawls',
params,
3000 * 1024,
mockDfOutput,
Expand Down
Loading