Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class DataRetention extends AbstractNativeApplication {
private final EntityTimeSeriesDAO testCaseResultsDAO;
private final EntityTimeSeriesDAO profileDataDAO;
private final CollectionDAO.AuditLogDAO auditLogDAO;
private final CollectionDAO.WorkflowDAO workflowDAO;

public DataRetention(CollectionDAO collectionDAO, SearchRepository searchRepository) {
super(collectionDAO, searchRepository);
Expand All @@ -59,6 +60,7 @@ public DataRetention(CollectionDAO collectionDAO, SearchRepository searchReposit
this.testCaseResultsDAO = collectionDAO.testCaseResultTimeSeriesDao();
this.profileDataDAO = collectionDAO.profilerDataTimeSeriesDao();
this.auditLogDAO = collectionDAO.auditLogDAO();
this.workflowDAO = collectionDAO.workflowDAO();
}

@Override
Expand Down Expand Up @@ -122,6 +124,7 @@ private void initializeStatsDefaults() {
entityStats.withAdditionalProperty("broken_search_entities", new StepStats());
entityStats.withAdditionalProperty("orphaned_tag_usages", new StepStats());
entityStats.withAdditionalProperty("audit_logs", new StepStats());
entityStats.withAdditionalProperty("reverse_ingestion_workflows", new StepStats());

retentionStats.setEntityStats(entityStats);
}
Expand Down Expand Up @@ -166,6 +169,13 @@ public void executeCleanup(DataRetentionConfiguration config) {
LOG.info(
"Starting cleanup for audit logs with retention period: {} days.", auditLogRetentionPeriod);
cleanAuditLogs(auditLogRetentionPeriod);

int reverseIngestionWorkflowRetentionPeriod =
Comment thread
Siddhanttimeline marked this conversation as resolved.
config.getReverseIngestionWorkflowRetentionPeriod();
LOG.info(
"Starting cleanup for reverse ingestion workflows with retention period: {} days.",
reverseIngestionWorkflowRetentionPeriod);
cleanReverseIngestionWorkflows(reverseIngestionWorkflowRetentionPeriod);
}

@Transaction
Expand Down Expand Up @@ -308,6 +318,19 @@ private void cleanAuditLogs(int retentionPeriod) {
LOG.info("Audit logs cleanup complete.");
}

@Transaction
private void cleanReverseIngestionWorkflows(int retentionPeriod) {
LOG.info(
"Initiating reverse ingestion workflows cleanup: Retention = {} days.", retentionPeriod);
long cutoffMillis = getRetentionCutoffMillis(retentionPeriod);

executeWithStatsTracking(
"reverse_ingestion_workflows",
() -> workflowDAO.deleteReverseIngestionWorkflowsBeforeCutoff(cutoffMillis, BATCH_SIZE));

LOG.info("Reverse ingestion workflows cleanup complete.");
}

private void executeWithStatsTracking(String entity, Supplier<Integer> deleteFunction) {
int totalDeleted = 0;
int totalFailed = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8954,6 +8954,33 @@ default Class<Workflow> getEntityClass() {
return Workflow.class;
}

@ConnectionAwareSqlUpdate(
Comment thread
gitar-bot[bot] marked this conversation as resolved.
value =
"DELETE FROM automations_workflow "
+ "WHERE id IN ( "
+ " SELECT id FROM ( "
+ " SELECT id FROM automations_workflow "
+ " WHERE workflowType = 'REVERSE_INGESTION' "
+ " AND status IN ('Successful', 'Failed') "
+ " AND updatedAt < :cutoffTs "
+ " ORDER BY updatedAt LIMIT :limit "
+ " ) AS sub "
+ ")",
connectionType = MYSQL)
@ConnectionAwareSqlUpdate(
value =
"DELETE FROM automations_workflow "
+ "WHERE ctid IN ( "
+ " SELECT ctid FROM automations_workflow "
+ " WHERE workflowtype = 'REVERSE_INGESTION' "
+ " AND status IN ('Successful', 'Failed') "
+ " AND updatedat < :cutoffTs "
+ " ORDER BY updatedat LIMIT :limit "
+ ")",
connectionType = POSTGRES)
int deleteReverseIngestionWorkflowsBeforeCutoff(
@Bind("cutoffTs") long cutoffTs, @Bind("limit") int limit);

@Override
default List<String> listBefore(
ListFilter filter, int limit, String beforeName, String beforeId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"changeEventRetentionPeriod": 7,
"activityThreadsRetentionPeriod": 60,
"profileDataRetentionPeriod": 1440,
"testCaseResultsRetentionPeriod": 1440
"testCaseResultsRetentionPeriod": 1440,
"auditLogRetentionPeriod": 90,
"reverseIngestionWorkflowRetentionPeriod": 30
},
"appSchedule": {
"scheduleTimeline": "Custom",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Comment thread
gitar-bot[bot] marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,22 @@
"type": "integer",
"default": 90,
"minimum": 1
},
"reverseIngestionWorkflowRetentionPeriod": {
"title": "Reverse Ingestion Workflow Retention Period (days)",
"description": "Enter the retention period for Reverse Ingestion workflows in days (e.g., 7 for one week, 30 for one month).",
"type": "integer",
"default": 30,
"minimum": 1
}
},
"required": [
"changeEventRetentionPeriod", "activityThreadsRetentionPeriod", "testCaseResultsRetentionPeriod", "profileDataRetentionPeriod", "auditLogRetentionPeriod"
"changeEventRetentionPeriod",
"activityThreadsRetentionPeriod",
"testCaseResultsRetentionPeriod",
"profileDataRetentionPeriod",
"auditLogRetentionPeriod",
"reverseIngestionWorkflowRetentionPeriod"
],
"additionalProperties": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,18 @@ $$section

Enter the retention period for Profile Data in days (e.g., 30 for one month, 60 for two months).

$$

$$section
### Audit Log Retention Period (days) $(id="auditLogRetentionPeriod")

Enter the retention period for Audit Log entries in days (e.g., 90 for three months).

$$

$$section
### Reverse Ingestion Workflow Retention Period (days) $(id="reverseIngestionWorkflowRetentionPeriod")

Enter the retention period for Reverse Ingestion workflows in days (e.g., 7 for one week, 30 for one month).

$$
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ export interface DataRetentionConfigurationClass {
* two months).
*/
testCaseResultsRetentionPeriod: number;
/**
* Enter the retention period for Audit Log entries in days (e.g., 90 for three months).
*/
auditLogRetentionPeriod: number;
/**
* Enter the retention period for Reverse Ingestion workflows in days (e.g., 7 for one week, 30
* for one month).
*/
reverseIngestionWorkflowRetentionPeriod: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,29 @@
"description": "Enter the retention period for Profile Data in days (e.g., 30 for one month, 60 for two months).",
"type": "integer",
"default": 1440
},
"auditLogRetentionPeriod": {
"title": "Audit Log Retention Period (days)",
"description": "Enter the retention period for Audit Log entries in days (e.g., 90 for three months).",
"type": "integer",
"default": 90,
"minimum": 1
},
"reverseIngestionWorkflowRetentionPeriod": {
"title": "Reverse Ingestion Workflow Retention Period (days)",
"description": "Enter the retention period for Reverse Ingestion workflows in days (e.g., 7 for one week, 30 for one month).",
"type": "integer",
"default": 30,
"minimum": 1
}
},
"required": [
"changeEventRetentionPeriod",
"activityThreadsRetentionPeriod",
"testCaseResultsRetentionPeriod",
"profileDataRetentionPeriod"
"profileDataRetentionPeriod",
"auditLogRetentionPeriod",
"reverseIngestionWorkflowRetentionPeriod"
],
"additionalProperties": false
}
Loading