platform/dev: add 'chromite' import & process id handling.
Current devserver does not have 'chromite' dependency. Also, in real devserver,
the cros_update process's id is different from the shell id, and the
path of 'stateful_update' is different from that in drone/shard.
This CL:
1. add 'chromite' import
2. pass the 'devserver directory' to ChromiumOSUpdater.
3. Create a process group before newing the cros_update process. Use the
process group id as the unique file identifier. Kill the whole process group if
neccessary.
BUG=chromium:636467
TEST=local autotest to trigger repair & provision.
real test in devserver chromeos4-devserver2.
pass testCROSAU in dev_integration_test.
Change-Id: Iddf7fcbcaf508b516a8c09bbe7b09fd7209c14a4
Reviewed-on: https://chromium-review.googlesource.com/367741
Commit-Ready: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/cros_update.py b/cros_update.py
index 5920cbe..78187c1 100644
--- a/cros_update.py
+++ b/cros_update.py
@@ -166,7 +166,9 @@
logging.debug('Remote device %s is connected', self.host_name)
payload_dir = os.path.join(self.static_dir, self.build_name)
chromeos_AU = auto_updater.ChromiumOSUpdater(
- device, self.build_name, payload_dir, log_file=self.log_file,
+ device, self.build_name, payload_dir,
+ dev_dir=os.path.abspath(os.path.dirname(__file__)),
+ log_file=self.log_file,
yes=True)
chromeos_AU.CheckPayloads()
@@ -244,18 +246,19 @@
force_update = AU_parser.options.force_update
full_update = AU_parser.options.full_update
- # Reset process group id to make current process running on the background.
+ # Use process group id as the unique id in track and log files, since
+ # os.setsid is executed before the current process is run.
pid = os.getpid()
- os.setsid()
+ pgid = os.getpgid(pid)
# Setting log files for CrOS auto-update process.
# Log file: file to record every details of CrOS auto-update process.
- log_file = cros_update_progress.GetExecuteLogFile(host_name, pid)
+ log_file = cros_update_progress.GetExecuteLogFile(host_name, pgid)
logging.info('Writing executing logs into file: %s', log_file)
logConfig.SetFileHandler(log_file)
# Create a progress_tracker for tracking CrOS auto-update progress.
- progress_tracker = cros_update_progress.AUProgress(host_name, pid)
+ progress_tracker = cros_update_progress.AUProgress(host_name, pgid)
# Create cros_update instance to run CrOS auto-update.
cros_updater_trigger = CrOSUpdateTrigger(host_name, build_name, static_dir,