Skip to content

Commit a2c5985

Browse files
authored
Add logs for android cuttlefish startup issue (#3621)
1 parent 484de8b commit a2c5985

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

src/clusterfuzz/_internal/bot/init_scripts/android.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,21 @@ def run():
3333
logs.log('Running Android init script on non-Cuttlefish.')
3434

3535
# Check if we need to reflash device to latest build.
36+
logs.log('Init: flash_to_latest_build_if_needed.')
3637
android.flash.flash_to_latest_build_if_needed()
3738

3839
# Reconnect to cuttlefish device if connection is ever lost.
3940
if environment.is_android_cuttlefish():
41+
logs.log('Init: connect_to_cuttlefish_device.')
4042
android.adb.connect_to_cuttlefish_device()
4143

4244
# Reboot to bring device in a good state if not done recently.
4345
if android.adb.time_since_last_reboot() > TIME_SINCE_REBOOT_MIN_THRESHOLD:
46+
logs.log('Init: reboot.')
4447
android.device.reboot()
4548

4649
# Make sure that device is in a good condition before we move forward.
50+
logs.log('Init: wait_until_fully_booted.')
4751
android.adb.wait_until_fully_booted()
4852

4953
# Wait until battery charges to a minimum level and temperature threshold.

src/clusterfuzz/_internal/platforms/android/adb.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
from clusterfuzz._internal.system import shell
3232

3333
ADB_TIMEOUT = 1200 # Should be lower than |REBOOT_TIMEOUT|.
34-
BAD_STATE_WAIT = 900
35-
BOOT_WAIT_INTERVAL = 30
34+
BAD_STATE_WAIT = 60 * 60 # 60 mins
35+
BOOT_WAIT_INTERVAL = 60 * 2
3636
CUTTLEFISH_USER = 'vsoc-01'
3737
CUTTLEFISH_CVD_PORT = 6520
3838
DEFAULT_DEVICE_MEMORY_MB = 2048
@@ -48,7 +48,7 @@
4848
MONKEY_PROCESS_NAME = 'monkey'
4949
WAIT_FOR_DEVICE_TIMEOUT = 600
5050
REBOOT_TIMEOUT = 3600
51-
RECOVERY_CMD_TIMEOUT = 60
51+
RECOVERY_CMD_TIMEOUT = 60 * 2
5252
GET_DEVICE_STATE_TIMEOUT = 20
5353
STOP_CVD_WAIT = 20
5454
LAUNCH_CVD_TIMEOUT = 2700
@@ -183,6 +183,7 @@ def copy_to_cuttlefish(src_path, dest_path, timeout=None):
183183

184184
def factory_reset():
185185
"""Reset device to factory state."""
186+
logs.log('reached factory_reset')
186187
if environment.is_android_cuttlefish():
187188
# We cannot recover from this since there can be cases like userdata image
188189
# corruption in /data/data. Till the bug is fixed, we just need to wait
@@ -438,6 +439,7 @@ def stop_cuttlefish_device():
438439
cvd_dir = environment.get_value('CVD_DIR')
439440
cvd_bin_dir = os.path.join(cvd_dir, 'bin')
440441
stop_cvd_cmd = os.path.join(cvd_bin_dir, 'stop_cvd')
442+
logs.log('stop_cvd_cmd: %', str(stop_cvd_cmd))
441443

442444
execute_command(
443445
stop_cvd_cmd, timeout=RECOVERY_CMD_TIMEOUT, on_cuttlefish_host=True)
@@ -457,6 +459,7 @@ def recreate_cuttlefish_device():
457459
"""Recreate cuttlefish device, restoring from backup images."""
458460
logs.log('Reimaging cuttlefish device.')
459461
cvd_dir = environment.get_value('CVD_DIR')
462+
logs.log('cvd_dir: %', cvd_dir)
460463

461464
stop_cuttlefish_device()
462465

src/clusterfuzz/_internal/platforms/android/fetch_artifact.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,17 @@ def execute_request_with_retries(request):
4949
def download_artifact(client, bid, target, attempt_id, name, output_directory,
5050
output_filename):
5151
"""Download one artifact."""
52+
logs.log('reached download_artifact')
53+
logs.log('artifact to download: %', name)
54+
logs.log('output_directory: %', output_directory)
55+
logs.log('output_filename: %', output_filename)
5256
artifact_query = client.buildartifact().get(
5357
buildId=bid, target=target, attemptId=attempt_id, resourceId=name)
5458
artifact = execute_request_with_retries(artifact_query)
5559
if artifact is None:
56-
logs.log_error('No artifact found with name %s, target %s and build id %s.'
57-
% (name, target, bid))
60+
logs.log_error(
61+
'Artifact unreachable with name %s, target %s and build id %s.' %
62+
(name, target, bid))
5863
return False
5964

6065
# Lucky us, we always have the size.
@@ -81,6 +86,7 @@ def download_artifact(client, bid, target, attempt_id, name, output_directory,
8186

8287
logs.log('Downloading artifact %s.' % name)
8388
output_dir = os.path.dirname(output_path)
89+
logs.log('Output dir: %', output_dir)
8490
if not os.path.exists(output_dir):
8591
logs.log(f'Creating directory {output_dir}')
8692
os.mkdir(output_dir)
@@ -198,8 +204,8 @@ def run_script(client, bid, target, regex, output_directory, output_filename):
198204
artifacts = get_artifacts_for_build(
199205
client=client, bid=bid, target=target, attempt_id='latest')
200206
if not artifacts:
201-
logs.log_error(
202-
'No artifact found for target %s, build id %s.' % (target, bid))
207+
logs.log_error('Artifact could not be fetched for target %s, build id %s.' %
208+
(target, bid))
203209
return False
204210

205211
regex = re.compile(regex)

src/clusterfuzz/_internal/platforms/android/flash.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
('userdata', 'userdata.img'),
5353
]
5454
FLASH_DEFAULT_BUILD_TARGET = '-next-userdebug'
55+
FLASH_DEFAULT_IMAGES_DIR = os.path.join(
56+
environment.get_value('ROOT_DIR'), 'bot', 'inputs', 'images')
5557
FLASH_INTERVAL = 1 * 24 * 60 * 60
5658
FLASH_RETRIES = 3
5759
FLASH_REBOOT_BOOTLOADER_WAIT = 15
@@ -147,6 +149,11 @@ def flash_to_latest_build_if_needed():
147149
return
148150

149151
image_directory = environment.get_value('IMAGES_DIR')
152+
logs.log('image_directory: %', image_directory)
153+
if not image_directory:
154+
logs.log('no image_directory set, setting to default')
155+
image_directory = FLASH_DEFAULT_IMAGES_DIR
156+
logs.log('image_directory: %', image_directory)
150157
build_info = fetch_artifact.get_latest_artifact_info(branch, target)
151158
if not build_info:
152159
logs.log_error('Unable to fetch information on latest build artifact for '

0 commit comments

Comments
 (0)