From 970680d1e103d317b99a07be33dcb45baf2d00f0 Mon Sep 17 00:00:00 2001 From: Maciej Kwidzinski Date: Wed, 3 Jan 2024 17:59:15 +0100 Subject: [PATCH] Fix always reporting fail even on success Avoid false-positives like (notice lack of stacktrace logging too): ``` 16:36:00,592 ERROR {} Ec2Instance(instanceId = i-080edd5933a74418f) failed to release itself 16:36:30,577 ERROR {} Ec2Instance(instanceId = i-061f9c1f94990848e) failed to release itself ``` --- CHANGELOG.md | 1 + .../tools/aws/api/housekeeping/ConcurrentHousekeeping.kt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c97020..cd1d4c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ Dropping a requirement of a major version of a dependency is a new contract. - Add missing `iam:GetRole` permission. You have to update the policy manually. Fix [JPERF-1407]. - Reduce pressure on CloudFormation when cleaning long lists of expired stacks. Help [JPERF-1332]. - Clean up EC2 security groups before CloudFormation stacks. Fix [JPERF-1208]. +- Fix housekeeping fail logging. [JPERF-1407]: https://ecosystem.atlassian.net/browse/JPERF-1407 [JPERF-1332]: https://ecosystem.atlassian.net/browse/JPERF-1332 diff --git a/src/main/kotlin/com/atlassian/performance/tools/aws/api/housekeeping/ConcurrentHousekeeping.kt b/src/main/kotlin/com/atlassian/performance/tools/aws/api/housekeeping/ConcurrentHousekeeping.kt index 403666d..32fbc9d 100644 --- a/src/main/kotlin/com/atlassian/performance/tools/aws/api/housekeeping/ConcurrentHousekeeping.kt +++ b/src/main/kotlin/com/atlassian/performance/tools/aws/api/housekeeping/ConcurrentHousekeeping.kt @@ -57,7 +57,7 @@ class ConcurrentHousekeeping( if (!resource.isExpired()) { throw Exception("You can't release $resource. It hasn't expired.") } - return resource.release().handle { throwable, _ -> + return resource.release().handle { _, throwable: Throwable? -> if (throwable != null) { logger.error("$resource failed to release itself", throwable) }