Skip to content

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

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

refactor!: Create cron-node (MAPCO-10228)#41
Powfu2 wants to merge 6 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 thread src/commands/create/createManager.ts Outdated
Comment thread src/commands/create/createManager.ts
Comment thread src/commands/pgDump/pgDumpFactory.ts Outdated
Comment thread src/commands/schedule/scheduleFactory.ts Outdated
Comment on lines +114 to +119
let exitCode = ExitCodes.GENERAL_ERROR;

if (error instanceof ErrorWithExitCode) {
exitCode = error.exitCode;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
let exitCode = ExitCodes.GENERAL_ERROR;
if (error instanceof ErrorWithExitCode) {
exitCode = error.exitCode;
}
const exitCode = error instanceof ErrorWithExitCode ? error.exitCode : ExitCodes.GENERAL_ERROR;

}): 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 thread tests/unit/commands/create/createFactory.spec.ts Outdated
Comment thread tests/unit/commands/create/createFactory.spec.ts Outdated
Comment thread tests/unit/commands/create/createManager.spec.ts
Comment thread package.json Outdated
"@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

Comment thread src/commands/common/pipelineRunner.ts
Comment thread src/commands/create/createFactory.ts Outdated
Comment thread src/commands/create/createFactory.ts Outdated

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 didn't fix this file at all

Comment thread src/commands/pgDump/pgDumpManager.ts
const runCreatePipelineMock = vi.mocked(runCreatePipeline);
const terminateChildrenMock = vi.mocked(terminateChildren);

const buildLogger = (): Logger => ({ debug: vi.fn(), info: vi.fn(), warn: vi.fn(), error: vi.fn() }) as unknown as Logger;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

fix this, as unknown as is a bad habbit, I'd rather you create a vi.fn() for every logger function instead
Also I don't think you need to test the logs so you can remove logger altogether

Comment thread tests/unit/commands/create/createFactory.spec.ts Outdated
Comment thread tests/unit/commands/create/createManager.spec.ts Outdated
Comment thread tests/unit/commands/create/createManager.spec.ts Outdated

const spawnChildMock = vi.mocked(spawnChild);

const buildAxios = (): AxiosInstance => ({ get: vi.fn() }) as unknown as AxiosInstance;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use nock

@NivGreenstein

Copy link
Copy Markdown

Any breaking changes? if so please rename to refactor!:

Comment thread .github/workflows/pull_request.yaml Outdated
Comment thread helm/templates/job.yaml
Comment on lines -50 to -51
- configMapRef:
name: {{ $releaseName }}-{{ $chartName }}-command-options-configmap

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why?

Comment thread helm/Chart.yaml Outdated
Comment thread helm/values.yaml Outdated
Comment thread helm/values.yaml Outdated
enabled: false
apiVersion: 'batch/v1' # depends on openshift version batch/v1 or batch/v1beta1
restartPolicy: OnFailure
schedule: '* * * * *'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this the actual schedule??

Comment thread src/containerConfig.ts
{ token: SERVICES.ARSTOTZKA, provider: { useValue: arstotzkaConfig } },
{ token: SERVICES.HTTP_CLIENT, provider: { useValue: axiosClient } },
{ token: SCHEDULE_COMMAND_FACTORY, provider: { useFactory: scheduleCommandFactory } },
{ token: SERVICES.CONFIG, provider: { useFactory: () => getConfig() } },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

change to useValue

Comment thread src/containerConfig.ts
Comment on lines +100 to +104
if (endpoint === undefined) {
throw new CheckError('s3.endpoint must be configured to use the s3 client', 's3', { endpoint });
}
return new S3Client({ endpoint, region: S3_REGION, forcePathStyle: true });
}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

create a factory function somewhere else + utilize the @map-colonies/schemas validation.

Comment thread package.json
{
"name": "planet-dumper",
"version": "6.1.0",
"version": "4.0.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.

revert version

Comment thread package.json
"tsyringe": "^4.6.0",
"tsyringe": "^4.10.0",
"valid-url": "^1.0.9",
"yargs": "^17.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.

remove

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-120a0c5e573e9bc4c79b7e346950f4eb5835add9.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 forger to change

@Powfu2 Powfu2 changed the title refactor: Create cron-node (MAPCO-10228) refactor!: Create cron-node (MAPCO-10228) Aug 19, 2026
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.

3 participants