feat(reports): keep reports until resolved, then by outcome (#3493)

This commit is contained in:
Hampus authored and GitHub committed 2026-10-15 16:40:51 +02:00
1 parent f5c30fdf8f
commit 4f88872a3c
18 files changed
+673 -238

No files matched your search

-9
View File
@@ -280,7 +280,6 @@ function defaultConfig(): MasterConfig {
inactivity_deletion_threshold_days: 365,
report_retention: {
days: 365,
resolved_days: null,
dry_run: false,
},
};
@@ -451,14 +450,6 @@ function validateApiWorkerConfig(config: MasterConfig): void {
function validateReportRetentionConfig(config: MasterConfig): void {
const retention = config.report_retention;
assertIntegerInRange(retention.days, 'FLUXER_REPORT_RETENTION_DAYS', 1, MAX_REPORT_RETENTION_DAYS);
if (retention.resolved_days !== null) {
assertIntegerInRange(
retention.resolved_days,
'FLUXER_RESOLVED_REPORT_RETENTION_DAYS',
1,
MAX_REPORT_RETENTION_DAYS,
);
}
assertBoolean(retention.dry_run, 'FLUXER_REPORT_RETENTION_DRY_RUN');
}
-1
View File
@@ -334,7 +334,6 @@ export interface MasterConfig {
inactivity_deletion_threshold_days: number;
report_retention: {
days: number;
resolved_days: number | null;
dry_run: boolean;
};
}
@@ -781,42 +781,22 @@ describe('report retention settings', () => {
vi.unstubAllEnvs();
});
test('deletes reports for real after 365 days with no resolved-report rule by default', async () => {
test('deletes resolved reports for real after 365 days by default', async () => {
stubMinimalEnv();
const config = await loadConfig();
expect(config.report_retention).toEqual({days: 365, resolved_days: null, dry_run: false});
expect(config.report_retention).toEqual({days: 365, dry_run: false});
});
test('reads both day settings and the dry run switch from the environment', async () => {
stubMinimalEnv({
FLUXER_REPORT_RETENTION_DAYS: '730',
FLUXER_RESOLVED_REPORT_RETENTION_DAYS: ' 90 ',
FLUXER_REPORT_RETENTION_DRY_RUN: 'TRUE',
});
test('reads the day setting and the dry run switch from the environment', async () => {
stubMinimalEnv({FLUXER_REPORT_RETENTION_DAYS: ' 730 ', FLUXER_REPORT_RETENTION_DRY_RUN: 'TRUE'});
const config = await loadConfig();
expect(config.report_retention).toEqual({days: 730, resolved_days: 90, dry_run: true});
});
test('an empty resolved-report setting leaves the rule off', async () => {
stubMinimalEnv({FLUXER_RESOLVED_REPORT_RETENTION_DAYS: '', FLUXER_REPORT_RETENTION_DRY_RUN: 'false'});
const config = await loadConfig();
expect(config.report_retention).toEqual({days: 365, resolved_days: null, dry_run: false});
expect(config.report_retention).toEqual({days: 730, dry_run: true});
});
test.each([
['FLUXER_REPORT_RETENTION_DAYS', '0', 'FLUXER_REPORT_RETENTION_DAYS must be an integer between 1 and 36500'],
['FLUXER_REPORT_RETENTION_DAYS', '36501', 'FLUXER_REPORT_RETENTION_DAYS must be an integer between 1 and 36500'],
['FLUXER_REPORT_RETENTION_DAYS', '1.5', 'FLUXER_REPORT_RETENTION_DAYS must be an integer, got "1.5"'],
[
'FLUXER_RESOLVED_REPORT_RETENTION_DAYS',
'0',
'FLUXER_RESOLVED_REPORT_RETENTION_DAYS must be an integer between 1 and 36500',
],
[
'FLUXER_RESOLVED_REPORT_RETENTION_DAYS',
'-30',
'FLUXER_RESOLVED_REPORT_RETENTION_DAYS must be an integer between 1 and 36500',
],
['FLUXER_REPORT_RETENTION_DRY_RUN', '1', 'FLUXER_REPORT_RETENTION_DRY_RUN must be true or false'],
])('refuses %s=%j', async (name, value, message) => {
stubMinimalEnv({[name]: value});
@@ -97,11 +97,10 @@ describe('the shipped compose stack forwards settings from .env', () => {
expect(renamed).toEqual([]);
});
test.each([
'FLUXER_REPORT_RETENTION_DAYS',
'FLUXER_RESOLVED_REPORT_RETENTION_DAYS',
'FLUXER_REPORT_RETENTION_DRY_RUN',
])('the worker is handed %s and gets no value when .env leaves it out', (name) => {
expect(serviceEnvironment('worker')[name]).toBe(`\${${name}:-}`);
});
test.each(['FLUXER_REPORT_RETENTION_DAYS', 'FLUXER_REPORT_RETENTION_DRY_RUN'])(
'the worker is handed %s and gets no value when .env leaves it out',
(name) => {
expect(serviceEnvironment('worker')[name]).toBe(`\${${name}:-}`);
},
);
});
@@ -301,7 +301,6 @@ const NAMED_FLUXER_ENV_OVERRIDES: Record<string, NamedEnvOverride> = {
FLUXER_DISCOVERY_MIN_MEMBER_COUNT: {path: ['discovery', 'min_member_count'], parse: parseInteger},
FLUXER_DELETION_GRACE_PERIOD_HOURS: {path: ['deletion_grace_period_hours'], parse: parseInteger},
FLUXER_REPORT_RETENTION_DAYS: {path: ['report_retention', 'days'], parse: parseInteger},
FLUXER_RESOLVED_REPORT_RETENTION_DAYS: {path: ['report_retention', 'resolved_days'], parse: parseInteger},
FLUXER_REPORT_RETENTION_DRY_RUN: {path: ['report_retention', 'dry_run'], parse: parseBoolean},
FLUXER_RELAX_REGISTRATION_RATE_LIMITS: {path: ['dev', 'relax_registration_rate_limits'], parse: parseBoolean},
FLUXER_DISABLE_RATE_LIMITS: {path: ['dev', 'disable_rate_limits'], parse: parseBoolean},