From e19ecaaf687f73780f690ea99782068b28445d43 Mon Sep 17 00:00:00 2001 From: Victor Lyuboslavsky <2685025+getvictor@users.noreply.github.com> Date: Fri, 10 Apr 2026 17:00:02 -0400 Subject: [PATCH] Fixed connection exhaustion causing DNS issues (#43402) **Related issue:** Resolves #42624 Fix for unreleased bug ## Testing - [x] QA'd all new/changed functionality manually For unreleased bug fixes in a release candidate, one of: - [x] Confirmed that the fix is not expected to adversely impact load test results ## Summary by CodeRabbit * **Bug Fixes** * Adjusted certificate enrollment to process sequentially, ensuring proper handling and reducing potential race conditions. --- .../com/fleetdm/agent/CertificateOrchestrator.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/android/app/src/main/java/com/fleetdm/agent/CertificateOrchestrator.kt b/android/app/src/main/java/com/fleetdm/agent/CertificateOrchestrator.kt index 79894518eb..fed584a5a6 100644 --- a/android/app/src/main/java/com/fleetdm/agent/CertificateOrchestrator.kt +++ b/android/app/src/main/java/com/fleetdm/agent/CertificateOrchestrator.kt @@ -16,8 +16,6 @@ import java.time.Instant import java.util.Date import java.util.Locale import java.util.TimeZone -import kotlinx.coroutines.async -import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.map @@ -822,7 +820,9 @@ class CertificateOrchestrator( } /** - * Enrolls multiple certificates in parallel. + * Enrolls multiple certificates sequentially. Each enrollment involves multiple HTTP calls + * (template fetch, SCEP enrollment, status update), so sequential processing avoids + * overwhelming the server and the device's network stack. * * @param context Android context for certificate installation * @param hostCertificates List of certificate templates to enroll @@ -832,14 +832,12 @@ class CertificateOrchestrator( context: Context, hostCertificates: List, certificateInstaller: CertificateEnrollmentHandler.CertificateInstaller? = null, - ): Map = coroutineScope { + ): Map { Log.d(TAG, "Starting batch certificate enrollment for ${hostCertificates.size} certificates") - hostCertificates.associate { cert -> - cert.id to async { - enrollCertificate(context, cert.id, cert.uuid, certificateInstaller) - } - }.mapValues { it.value.await() } + return hostCertificates.associate { cert -> + cert.id to enrollCertificate(context, cert.id, cert.uuid, certificateInstaller) + } } /**