Skip to content

Commit cee8b2e

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

File tree

5 files changed

+6
-18
lines changed

5 files changed

+6
-18
lines changed

scriptworker/cot/verify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@ async def verify_chain_of_trust(chain):
21142114
CoTError: on failure
21152115
21162116
"""
2117-
log_path = os.path.join(chain.context.config["task_log_dir"], "chain_of_trust.log")
2117+
log_path = os.path.join(chain.context.config["task_log_dir"], "live_backing.log")
21182118
scriptworker_log = logging.getLogger('scriptworker')
21192119
with contextual_log_handler(
21202120
chain.context, path=log_path, log_obj=scriptworker_log,

scriptworker/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def get_log_filehandle(context):
112112
"""
113113
log_file_name = get_log_filename(context)
114114
makedirs(context.config['task_log_dir'])
115-
with open(log_file_name, "w", encoding="utf-8") as filehandle:
115+
with open(log_file_name, "a", encoding="utf-8") as filehandle:
116116
yield filehandle
117117

118118

scriptworker/test/test_integration.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,8 @@ async def test_shutdown():
264264
async with get_context(partial_config) as context:
265265
result = await create_task(context, task_id, task_id)
266266
assert result['status']['state'] == 'pending'
267-
fake_cot_log = os.path.join(context.config['artifact_dir'], 'public', 'logs', 'chain_of_trust.log')
268267
fake_other_artifact = os.path.join(context.config['artifact_dir'], 'public', 'artifact.apk')
269268

270-
with open(fake_cot_log, 'w') as file:
271-
file.write('CoT logs')
272269
with open(fake_other_artifact, 'w') as file:
273270
file.write('unrelated artifact')
274271
cancel_fut = asyncio.ensure_future(do_shutdown(context))
@@ -281,28 +278,19 @@ async def test_shutdown():
281278
log_url = context.queue.buildUrl(
282279
'getArtifact', task_id, 0, 'public/logs/live_backing.log'
283280
)
284-
cot_log_url = context.queue.buildUrl(
285-
'getArtifact', task_id, 0, 'public/logs/chain_of_trust.log'
286-
)
287281
other_artifact_url = context.queue.buildUrl(
288282
'getArtifact', task_id, 0, 'public/artifact.apk'
289283
)
290284
log_path = os.path.join(context.config['work_dir'], 'log')
291-
cot_log_path = os.path.join(context.config['work_dir'], 'cot_log')
292285
other_artifact_path = os.path.join(context.config['work_dir'], 'artifact.apk')
293286
await utils.download_file(context, log_url, log_path)
294-
await utils.download_file(context, cot_log_url, cot_log_path)
295287
with pytest.raises(Download404):
296288
await utils.download_file(context, other_artifact_url, other_artifact_path)
297289

298290
with open(log_path) as fh:
299291
contents = fh.read()
300292
assert contents.rstrip() == "running task script\nAutomation Error: python exited with signal -15"
301293

302-
with open(cot_log_path) as fh:
303-
contents = fh.read()
304-
assert contents.rstrip() == "CoT logs"
305-
306294

307295
# empty_queue {{{1
308296
@pytest.mark.skipif(os.environ.get("NO_TESTS_OVER_WIRE"), reason=SKIP_REASON)

scriptworker/test/test_worker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ async def test_run_tasks_cancel_cot(context, mocker):
378378

379379
mock_prepare_task.assert_called_once()
380380
mock_complete_task.assert_called_once_with(mock.ANY, STATUSES['worker-shutdown'])
381-
mock_do_upload.assert_called_once_with(context, ['public/logs/chain_of_trust.log', 'public/logs/live_backing.log'])
381+
mock_do_upload.assert_called_once_with(context, ['public/logs/live_backing.log'])
382382

383383

384384
@pytest.mark.asyncio
@@ -418,7 +418,7 @@ async def mock_run_task(_, to_cancellable_process):
418418
assert task_process.stopped_due_to_worker_shutdown
419419
mock_prepare_task.assert_called_once()
420420
mock_complete_task.assert_called_once_with(mock.ANY, STATUSES['worker-shutdown'])
421-
mock_do_upload.assert_called_once_with(context, ['public/logs/chain_of_trust.log', 'public/logs/live_backing.log'])
421+
mock_do_upload.assert_called_once_with(context, ['public/logs/live_backing.log'])
422422

423423

424424
@pytest.mark.asyncio
@@ -500,7 +500,7 @@ async def mock_do_run_task(_, __, to_cancellable_process):
500500

501501
mock_prepare_task.assert_called_once()
502502
mock_complete_task.assert_called_once_with(mock.ANY, STATUSES['worker-shutdown'])
503-
mock_do_upload.assert_called_once_with(context, ['public/logs/chain_of_trust.log', 'public/logs/live_backing.log'])
503+
mock_do_upload.assert_called_once_with(context, ['public/logs/live_backing.log'])
504504

505505

506506
@pytest.mark.asyncio

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
artifacts_paths = filepaths_in_dir(context.config['artifact_dir'])
137137
except WorkerShutdownDuringTask:
138138
shutdown_artifact_paths = [os.path.join('public', 'logs', log_file)
139-
for log_file in ['chain_of_trust.log', 'live_backing.log']]
139+
for log_file in ['live_backing.log']]
140140
artifacts_paths = [path for path in shutdown_artifact_paths
141141
if os.path.isfile(os.path.join(context.config['artifact_dir'], path))]
142142
status = STATUSES['worker-shutdown']

0 commit comments

Comments
 (0)