From e5a8f156a756e1662d0a49d94f91291e9768a7bd Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:52:29 +0000 Subject: [PATCH 1/2] Set schedule rule descriptions in SleeperScheduleRule --- .../cdk/stack/GarbageCollectorStack.java | 2 +- .../cdk/stack/PartitionSplittingStack.java | 2 +- .../sleeper/cdk/stack/TableMetricsStack.java | 1 + .../compaction/CompactionJobResources.java | 2 +- .../compaction/CompactionTaskResources.java | 2 +- .../core/TransactionLogSnapshotStack.java | 2 + .../core/TransactionLogTransactionStack.java | 1 + .../cdk/stack/ingest/IngestBatcherStack.java | 2 +- .../sleeper/cdk/stack/ingest/IngestStack.java | 2 +- .../cdk/stack/query/KeepLambdaWarmStack.java | 2 +- .../core/deploy/SleeperScheduleRule.java | 55 +++++++++++-------- 11 files changed, 42 insertions(+), 31 deletions(-) diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/GarbageCollectorStack.java b/java/cdk/src/main/java/sleeper/cdk/stack/GarbageCollectorStack.java index e6b3bef423..34a4ab2bd6 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/GarbageCollectorStack.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/GarbageCollectorStack.java @@ -110,7 +110,7 @@ public GarbageCollectorStack( Rule rule = Rule.Builder .create(this, "GarbageCollectorPeriodicTrigger") .ruleName(SleeperScheduleRule.GARBAGE_COLLECTOR.buildRuleName(instanceProperties)) - .description("A rule to periodically trigger the garbage collector") + .description(SleeperScheduleRule.GARBAGE_COLLECTOR.getDescription()) .enabled(!shouldDeployPaused(this)) .schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(GARBAGE_COLLECTOR_PERIOD_IN_MINUTES)))) .targets(List.of(new LambdaFunction(triggerFunction))) diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/PartitionSplittingStack.java b/java/cdk/src/main/java/sleeper/cdk/stack/PartitionSplittingStack.java index 72fd12e81b..c1031b95ab 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/PartitionSplittingStack.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/PartitionSplittingStack.java @@ -199,7 +199,7 @@ private void createTriggerFunction(InstanceProperties instanceProperties, Lambda Rule rule = Rule.Builder .create(this, "FindPartitionsToSplitPeriodicTrigger") .ruleName(SleeperScheduleRule.PARTITION_SPLITTING.buildRuleName(instanceProperties)) - .description("A rule to periodically trigger the lambda to look for partitions to split") + .description(SleeperScheduleRule.PARTITION_SPLITTING.getDescription()) .enabled(!shouldDeployPaused(this)) .schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(PARTITION_SPLITTING_TRIGGER_PERIOD_IN_MINUTES)))) .targets(List.of(new LambdaFunction(triggerFunction))) diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/TableMetricsStack.java b/java/cdk/src/main/java/sleeper/cdk/stack/TableMetricsStack.java index 1c44e911f7..6a5736948d 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/TableMetricsStack.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/TableMetricsStack.java @@ -92,6 +92,7 @@ public TableMetricsStack( Rule rule = Rule.Builder.create(this, "MetricsPublishSchedule") .ruleName(SleeperScheduleRule.TABLE_METRICS.buildRuleName(instanceProperties)) + .description(SleeperScheduleRule.TABLE_METRICS.getDescription()) .schedule(Schedule.rate(Duration.minutes(1))) .targets(Collections.singletonList(new LambdaFunction(tableMetricsTrigger))) .enabled(!shouldDeployPaused(this)) diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/compaction/CompactionJobResources.java b/java/cdk/src/main/java/sleeper/cdk/stack/compaction/CompactionJobResources.java index 4517bb3f97..4b64dd1404 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/compaction/CompactionJobResources.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/compaction/CompactionJobResources.java @@ -189,7 +189,7 @@ private IFunction lambdaToCreateCompactionJobBatches( Rule rule = Rule.Builder .create(stack, "CompactionJobCreationPeriodicTrigger") .ruleName(SleeperScheduleRule.COMPACTION_JOB_CREATION.buildRuleName(instanceProperties)) - .description("A rule to periodically trigger the compaction job creation lambda") + .description(SleeperScheduleRule.COMPACTION_JOB_CREATION.getDescription()) .enabled(!shouldDeployPaused(stack)) .schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(COMPACTION_JOB_CREATION_LAMBDA_PERIOD_IN_MINUTES)))) .targets(List.of(new LambdaFunction(triggerFunction))) diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/compaction/CompactionTaskResources.java b/java/cdk/src/main/java/sleeper/cdk/stack/compaction/CompactionTaskResources.java index 30819add75..f5ce5fbd46 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/compaction/CompactionTaskResources.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/compaction/CompactionTaskResources.java @@ -175,7 +175,7 @@ private void lambdaToCreateCompactionTasks( Rule rule = Rule.Builder .create(stack, "CompactionTasksCreationPeriodicTrigger") .ruleName(SleeperScheduleRule.COMPACTION_TASK_CREATION.buildRuleName(instanceProperties)) - .description("A rule to periodically trigger the compaction task creation lambda") + .description(SleeperScheduleRule.COMPACTION_TASK_CREATION.getDescription()) .enabled(!shouldDeployPaused(stack)) .schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(COMPACTION_TASK_CREATION_PERIOD_IN_MINUTES)))) .targets(Collections.singletonList(new LambdaFunction(handler))) diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/core/TransactionLogSnapshotStack.java b/java/cdk/src/main/java/sleeper/cdk/stack/core/TransactionLogSnapshotStack.java index eb94895401..780c3ecf88 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/core/TransactionLogSnapshotStack.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/core/TransactionLogSnapshotStack.java @@ -105,6 +105,7 @@ private void createSnapshotCreationLambda(InstanceProperties instanceProperties, Rule rule = Rule.Builder.create(this, "TransactionLogSnapshotCreationSchedule") .ruleName(SleeperScheduleRule.TRANSACTION_LOG_SNAPSHOT_CREATION.buildRuleName(instanceProperties)) + .description(SleeperScheduleRule.TRANSACTION_LOG_SNAPSHOT_CREATION.getDescription()) .schedule(Schedule.rate(Duration.seconds( instanceProperties.getInt(SNAPSHOT_CREATION_LAMBDA_PERIOD_IN_SECONDS)))) .targets(List.of(new LambdaFunction(snapshotCreationTrigger))) @@ -171,6 +172,7 @@ private void createSnapshotDeletionLambda(InstanceProperties instanceProperties, Rule rule = Rule.Builder.create(this, "TransactionLogSnapshotDeletionSchedule") .ruleName(SleeperScheduleRule.TRANSACTION_LOG_SNAPSHOT_DELETION.buildRuleName(instanceProperties)) + .description(SleeperScheduleRule.TRANSACTION_LOG_SNAPSHOT_DELETION.getDescription()) .schedule(Schedule.rate(Duration.minutes( instanceProperties.getLong(SNAPSHOT_DELETION_LAMBDA_PERIOD_IN_MINUTES)))) .targets(List.of(new LambdaFunction(snapshotDeletionTrigger))) diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/core/TransactionLogTransactionStack.java b/java/cdk/src/main/java/sleeper/cdk/stack/core/TransactionLogTransactionStack.java index 34a1f586c0..cec2932967 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/core/TransactionLogTransactionStack.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/core/TransactionLogTransactionStack.java @@ -94,6 +94,7 @@ private void createTransactionDeletionLambda(InstanceProperties instanceProperti Rule rule = Rule.Builder.create(this, "TransactionLogTransactionDeletionSchedule") .ruleName(SleeperScheduleRule.TRANSACTION_LOG_TRANSACTION_DELETION.buildRuleName(instanceProperties)) + .description(SleeperScheduleRule.TRANSACTION_LOG_TRANSACTION_DELETION.getDescription()) .schedule(Schedule.rate(Duration.minutes( instanceProperties.getLong(TRANSACTION_DELETION_LAMBDA_PERIOD_IN_MINUTES)))) .targets(List.of(new LambdaFunction(transactionDeletionTrigger))) diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/ingest/IngestBatcherStack.java b/java/cdk/src/main/java/sleeper/cdk/stack/ingest/IngestBatcherStack.java index 32c425b023..789494874c 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/ingest/IngestBatcherStack.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/ingest/IngestBatcherStack.java @@ -173,7 +173,7 @@ public IngestBatcherStack( Rule rule = Rule.Builder .create(this, "IngestBatcherJobCreationPeriodicTrigger") .ruleName(SleeperScheduleRule.INGEST_BATCHER_JOB_CREATION.buildRuleName(instanceProperties)) - .description("A rule to periodically trigger the ingest batcher job creation lambda") + .description(SleeperScheduleRule.INGEST_BATCHER_JOB_CREATION.getDescription()) .enabled(!shouldDeployPaused(this)) .schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(INGEST_BATCHER_JOB_CREATION_LAMBDA_PERIOD_IN_MINUTES)))) .targets(Collections.singletonList(new LambdaFunction(jobCreatorLambda))) diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/ingest/IngestStack.java b/java/cdk/src/main/java/sleeper/cdk/stack/ingest/IngestStack.java index 1bc68faded..6cbefc7e93 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/ingest/IngestStack.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/ingest/IngestStack.java @@ -277,7 +277,7 @@ private void lambdaToCreateIngestTasks(CoreStacks coreStacks, Queue ingestJobQue Rule rule = Rule.Builder .create(this, "IngestTasksCreationPeriodicTrigger") .ruleName(SleeperScheduleRule.INGEST.buildRuleName(instanceProperties)) - .description("A rule to periodically trigger the ingest tasks lambda") + .description(SleeperScheduleRule.INGEST.getDescription()) .enabled(!shouldDeployPaused(this)) .schedule(Schedule.rate(Duration.minutes(instanceProperties.getInt(INGEST_TASK_CREATION_PERIOD_IN_MINUTES)))) .targets(Collections.singletonList(new LambdaFunction(handler))) diff --git a/java/cdk/src/main/java/sleeper/cdk/stack/query/KeepLambdaWarmStack.java b/java/cdk/src/main/java/sleeper/cdk/stack/query/KeepLambdaWarmStack.java index 71d6335edc..f3dfe62a07 100644 --- a/java/cdk/src/main/java/sleeper/cdk/stack/query/KeepLambdaWarmStack.java +++ b/java/cdk/src/main/java/sleeper/cdk/stack/query/KeepLambdaWarmStack.java @@ -80,7 +80,7 @@ public KeepLambdaWarmStack(Construct scope, Rule rule = Rule.Builder .create(this, "QueryExecutionPeriodicTrigger") .ruleName(SleeperScheduleRule.QUERY_WARM_LAMBDA.buildRuleName(instanceProperties)) - .description("A rule to periodically trigger the query execution lambda") + .description(SleeperScheduleRule.QUERY_WARM_LAMBDA.getDescription()) .enabled(!shouldDeployPaused(this)) .schedule(Schedule.rate(Duration.minutes(instanceProperties .getInt(QUERY_WARM_LAMBDA_EXECUTION_PERIOD_IN_MINUTES)))) diff --git a/java/core/src/main/java/sleeper/core/deploy/SleeperScheduleRule.java b/java/core/src/main/java/sleeper/core/deploy/SleeperScheduleRule.java index 05a73aa040..36fa60c468 100644 --- a/java/core/src/main/java/sleeper/core/deploy/SleeperScheduleRule.java +++ b/java/core/src/main/java/sleeper/core/deploy/SleeperScheduleRule.java @@ -44,50 +44,53 @@ public class SleeperScheduleRule { private static final List RULES = new ArrayList<>(); - // Rule that creates compaction jobs public static final SleeperScheduleRule COMPACTION_JOB_CREATION = add( - COMPACTION_JOB_CREATION_CLOUDWATCH_RULE, "%s-CompactionJobCreationRule"); - // Rule that creates compaction tasks + COMPACTION_JOB_CREATION_CLOUDWATCH_RULE, "%s-CompactionJobCreationRule", + "Triggers creation of compaction jobs for online Sleeper tables"); public static final SleeperScheduleRule COMPACTION_TASK_CREATION = add( - COMPACTION_TASK_CREATION_CLOUDWATCH_RULE, "%s-CompactionTasksCreationRule"); - // Rule that looks for partitions that need splitting + COMPACTION_TASK_CREATION_CLOUDWATCH_RULE, "%s-CompactionTasksCreationRule", + "Triggers scaling compaction tasks to run created jobs"); public static final SleeperScheduleRule PARTITION_SPLITTING = add( - PARTITION_SPLITTING_CLOUDWATCH_RULE, "%s-FindPartitionsToSplitPeriodicTrigger"); - // Rule that triggers garbage collector lambda + PARTITION_SPLITTING_CLOUDWATCH_RULE, "%s-FindPartitionsToSplitPeriodicTrigger", + "Triggers looking for partitions to split in online Sleeper tables"); public static final SleeperScheduleRule GARBAGE_COLLECTOR = add( - GARBAGE_COLLECTOR_CLOUDWATCH_RULE, "%s-GarbageCollectorPeriodicTrigger"); - // Rule that triggers creation of ingest tasks + GARBAGE_COLLECTOR_CLOUDWATCH_RULE, "%s-GarbageCollectorPeriodicTrigger", + "Triggers garbage collection to delete unused files"); public static final SleeperScheduleRule INGEST = add( - INGEST_CLOUDWATCH_RULE, "%s-IngestTasksCreationRule"); - // Rule that batches up ingest jobs from file ingest requests + INGEST_CLOUDWATCH_RULE, "%s-IngestTasksCreationRule", + "Triggers scaling ingest tasks to run queued jobs"); public static final SleeperScheduleRule INGEST_BATCHER_JOB_CREATION = add( - INGEST_BATCHER_JOB_CREATION_CLOUDWATCH_RULE, "%s-IngestBatcherJobCreationRule"); - public static final SleeperScheduleRule TABLE_METRICS = add(TABLE_METRICS_RULE, "%s-MetricsPublishRule"); - // Rule that triggers the query lambdas to keep warm + INGEST_BATCHER_JOB_CREATION_CLOUDWATCH_RULE, "%s-IngestBatcherJobCreationRule", + "Triggers creation of jobs from files submitted to the ingest batcher"); + public static final SleeperScheduleRule TABLE_METRICS = add(TABLE_METRICS_RULE, "%s-MetricsPublishRule", + "Triggers publishing metrics based on the current state of Sleeper tables"); public static final SleeperScheduleRule QUERY_WARM_LAMBDA = add( - QUERY_WARM_LAMBDA_CLOUDWATCH_RULE, "%s-QueryWarmLambdaRule"); - // Rule that triggers transaction log snapshot creation + QUERY_WARM_LAMBDA_CLOUDWATCH_RULE, "%s-QueryWarmLambdaRule", + "Triggers query requests to prevent the system scaling to zero"); public static final SleeperScheduleRule TRANSACTION_LOG_SNAPSHOT_CREATION = add( - TRANSACTION_LOG_SNAPSHOT_CREATION_RULE, "%s-TransactionLogSnapshotCreationRule"); - // Rule that triggers deletion of old transaction log snapshots + TRANSACTION_LOG_SNAPSHOT_CREATION_RULE, "%s-TransactionLogSnapshotCreationRule", + "Triggers creation of snapshots of the current state of online Sleeper tables based on a transaction log"); public static final SleeperScheduleRule TRANSACTION_LOG_SNAPSHOT_DELETION = add( - TRANSACTION_LOG_SNAPSHOT_DELETION_RULE, "%s-TransactionLogSnapshotDeletionRule"); - // Rule that triggers deletion of old transaction log transactions + TRANSACTION_LOG_SNAPSHOT_DELETION_RULE, "%s-TransactionLogSnapshotDeletionRule", + "Triggers deletion of old snapshots of online Sleeper tables based on a transaction log"); public static final SleeperScheduleRule TRANSACTION_LOG_TRANSACTION_DELETION = add( - TRANSACTION_LOG_TRANSACTION_DELETION_RULE, "%s-TransactionLogTransactionDeletionRule"); + TRANSACTION_LOG_TRANSACTION_DELETION_RULE, "%s-TransactionLogTransactionDeletionRule", + "Triggers deletion of old transactions from the active transaction logs of online Sleeper tables"); private final InstanceProperty property; private final String nameFormat; + private final String description; - private static SleeperScheduleRule add(InstanceProperty property, String nameFormat) { - SleeperScheduleRule rule = new SleeperScheduleRule(property, nameFormat); + private static SleeperScheduleRule add(InstanceProperty property, String nameFormat, String description) { + SleeperScheduleRule rule = new SleeperScheduleRule(property, nameFormat, description); RULES.add(rule); return rule; } - private SleeperScheduleRule(InstanceProperty property, String nameFormat) { + private SleeperScheduleRule(InstanceProperty property, String nameFormat, String description) { this.property = requireNonNull(property, "property must not be null"); this.nameFormat = requireNonNull(nameFormat, "nameFormat must not be null"); + this.description = requireNonNull(description, "description must not be null"); } /** @@ -171,6 +174,10 @@ public InstanceProperty getProperty() { return property; } + public String getDescription() { + return description; + } + /** * A wrapper for the instance property value for this CloudWatch rule. */ From d173e3ee99960bb137e88632c45f09118097e300 Mon Sep 17 00:00:00 2001 From: patchwork01 <110390516+patchwork01@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:56:01 +0000 Subject: [PATCH 2/2] Set CloudWatch alarm names to match DLQ --- java/cdk/src/main/java/sleeper/cdk/util/Utils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/cdk/src/main/java/sleeper/cdk/util/Utils.java b/java/cdk/src/main/java/sleeper/cdk/util/Utils.java index 11c17d7073..8cf72deb5f 100644 --- a/java/cdk/src/main/java/sleeper/cdk/util/Utils.java +++ b/java/cdk/src/main/java/sleeper/cdk/util/Utils.java @@ -286,6 +286,7 @@ public static String normaliseSize(String size) { public static void createAlarmForDlq(Construct scope, String id, String description, Queue dlq, Topic topic) { Alarm alarm = Alarm.Builder .create(scope, id) + .alarmName(dlq.getQueueName()) .alarmDescription(description) .metric(dlq.metricApproximateNumberOfMessagesVisible() .with(MetricOptions.builder().statistic("Sum").period(Duration.seconds(60)).build()))