Skip to content

Commit 8190bb0

Browse files
committed
chore: make resource error as external error message (#13971)
1 parent 54849f2 commit 8190bb0

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

airbyte-commons-worker/src/main/java/io/airbyte/workers/helper/FailureHelper.java

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import io.airbyte.config.Metadata;
1515
import io.airbyte.config.StreamDescriptor;
1616
import io.airbyte.protocol.models.AirbyteTraceMessage;
17+
import io.airbyte.workers.exception.ResourceConstraintException;
1718
import io.airbyte.workers.exception.WorkloadLauncherException;
1819
import io.airbyte.workers.exception.WorkloadMonitorException;
1920
import java.util.Comparator;
@@ -294,6 +295,11 @@ public static FailureReason checkFailure(final Throwable t,
294295
public static FailureReason replicationFailure(final Throwable t, final Long jobId, final Integer attemptNumber) {
295296
final FailureReason failure = genericFailure(t, jobId, attemptNumber)
296297
.withFailureOrigin(FailureOrigin.REPLICATION);
298+
if (isInstanceOf(t, ResourceConstraintException.class)) {
299+
return failure.withFailureType(FailureType.TRANSIENT_ERROR)
300+
.withExternalMessage("Airbyte could not start the sync process."
301+
+ " This may be due to insufficient system resources. Please check available resources and try again.");
302+
}
297303
if (isInstanceOf(t, WorkloadLauncherException.class)) {
298304
return failure.withFailureType(FailureType.TRANSIENT_ERROR)
299305
.withExternalMessage("Airbyte could not start the sync process.");

airbyte-workload-launcher/src/main/kotlin/pods/KubeClientException.kt renamed to airbyte-commons-worker/src/main/kotlin/io/airbyte/workers/exception/KubeClientException.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package io.airbyte.workload.launcher.pods
1+
package io.airbyte.workers.exception
22

3-
class KubeClientException(
3+
open class KubeClientException(
44
override val message: String,
55
override val cause: Throwable,
66
val commandType: KubeCommandType,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package io.airbyte.workers.exception
2+
3+
class ResourceConstraintException(message: String, cause: Throwable, commandType: KubeCommandType, podType: PodType? = null) :
4+
KubeClientException(message, cause, commandType, podType)

airbyte-workload-launcher/src/main/kotlin/pipeline/handlers/FailureHandler.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ package io.airbyte.workload.launcher.pipeline.handlers
66

77
import io.airbyte.metrics.lib.ApmTraceUtils
88
import io.airbyte.metrics.lib.MetricAttribute
9+
import io.airbyte.workers.exception.KubeClientException
910
import io.airbyte.workload.launcher.client.WorkloadApiClient
1011
import io.airbyte.workload.launcher.metrics.CustomMetricPublisher
1112
import io.airbyte.workload.launcher.metrics.MeterFilterFactory
1213
import io.airbyte.workload.launcher.metrics.WorkloadLauncherMetricMetadata
1314
import io.airbyte.workload.launcher.pipeline.stages.model.LaunchStageIO
1415
import io.airbyte.workload.launcher.pipeline.stages.model.StageError
15-
import io.airbyte.workload.launcher.pods.KubeClientException
1616
import io.github.oshai.kotlinlogging.KotlinLogging
1717
import io.github.oshai.kotlinlogging.withLoggingContext
1818
import jakarta.inject.Named

airbyte-workload-launcher/src/main/kotlin/pods/KubePodClient.kt

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import io.airbyte.featureflag.Multi
1010
import io.airbyte.featureflag.Workspace
1111
import io.airbyte.metrics.lib.ApmTraceUtils
1212
import io.airbyte.persistence.job.models.ReplicationInput
13+
import io.airbyte.workers.exception.KubeClientException
14+
import io.airbyte.workers.exception.KubeCommandType
15+
import io.airbyte.workers.exception.PodType
16+
import io.airbyte.workers.exception.ResourceConstraintException
1317
import io.airbyte.workers.models.CheckConnectionInput
1418
import io.airbyte.workers.models.DiscoverCatalogInput
1519
import io.airbyte.workers.models.SpecInput
@@ -265,7 +269,7 @@ class KubePodClient(
265269
when (e) {
266270
is TimeoutException, is KubernetesClientTimeoutException -> {
267271
ApmTraceUtils.addExceptionToTrace(e)
268-
throw KubeClientException(
272+
throw ResourceConstraintException(
269273
"Unable to start the $podLogLabel pod. This may be due to insufficient system resources. Please check available resources and try again.",
270274
e,
271275
KubeCommandType.WAIT_INIT,

airbyte-workload-launcher/src/test/kotlin/pods/KubePodClientTest.kt

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import io.airbyte.featureflag.TestClient
1515
import io.airbyte.persistence.job.models.IntegrationLauncherConfig
1616
import io.airbyte.persistence.job.models.JobRunConfig
1717
import io.airbyte.persistence.job.models.ReplicationInput
18+
import io.airbyte.workers.exception.KubeClientException
19+
import io.airbyte.workers.exception.KubeCommandType
20+
import io.airbyte.workers.exception.PodType
1821
import io.airbyte.workers.models.CheckConnectionInput
1922
import io.airbyte.workers.models.DiscoverCatalogInput
2023
import io.airbyte.workers.models.SpecInput

0 commit comments

Comments
 (0)