diff options
author | Yu-Ju Hong <yjhong@chromium.org> | 2014-12-04 11:22:29 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-12-12 23:14:53 +0000 |
commit | b8d4dd52f8fe895d612f59adf16ab4d2b83267e3 (patch) | |
tree | a4bd3537c1cdb59b3ca35f0e96fa24d814137ee8 /compute | |
parent | 3ab8a574da60a3613eee019ccd058933b596ab99 (diff) | |
download | chromite-b8d4dd52f8fe895d612f59adf16ab4d2b83267e3.tar.gz |
compute: create chromeos-bot-v2 image
- Ensure buildbot is started after reboot
- Install sysstat package for system performance monitoring.
- Increase the file descriptor limit
- Modified the exception handling so that the cleanup (instance deletion)
is run when error occurs during image creation.
BUG=chromium:438839
TEST=Ran the script to create an image and launched an instance
Change-Id: I7c6a1498599e9cf4a634b0bee30012e707a10a4b
Reviewed-on: https://chromium-review.googlesource.com/233250
Tested-by: Yu-Ju Hong <yjhong@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Reviewed-by: Yu-Ju Hong <yjhong@chromium.org>
Commit-Queue: Yu-Ju Hong <yjhong@chromium.org>
Diffstat (limited to 'compute')
-rw-r--r-- | compute/compute_configs.py | 2 | ||||
-rw-r--r-- | compute/cros_compute.py | 10 | ||||
-rw-r--r-- | compute/setup_bot.py | 22 |
3 files changed, 28 insertions, 6 deletions
diff --git a/compute/compute_configs.py b/compute/compute_configs.py index 7ab3321aa..8838c80f1 100644 --- a/compute/compute_configs.py +++ b/compute/compute_configs.py @@ -11,7 +11,7 @@ from chromite.cbuildbot import constants PROJECT = 'chromeos-bot' DEFAULT_BASE_IMAGE = 'ubuntu-14-04-server-v20141016' -DEFAULT_IMAGE_NAME = 'chromeos-bot-v1' +DEFAULT_IMAGE_NAME = 'chromeos-bot-v2' DEFAULT_ZONE = 'us-east1-a' DEFAULT_SCOPES = ('https://www.googleapis.com/auth/devstorage.full_control', 'https://www.googleapis.com/auth/gerritcodereview') diff --git a/compute/cros_compute.py b/compute/cros_compute.py index 8fd3b7673..3f9b2b881 100644 --- a/compute/cros_compute.py +++ b/compute/cros_compute.py @@ -69,9 +69,9 @@ def BotifyInstance(instance, project, zone): dest_path = bot_constants.BOT_CREDS_TMP_PATH src_path = os.getenv(bot_constants.BOT_CREDS_DIR_ENV_VAR) if not src_path: - cros_build_lib.Die('Environment variable %s is not set. This is necessary' - 'to set up credentials for the bot.' - % bot_constants.BOT_CREDS_DIR_ENV_VAR) + raise ValueError('Environment variable %s is not set. This is necessary' + 'to set up credentials for the bot.' + % bot_constants.BOT_CREDS_DIR_ENV_VAR) gcctx.CopyFilesToInstance(instance, src_path, dest_path) gcctx.SSH( instance, @@ -169,10 +169,10 @@ def CreateImageForCrosBots(project, zone): gcctx.CreateInstance(instance, image=compute_configs.DEFAULT_BASE_IMAGE) try: BotifyInstance(instance, project, zone) - # TODO: remove unncessary files. - except Exception: + except: # Clean up the temp instance. gcctx.DeleteInstance(instance) + raise gcctx.DeleteInstance(instance, keep_disks='boot') # By default the name of the boot disk is the same as the name of diff --git a/compute/setup_bot.py b/compute/setup_bot.py index d26d35738..8c6c11336 100644 --- a/compute/setup_bot.py +++ b/compute/setup_bot.py @@ -35,6 +35,10 @@ def SetupPrerequisites(): packages += ['python-sqlalchemy', 'python-mysqldb'] # Required for payload generation outside of the chroot. packages += ['python-protobuf'] + + # Packages to monitor system performance and usage. + packages += ['sysstat'] + SudoRunCommand(['apt-get', '-y', 'install'] + packages) @@ -175,6 +179,23 @@ def SetupBuildbotEnvironment(): RunCommand(['bash', '-c', r'echo export PATH=\$PATH:%s >> ~/.bashrc' % depot_tools_path]) + # Start buildbot slave at startup. + crontab_content = '' + result = RunCommand( + ['crontab', '-l'], capture_output=True, error_code_ok=True) + crontab_content = result.output if result.returncode == 0 else '' + crontab_content += ('SHELL=/bin/bash\nUSER=chrome-bot\n' + '@reboot cd /b/build/slave && make start\n') + RunCommand(['crontab', '-'], input=crontab_content) + + +def TuneSystemSettings(): + """Tune the system settings for our build environment.""" + # Increase the user-level file descriptor limits. + entries = ('* soft nofile 65536\n' + '* hard nofile 65536\n') + SudoRunCommand(['tee', '-a', '/etc/security/limits.conf'], input=entries) + def main(_argv): assert getpass.getuser() == bot_constants.BUILDBOT_USER, ( @@ -184,3 +205,4 @@ def main(_argv): InstallChromeDependencies() SetupCredentials() SetupBuildbotEnvironment() + TuneSystemSettings() |