Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ecs): Cloudwatch alarms cleanup on destroy ecs group #6315

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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
Loading