Skip to content

Commit

Permalink
Revert "SlackBuildFeatureHealthReport: prevent log flood by logging o…
Browse files Browse the repository at this point in the history
…nly first failure, others are probably the same due to caching"

This reverts commit b3e0893.
  • Loading branch information
Sagolbah committed Nov 27, 2023
1 parent b3e0893 commit c9dcf1a
Showing 1 changed file with 15 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,58 +68,51 @@ class SlackBuildFeatureHealthReport(
}

override fun report(scope: HealthStatusScope, consumer: HealthStatusItemConsumer) {
val buildTypeItems = mutableListOf<Pair<SBuildType, HealthStatusItem>>()
val templateItems = mutableListOf<Pair<BuildTypeTemplate, HealthStatusItem>>()
try {
for (buildType in scope.buildTypes) {
buildTypeItems.addAll(getStatusItems(buildType))
}
for (buildType in scope.buildTypes) {
report(buildType, consumer)
}

for (buildTemplate in scope.buildTypeTemplates) {
templateItems.addAll(getStatusItems(buildTemplate))
}
} catch (e: SlackResponseError) {
logger.error("Error while generating health report: ${e.message}")
return
for (buildTemplate in scope.buildTypeTemplates) {
report(buildTemplate, consumer)
}
buildTypeItems.forEach { consumer.consumeForBuildType(it.first, it.second) }
templateItems.forEach { consumer.consumeForTemplate(it.first, it.second) }
}

private fun getStatusItems(buildType: SBuildType): List<Pair<SBuildType, HealthStatusItem>> {
private fun report(buildType: SBuildType, consumer: HealthStatusItemConsumer) {
val features = getFeatures(buildType)
val result = mutableListOf<Pair<SBuildType, HealthStatusItem>>()
for (feature in features) {
val statusItem = try {
getHealthStatus(feature, buildType, "buildType")
} catch (e: TimeoutException) {
null
} catch (e: ExecutionException) {
null
} catch (e: SlackResponseError) {
logger.error("Error while generating health report: ${e.message}")
null
}
if (statusItem != null) {
result.add(Pair(buildType, statusItem))
consumer.consumeForBuildType(buildType, statusItem)
}
}
return result
}

private fun getStatusItems(buildTemplate: BuildTypeTemplate): List<Pair<BuildTypeTemplate, HealthStatusItem>> {
private fun report(buildTemplate: BuildTypeTemplate, consumer: HealthStatusItemConsumer) {
val features = getFeatures(buildTemplate)
val result = mutableListOf<Pair<BuildTypeTemplate, HealthStatusItem>>()
for (feature in features) {
val statusItem = try {
getHealthStatus(feature, buildTemplate, "template")
} catch (e: TimeoutException) {
null
} catch (e: ExecutionException) {
null
} catch (e: SlackResponseError) {
logger.error("Error while generating health report: ${e.message}")
null
}
if (statusItem != null) {
result.add(Pair(buildTemplate, statusItem))
consumer.consumeForTemplate(buildTemplate, statusItem)
}
}
return result
}

private fun getFeatures(buildTypeSettings: BuildTypeSettings): List<SBuildFeatureDescriptor> {
Expand Down

0 comments on commit c9dcf1a

Please sign in to comment.