Skip to content

Commit 4100eab

Browse files
authored
fix(core): respect systemInfoV2 in snapshotter (#2961)
When no `memoryMbytes` option is provided, we infer the available memory in the snapshotter. This place was not respecting the `systemInfoV2` option, which this PR resolves. Closes #2958
1 parent 6d636c0 commit 4100eab

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

packages/core/src/autoscaling/snapshotter.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { StorageClient } from '@crawlee/types';
2-
import { getMemoryInfo } from '@crawlee/utils';
2+
import { getMemoryInfo, getMemoryInfoV2, isContainerized } from '@crawlee/utils';
33
import ow from 'ow';
44

55
import type { Log } from '@apify/log';
@@ -195,7 +195,17 @@ export class Snapshotter {
195195
if (memoryMbytes > 0) {
196196
this.maxMemoryBytes = memoryMbytes * 1024 * 1024;
197197
} else {
198-
const { totalBytes } = await getMemoryInfo();
198+
let totalBytes: number;
199+
200+
if (this.config.get('systemInfoV2')) {
201+
const containerized = this.config.get('containerized', await isContainerized());
202+
const memInfo = await getMemoryInfoV2(containerized);
203+
totalBytes = memInfo.totalBytes;
204+
} else {
205+
const memInfo = await getMemoryInfo();
206+
totalBytes = memInfo.totalBytes;
207+
}
208+
199209
this.maxMemoryBytes = Math.ceil(totalBytes * this.config.get('availableMemoryRatio')!);
200210
this.log.debug(
201211
`Setting max memory of this run to ${Math.round(this.maxMemoryBytes / 1024 / 1024)} MB. ` +

packages/core/src/events/local_event_manager.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ export class LocalEventManager extends EventManager {
5454
* @internal
5555
*/
5656
async isContainerizedWrapper() {
57-
const config = this.config.get('containerized');
58-
if (config !== undefined) {
59-
return config;
60-
}
61-
return isContainerized();
57+
return this.config.get('containerized', await isContainerized());
6258
}
6359

6460
private getCurrentCpuTicks() {

0 commit comments

Comments
 (0)