Skip to content

Commit e40a844

Browse files
author
Richard Kuo (Danswer)
committed
handle more codes
1 parent b257d85 commit e40a844

File tree

1 file changed

+13
-2
lines changed
  • backend/onyx/background/celery/tasks/indexing

1 file changed

+13
-2
lines changed

backend/onyx/background/celery/tasks/indexing/tasks.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,33 +107,42 @@ class IndexingWatchdogTerminalStatus(str, Enum):
107107
# the watchdog terminated the task due to no activity
108108
TERMINATED_BY_ACTIVITY_TIMEOUT = "terminated_by_activity_timeout"
109109

110+
OUT_OF_MEMORY = "out_of_memory"
111+
110112
@property
111113
def code(self) -> int:
112114
_ENUM_TO_CODE: dict[IndexingWatchdogTerminalStatus, int] = {
115+
IndexingWatchdogTerminalStatus.OUT_OF_MEMORY: 137,
113116
IndexingWatchdogTerminalStatus.BLOCKED_BY_DELETION: 248,
114117
IndexingWatchdogTerminalStatus.BLOCKED_BY_STOP_SIGNAL: 249,
115118
IndexingWatchdogTerminalStatus.FENCE_NOT_FOUND: 250,
116119
IndexingWatchdogTerminalStatus.FENCE_READINESS_TIMEOUT: 251,
117120
IndexingWatchdogTerminalStatus.FENCE_MISMATCH: 252,
118121
IndexingWatchdogTerminalStatus.TASK_ALREADY_RUNNING: 253,
119122
IndexingWatchdogTerminalStatus.INDEX_ATTEMPT_MISMATCH: 254,
123+
IndexingWatchdogTerminalStatus.CONNECTOR_EXCEPTIONED: 255,
120124
}
121125

122126
return _ENUM_TO_CODE[self]
123127

124128
@classmethod
125129
def from_code(cls, code: int) -> "IndexingWatchdogTerminalStatus":
126130
_CODE_TO_ENUM: dict[int, IndexingWatchdogTerminalStatus] = {
131+
137: IndexingWatchdogTerminalStatus.OUT_OF_MEMORY,
127132
248: IndexingWatchdogTerminalStatus.BLOCKED_BY_DELETION,
128133
249: IndexingWatchdogTerminalStatus.BLOCKED_BY_STOP_SIGNAL,
129134
250: IndexingWatchdogTerminalStatus.FENCE_NOT_FOUND,
130135
251: IndexingWatchdogTerminalStatus.FENCE_READINESS_TIMEOUT,
131136
252: IndexingWatchdogTerminalStatus.FENCE_MISMATCH,
132137
253: IndexingWatchdogTerminalStatus.TASK_ALREADY_RUNNING,
133138
254: IndexingWatchdogTerminalStatus.INDEX_ATTEMPT_MISMATCH,
139+
255: IndexingWatchdogTerminalStatus.CONNECTOR_EXCEPTIONED,
134140
}
135141

136-
return _CODE_TO_ENUM[code]
142+
if code in _CODE_TO_ENUM:
143+
return _CODE_TO_ENUM[code]
144+
145+
return IndexingWatchdogTerminalStatus.UNDEFINED
137146

138147

139148
class SimpleJobResult:
@@ -832,7 +841,9 @@ def process_job_result(
832841
)
833842
)
834843
else:
835-
result.status = IndexingWatchdogTerminalStatus.CONNECTOR_EXCEPTIONED
844+
if result.exit_code is not None:
845+
result.status = IndexingWatchdogTerminalStatus.from_code(result.exit_code)
846+
836847
result.exception_str = job.exception()
837848

838849
return result

0 commit comments

Comments
 (0)