@@ -168,6 +168,13 @@ async def get_build_logs(job_name: str, build_id: str) -> dict:
168
168
async def get_install_logs (job_name : str , build_id : str , test_name : str ):
169
169
"""Get the install logs for a specific build ID and job name.
170
170
171
+ This function looks specifically in the installation directories:
172
+ <job_name>/<build_id>/artifacts/<test_name>/<ipi-install-*>/
173
+
174
+ It tries multiple installation directory patterns:
175
+ - ipi-install-install
176
+ - ipi-install-install-stableinitial
177
+
171
178
Args:
172
179
job_name: The name of the job
173
180
build_id: The build ID for which to get install logs
@@ -176,35 +183,58 @@ async def get_install_logs(job_name: str, build_id: str, test_name: str):
176
183
Returns:
177
184
Dictionary containing the job metadata(job_name, build_id, test_name), installation logs or error information
178
185
"""
179
- try :
180
- # Construct the artifacts URL
181
- artifacts_url = f"{ GCS_URL } /{ job_name } /{ build_id } /artifacts"
182
-
183
- async with httpx .AsyncClient () as client :
184
- response = await client .get (f"{ artifacts_url } /{ test_name } /ipi-install-install/finished.json" )
185
- response .raise_for_status ()
186
- json_resp = response .json ()
187
- result = json_resp ["result" ]
188
- passed = json_resp ["passed" ]
189
-
190
- async with httpx .AsyncClient () as client :
191
- response = await client .get (f"{ artifacts_url } /{ test_name } /ipi-install-install/build-log.txt" )
192
- response .raise_for_status ()
193
- logs = response .text
194
- return {
195
- "build_id" : build_id ,
196
- "job_name" : job_name ,
197
- "test_name" : test_name ,
198
- "passed" : passed ,
199
- "result" : result ,
200
- "logs" : logs ,
201
- "artifacts_url" : artifacts_url
202
- }
203
- except Exception as e :
204
- return {
205
- "error" : f"Failed to fetch logs: { str (e )} " ,
206
- "artifacts_url" : artifacts_url if 'artifacts_url' in locals () else None
207
- }
186
+ # List of possible installation directory patterns
187
+ install_dirs = [
188
+ "ipi-install-install" ,
189
+ "ipi-install-install-stableinitial"
190
+ ]
191
+
192
+ # Construct the base artifacts URL
193
+ artifacts_url = f"{ GCS_URL } /{ job_name } /{ build_id } /artifacts"
194
+
195
+ # Try each installation directory pattern
196
+ for install_dir in install_dirs :
197
+ try :
198
+ async with httpx .AsyncClient () as client :
199
+ # Try to get finished.json from this installation directory
200
+ finished_url = f"{ artifacts_url } /{ test_name } /{ install_dir } /finished.json"
201
+ response = await client .get (finished_url )
202
+ response .raise_for_status ()
203
+ json_resp = response .json ()
204
+ result = json_resp ["result" ]
205
+ passed = json_resp ["passed" ]
206
+
207
+ async with httpx .AsyncClient () as client :
208
+ # Get build-log.txt from the same installation directory
209
+ log_url = f"{ artifacts_url } /{ test_name } /{ install_dir } /build-log.txt"
210
+ response = await client .get (log_url )
211
+ response .raise_for_status ()
212
+ logs = response .text
213
+
214
+ return {
215
+ "build_id" : build_id ,
216
+ "job_name" : job_name ,
217
+ "test_name" : test_name ,
218
+ "install_dir" : install_dir ,
219
+ "passed" : passed ,
220
+ "result" : result ,
221
+ "logs" : logs ,
222
+ "artifacts_url" : artifacts_url ,
223
+ "log_url" : log_url
224
+ }
225
+ except Exception as e :
226
+ # Continue to try the next directory pattern
227
+ continue
228
+
229
+ # If none of the patterns worked, return an error
230
+ return {
231
+ "error" : f"Failed to fetch install logs from any installation directory. Tried: { ', ' .join (install_dirs )} " ,
232
+ "build_id" : build_id ,
233
+ "job_name" : job_name ,
234
+ "test_name" : test_name ,
235
+ "artifacts_url" : artifacts_url ,
236
+ "tried_directories" : [f"{ artifacts_url } /{ test_name } /{ d } " for d in install_dirs ]
237
+ }
208
238
209
239
210
240
0 commit comments