Skip to content

refactor: Create cron-node (MAPCO-10228)#41

Open
Powfu2 wants to merge 3 commits into
masterfrom
feat/add-node-cron
Open

refactor: Create cron-node (MAPCO-10228)#41
Powfu2 wants to merge 3 commits into
masterfrom
feat/add-node-cron

Conversation

@Powfu2

@Powfu2 Powfu2 commented Jul 19, 2026

Copy link
Copy Markdown

Create cron-node,
upgrade all libraries,
add ci
add tests

@github-actions

github-actions Bot commented Jul 19, 2026

Copy link
Copy Markdown

🎫 Related Jira Issue: MAPCO-10228

@Powfu2
Powfu2 requested a review from eyalr1100 July 19, 2026 08:32
Comment thread config/default.json Outdated
{
"telemetry": {
"shared": {
"serviceName": "planet-dumper"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do shared: {}

Comment on lines +13 to +17
{{- if .Values.cron.enabled }}
TARGET: {{ .Values.cron.target | quote }}
CRON_EXPRESSION: {{ .Values.cron.schedule | quote }}
RUN_ON_INIT: {{ .Values.cron.runOnInit | quote }}
{{- end }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like with .values.cron but that's me

Comment thread src/commands/common/pipelineRunner.ts Outdated
try {
const state = await manager.getState(stateSource);

// pre cleanup

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove ai comments

Comment thread src/commands/common/pipelineRunner.ts Outdated
Comment on lines +118 to +123
if (cleanupMode === 'post-clean-workdir') {
await emptyDirectory(join(WORKDIR, state));
} else if (cleanupMode === 'post-clean-others') {
await emptyDirectory(WORKDIR, [state]);
} else if (cleanupMode === 'post-clean-all') {
await emptyDirectory(WORKDIR);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UGLY! maybe switch? Maybe enum (as const, satisfy, whatever)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WTF

Comment thread src/commands/common/types.ts Outdated
Comment on lines +5 to +14
export const PG_DUMP_CLEANUP_CHOICES: CleanupMode[] = ['none', 'pre-clean-others', 'post-clean-others'];

export const CREATE_CLEANUP_CHOICES: ExtendedCleanupMode[] = [
'none',
'pre-clean-others',
'post-clean-others',
'post-clean-workdir',
'post-clean-all',
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AN ARRAY??? WITH LOW CARDINALITY VALUES???

Comment on lines +35 to +50
const buildArgv = (overrides: Partial<ScheduleArguments>): Arguments<ScheduleArguments> => ({
// eslint-disable-next-line @typescript-eslint/naming-convention -- required by yargs' Arguments<T> shape
_: [],
$0: 'planet-dumper',
outputFormat: 'dump_{state}_{timestamp}.pbf',
stateSource: '1',
cleanupMode: 'none',
s3Acl: 'private',
dumpServerHeaders: [],
resume: false,
info: false,
target: 'pg_dump',
cronExpression: '* * * * * *',
runOnInit: false,
...overrides,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this could be in a different class

Comment on lines +55 to +59
for (const task of getTasks().values()) {
void task.destroy();
}
vi.restoreAllMocks();
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foreach

Comment on lines +65 to +66
// gate the first run on an explicit signal instead of a fixed delay, so "still in-flight"
// is guaranteed rather than timing-dependent on how fast the test happens to run

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Comment on lines +42 to +62
const disabledArstotzkaConfig: ArstotzkaConfig = {
enabled: false,
services: { planetDumperPg: 'pg-service', planetDumperNg: 'ng-service' },
mediator: {
timeout: 1000,
enableRetryStrategy: false,
retryStrategy: {},
},
};

const enabledArstotzkaConfig: ArstotzkaConfig = {
enabled: true,
services: { planetDumperPg: 'pg-service', planetDumperNg: 'ng-service' },
mediator: {
timeout: 1000,
enableRetryStrategy: false,
retryStrategy: {},
actiony: { url: 'http://actiony.example.com' },
locky: { url: 'http://locky.example.com' },
},
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of writing the same cofnig twice with one variable flipped, just use ... with overrides

Comment thread .release-please-manifest.json Outdated
@@ -0,0 +1,3 @@
{
".": "6.1.0"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The master tag says 4.0.0

@eyalr1100
eyalr1100 self-requested a review July 22, 2026 06:32
Comment on lines +1 to +2
import { join, dirname } from 'node:path';
import { createReadStream } from 'node:fs';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WTF?

Comment on lines 41 to 42
const currentNgDumpDir = join(WORKDIR, this.state, NG_DUMP_DIR);
const ngDumpOutputPath = join(currentNgDumpDir, ngDumpName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

every fs function should live in fs repository

Comment on lines +11 to +12
import type { PgDumpPipelineArgs } from '../common/pipelineRunner';
import { runPgDumpPipeline } from '../common/pipelineRunner';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge

import type { ConfigType } from '@common/config';
import { FsRepository } from '@src/fsRepository/fsRepository';
import { nameFormat } from '../common/helpers';
import type { CleanupMode } from '../common/types';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have @common

Comment on lines +37 to +50
stateSourceCheck(stateSource);

const target = config.get('cli.schedule.target');
if (target === undefined) {
throw new CheckError('cli.schedule.target must be configured to run the schedule command', 'cli.schedule.target', target);
}

const cronExpression = config.get('cli.schedule.cronExpression');
if (cronExpression === undefined) {
throw new CheckError(
'cli.schedule.cronExpression must be configured to run the schedule command',
'cli.schedule.cronExpression',
cronExpression
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all these checks are stuff that schemas should solve. If an undefined cli.schedule.target causes an error, just require it

}): DependencyContainer => {
const logger = overrides.logger ?? buildLogger();
const config = overrides.config ?? buildConfig();
const manager = overrides.manager ?? ({} as CreateManager);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no as

Comment on lines +56 to +66
'cli.stateSource': '1',
'cli.outputFormat': 'dump_{state}_{timestamp}.pbf',
'cli.cleanupMode': 'none',
'cli.resume': false,
'cli.info': false,
's3.endpoint': 'https://s3.example.com',
's3.bucketName': 'bucket',
's3.acl': 'private',
'cli.dumpServer.endpoint': undefined,
'cli.dumpServer.headers': [],
...overrides,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider putting non test specific configs in test.json

const dependencyContainer = buildDependencyContainer({ config: validConfig() });
const { handler } = createCommandFactory(dependencyContainer);

// eslint-disable-next-line @typescript-eslint/naming-convention -- required by yargs' Arguments<T> shape

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you disable it every five lines just disable the rule for the whole file

});

it('collects osmium info and attaches it to the metadata when shouldCollectInfo is true', async () => {
spawnChildMock.mockResolvedValue({ exitCode: 0, stdout: '{"num_nodes":1}', stderr: '' } as never);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you use alot of as nevers, why?

Comment thread package.json
"@map-colonies/config": "^4.0.1",
"@map-colonies/js-logger": "^5.0.0",
"@map-colonies/read-pkg": "^2.0.0",
"@map-colonies/schemas": "https://ghatmpstorage.blob.core.windows.net/npm-packages/schemas-213f62397c5cf2f0f83694fbcdaf18665b00bd6e.tgz",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget to change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants