Skip to content

Commit

Permalink
fix(ecs): Cloudwatch alarms cleanup on destroy ecs group
Browse files Browse the repository at this point in the history
  • Loading branch information
christosarvanitis committed Dec 12, 2024
1 parent 7ce44a3 commit 2487e0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class EcsCloudMetricService {
public void deleteMetrics(
String serviceName, String account, String region, String ecsClusterName) {
List<EcsMetricAlarm> metricAlarms =
metricAlarmCacheClient.getMetricAlarms(ecsClusterName, serviceName, account, region);
metricAlarmCacheClient.getMetricAlarms(serviceName, account, region, ecsClusterName);

if (metricAlarms.isEmpty()) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package com.netflix.spinnaker.clouddriver.ecs.services
import com.amazonaws.services.applicationautoscaling.AWSApplicationAutoScaling
import com.amazonaws.services.applicationautoscaling.model.*
import com.amazonaws.services.cloudwatch.AmazonCloudWatch
import com.amazonaws.services.cloudwatch.model.DeleteAlarmsRequest
import com.amazonaws.services.cloudwatch.model.DescribeAlarmsResult
import com.amazonaws.services.cloudwatch.model.Dimension
import com.amazonaws.services.cloudwatch.model.MetricAlarm
Expand Down Expand Up @@ -409,17 +410,20 @@ class EcsCloudMetricServiceSpec extends Specification {
5.times {
metricAlarms << new EcsMetricAlarm(
accountName: targetAccountName,
region: targetRegion
region: targetRegion,
alarmName: "alarm-name-${it}"
)
}

metricAlarmCacheClient.getMetricAlarms(_, _,_ ,_) >> metricAlarms
metricAlarmCacheClient.getMetricAlarms(targetServiceName,targetAccountName,targetRegion,clusterName) >> metricAlarms

when:
service.deleteMetrics(targetServiceName, targetAccountName, targetRegion, clusterName)

then:
1 * targetCloudWatch.deleteAlarms(_)
1 * targetCloudWatch.deleteAlarms({ DeleteAlarmsRequest request ->
request.alarmNames.sort() == metricAlarms*.alarmName.sort()
})
}


Expand Down

0 comments on commit 2487e0d

Please sign in to comment.