Skip to content

Commit 369424a

Browse files
committed
bug 1400258 - write cot verification logs to live_backing.log
Fixes #179.
1 parent 764816a commit 369424a

File tree

4 files changed

+3
-13
lines changed

4 files changed

+3
-13
lines changed

src/scriptworker/cot/verify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1912,7 +1912,7 @@ async def verify_chain_of_trust(chain, *, check_task=False):
19121912
CoTError: on failure
19131913
19141914
"""
1915-
log_path = os.path.join(chain.context.config["task_log_dir"], "chain_of_trust.log")
1915+
log_path = os.path.join(chain.context.config["task_log_dir"], "live_backing.log")
19161916
scriptworker_log = logging.getLogger("scriptworker")
19171917
with contextual_log_handler(
19181918
chain.context,

src/scriptworker/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def get_log_filehandle(context: Any) -> Iterator[IO[str]]:
113113
"""
114114
log_file_name = get_log_filename(context)
115115
makedirs(context.config["task_log_dir"])
116-
with open(log_file_name, "w", encoding="utf-8") as filehandle:
116+
with open(log_file_name, "a", encoding="utf-8") as filehandle:
117117
yield filehandle
118118

119119

src/scriptworker/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async def invoke(self, context):
136136
status = await do_run_task(context, self._run_cancellable, self._to_cancellable_process)
137137
artifacts_paths = filepaths_in_dir(context.config["artifact_dir"])
138138
except WorkerShutdownDuringTask:
139-
shutdown_artifact_paths = [os.path.join("public", "logs", log_file) for log_file in ["chain_of_trust.log", "live_backing.log"]]
139+
shutdown_artifact_paths = [os.path.join("public", "logs", log_file) for log_file in ["live_backing.log"]]
140140
artifacts_paths = [path for path in shutdown_artifact_paths if os.path.isfile(os.path.join(context.config["artifact_dir"], path))]
141141
status = STATUSES["worker-shutdown"]
142142
status = worst_level(status, await do_upload(context, artifacts_paths))

tests/test_integration.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,8 @@ async def test_shutdown():
262262
async with get_context(partial_config) as context:
263263
result = await create_task(context, task_id, task_id)
264264
assert result["status"]["state"] == "pending"
265-
fake_cot_log = os.path.join(context.config["artifact_dir"], "public", "logs", "chain_of_trust.log")
266265
fake_other_artifact = os.path.join(context.config["artifact_dir"], "public", "artifact.apk")
267266

268-
with open(fake_cot_log, "w") as file:
269-
file.write("CoT logs")
270267
with open(fake_other_artifact, "w") as file:
271268
file.write("unrelated artifact")
272269
cancel_fut = asyncio.ensure_future(do_shutdown(context))
@@ -277,24 +274,17 @@ async def test_shutdown():
277274
assert status["status"]["runs"][0]["state"] == "exception"
278275
assert status["status"]["runs"][0]["reasonResolved"] == "worker-shutdown"
279276
log_url = context.queue.buildUrl("getArtifact", task_id, 0, "public/logs/live_backing.log")
280-
cot_log_url = context.queue.buildUrl("getArtifact", task_id, 0, "public/logs/chain_of_trust.log")
281277
other_artifact_url = context.queue.buildUrl("getArtifact", task_id, 0, "public/artifact.apk")
282278
log_path = os.path.join(context.config["work_dir"], "log")
283-
cot_log_path = os.path.join(context.config["work_dir"], "cot_log")
284279
other_artifact_path = os.path.join(context.config["work_dir"], "artifact.apk")
285280
await utils.download_file(context, log_url, log_path)
286-
await utils.download_file(context, cot_log_url, cot_log_path)
287281
with pytest.raises(Download404):
288282
await utils.download_file(context, other_artifact_url, other_artifact_path)
289283

290284
with open(log_path) as fh:
291285
contents = fh.read()
292286
assert contents.rstrip() == "running task script\nAutomation Error: python exited with signal -15"
293287

294-
with open(cot_log_path) as fh:
295-
contents = fh.read()
296-
assert contents.rstrip() == "CoT logs"
297-
298288

299289
# empty_queue {{{1
300290
@pytest.mark.parametrize("context_function", [get_context, get_temp_creds_context])

0 commit comments

Comments
 (0)