diff --git a/.zuul.yaml b/.zuul.yaml index 7b9deea46..311f5cdf3 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -27,6 +27,8 @@ s-proxy: false devstack_plugins: nodepool: https://git.openstack.org/openstack-infra/nodepool + zuul_copy_output: + '/var/log/nodepool/builds': 'logs' - job: name: nodepool-functional-py35 diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 41609d153..4688c6d21 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -168,6 +168,9 @@ EOF EOF sudo mv /tmp/secure.conf $NODEPOOL_SECURE + sudo mkdir /var/log/nodepool + sudo chown -R stack:stack /var/log/nodepool + if use_library_from_git "glean"; then git --git-dir=$DEST/glean/.git checkout -b devstack DIB_GLEAN_INSTALLTYPE="DIB_INSTALLTYPE_simple_init: 'repo'" diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 79363d57d..23b48d9ec 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -65,6 +65,34 @@ Example:: images-dir: /path/to/images/dir +.. _build-log-dir: + +build-log-dir +------------- + +The builder will store build logs in this directory. It will create +one file for each build, named `-.log`; for example, +`fedora-0000000004.log`. It defaults to ``/var/log/nodepool/builds``. + +Example:: + + build-log-dir: /path/to/log/dir + +.. _build-log-retention: + +build-log-retention +------------------- + +At the start of each build, the builder will remove old build logs if +they exceed a certain number. This option specifies how many will be +kept (usually you will see one more, as deletion happens before +starting a new build). By default, the last 7 old build logs are +kept. + +Example:: + + build-log-retention: 14 + zookeeper-servers ----------------- Lists the ZooKeeper servers uses for coordinating information between diff --git a/nodepool/builder.py b/nodepool/builder.py index b5827eaf3..e0730af16 100755 --- a/nodepool/builder.py +++ b/nodepool/builder.py @@ -547,6 +547,29 @@ class BuildWorker(BaseWorker): self.name = 'BuildWorker.%s' % name self.dib_cmd = dib_cmd + def _getBuildLogRoot(self, name): + log_dir = self._config.build_log_dir + if not log_dir: + log_dir = '/var/log/nodepool/builds' + if not os.path.exists(log_dir): + os.makedirs(log_dir) + return log_dir + + def _pruneBuildLogs(self, name): + log_dir = self._getBuildLogRoot(name) + keep = max(self._config.build_log_retention, 1) + existing = sorted(os.listdir(log_dir)) + existing = [f for f in existing if f.startswith(name)] + delete = existing[:0 - keep] + for f in delete: + fp = os.path.join(log_dir, f) + self.log.info("Deleting old build log %s" % (fp,)) + os.unlink(fp) + + def _getBuildLog(self, name, build_id): + log_dir = self._getBuildLogRoot(name) + return os.path.join(log_dir, '%s-%s.log' % (name, build_id)) + def _checkForScheduledImageUpdates(self): ''' Check every DIB image to see if it has aged out and needs rebuilt. @@ -714,10 +737,11 @@ class BuildWorker(BaseWorker): (self.dib_cmd, img_types, qemu_img_options, filename, img_elements)) - log = logging.getLogger("nodepool.image.build.%s" % - (diskimage.name,)) + self._pruneBuildLogs(diskimage.name) + log_fn = self._getBuildLog(diskimage.name, build_id) - self.log.info('Running %s' % cmd) + self.log.info('Running %s' % (cmd,)) + self.log.info('Logging to %s' % (log_fn,)) try: p = subprocess.Popen( @@ -730,13 +754,17 @@ class BuildWorker(BaseWorker): "Failed to exec '%s'. Error: '%s'" % (cmd, e.strerror) ) - while True: - ln = p.stdout.readline() - log.info(ln.strip()) - if not ln: - break + with open(log_fn, 'wb') as log: + while True: + ln = p.stdout.readline() + log.write(ln) + log.flush() + if not ln: + break - p.wait() + rc = p.wait() + m = "Exit code: %s\n" % rc + log.write(m.encode('utf8')) # It's possible the connection to the ZK cluster could have been # interrupted during the build. If so, wait for it to return. diff --git a/nodepool/cmd/config_validator.py b/nodepool/cmd/config_validator.py index cccf611ab..310c534cc 100644 --- a/nodepool/cmd/config_validator.py +++ b/nodepool/cmd/config_validator.py @@ -58,6 +58,8 @@ class ConfigValidator: 'webapp': webapp, 'elements-dir': str, 'images-dir': str, + 'build-log-dir': str, + 'build-log-retention': int, 'zookeeper-servers': [{ 'host': str, 'port': int, diff --git a/nodepool/config.py b/nodepool/config.py index 47a80d162..98fa2c41f 100755 --- a/nodepool/config.py +++ b/nodepool/config.py @@ -110,6 +110,8 @@ def loadConfig(config_path): newconfig.labels = {} newconfig.elementsdir = config.get('elements-dir') newconfig.imagesdir = config.get('images-dir') + newconfig.build_log_dir = config.get('build-log-dir') + newconfig.build_log_retention = config.get('build-log-retention', 7) newconfig.provider_managers = {} newconfig.zookeeper_servers = {} newconfig.diskimages = {} diff --git a/nodepool/tests/__init__.py b/nodepool/tests/__init__.py index 45a193816..7561874ab 100644 --- a/nodepool/tests/__init__.py +++ b/nodepool/tests/__init__.py @@ -286,18 +286,22 @@ class DBTestCase(BaseTestCase): if images_dir is None: images_dir = fixtures.TempDir() self.useFixture(images_dir) + build_log_dir = fixtures.TempDir() + self.useFixture(build_log_dir) configfile = os.path.join(os.path.dirname(__file__), 'fixtures', filename) (fd, path) = tempfile.mkstemp() with open(configfile, 'rb') as conf_fd: config = conf_fd.read().decode('utf8') data = config.format(images_dir=images_dir.path, + build_log_dir=build_log_dir.path, zookeeper_host=self.zookeeper_host, zookeeper_port=self.zookeeper_port, zookeeper_chroot=self.zookeeper_chroot) os.write(fd, data.encode('utf8')) os.close(fd) self._config_images_dir = images_dir + self._config_build_log_dir = build_log_dir validator = ConfigValidator(path) validator.validate() return path diff --git a/nodepool/tests/fixtures/disabled_provider.yaml b/nodepool/tests/fixtures/disabled_provider.yaml index 676cc1492..0136dc7fd 100644 --- a/nodepool/tests/fixtures/disabled_provider.yaml +++ b/nodepool/tests/fixtures/disabled_provider.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/info_cmd_two_provider.yaml b/nodepool/tests/fixtures/info_cmd_two_provider.yaml index f9ce70925..c8357b0ae 100644 --- a/nodepool/tests/fixtures/info_cmd_two_provider.yaml +++ b/nodepool/tests/fixtures/info_cmd_two_provider.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/info_cmd_two_provider_remove.yaml b/nodepool/tests/fixtures/info_cmd_two_provider_remove.yaml index 902554748..10a60418e 100644 --- a/nodepool/tests/fixtures/info_cmd_two_provider_remove.yaml +++ b/nodepool/tests/fixtures/info_cmd_two_provider_remove.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/integration_noocc.yaml b/nodepool/tests/fixtures/integration_noocc.yaml index 4cfcaad0c..13c24dbed 100644 --- a/nodepool/tests/fixtures/integration_noocc.yaml +++ b/nodepool/tests/fixtures/integration_noocc.yaml @@ -1,4 +1,5 @@ images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: localhost diff --git a/nodepool/tests/fixtures/integration_occ.yaml b/nodepool/tests/fixtures/integration_occ.yaml index bc0733c9d..8dbc0e67e 100644 --- a/nodepool/tests/fixtures/integration_occ.yaml +++ b/nodepool/tests/fixtures/integration_occ.yaml @@ -1,4 +1,5 @@ images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: localhost diff --git a/nodepool/tests/fixtures/launcher_two_provider.yaml b/nodepool/tests/fixtures/launcher_two_provider.yaml index 748e4b6d5..734e8f2bd 100644 --- a/nodepool/tests/fixtures/launcher_two_provider.yaml +++ b/nodepool/tests/fixtures/launcher_two_provider.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/launcher_two_provider_max_1.yaml b/nodepool/tests/fixtures/launcher_two_provider_max_1.yaml index 2b8147a86..6a57137c8 100644 --- a/nodepool/tests/fixtures/launcher_two_provider_max_1.yaml +++ b/nodepool/tests/fixtures/launcher_two_provider_max_1.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/launcher_two_provider_remove.yaml b/nodepool/tests/fixtures/launcher_two_provider_remove.yaml index 902554748..10a60418e 100644 --- a/nodepool/tests/fixtures/launcher_two_provider_remove.yaml +++ b/nodepool/tests/fixtures/launcher_two_provider_remove.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/leaked_node.yaml b/nodepool/tests/fixtures/leaked_node.yaml index 902554748..10a60418e 100644 --- a/nodepool/tests/fixtures/leaked_node.yaml +++ b/nodepool/tests/fixtures/leaked_node.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/leaked_node_nodepool_id.yaml b/nodepool/tests/fixtures/leaked_node_nodepool_id.yaml index 5d95ddffb..d212a34fc 100644 --- a/nodepool/tests/fixtures/leaked_node_nodepool_id.yaml +++ b/nodepool/tests/fixtures/leaked_node_nodepool_id.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/multi_drivers.yaml b/nodepool/tests/fixtures/multi_drivers.yaml index b79e7528d..06a0d019b 100644 --- a/nodepool/tests/fixtures/multi_drivers.yaml +++ b/nodepool/tests/fixtures/multi_drivers.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/multiple_pools.yaml b/nodepool/tests/fixtures/multiple_pools.yaml index 72ae76cb8..e5f11debd 100644 --- a/nodepool/tests/fixtures/multiple_pools.yaml +++ b/nodepool/tests/fixtures/multiple_pools.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node.yaml b/nodepool/tests/fixtures/node.yaml index e794160ea..45682671d 100644 --- a/nodepool/tests/fixtures/node.yaml +++ b/nodepool/tests/fixtures/node.yaml @@ -1,5 +1,7 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' +build-log-retention: 1 zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_auto_floating_ip.yaml b/nodepool/tests/fixtures/node_auto_floating_ip.yaml index 1e489131e..fdfc77d1b 100644 --- a/nodepool/tests/fixtures/node_auto_floating_ip.yaml +++ b/nodepool/tests/fixtures/node_auto_floating_ip.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_az.yaml b/nodepool/tests/fixtures/node_az.yaml index 0ffa64290..4743b5849 100644 --- a/nodepool/tests/fixtures/node_az.yaml +++ b/nodepool/tests/fixtures/node_az.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_boot_from_volume.yaml b/nodepool/tests/fixtures/node_boot_from_volume.yaml index 7b96d1208..254cf0a84 100644 --- a/nodepool/tests/fixtures/node_boot_from_volume.yaml +++ b/nodepool/tests/fixtures/node_boot_from_volume.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_cmd.yaml b/nodepool/tests/fixtures/node_cmd.yaml index 1f7658e32..2a4c83b9e 100644 --- a/nodepool/tests/fixtures/node_cmd.yaml +++ b/nodepool/tests/fixtures/node_cmd.yaml @@ -1,4 +1,5 @@ images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_disabled_label.yaml b/nodepool/tests/fixtures/node_disabled_label.yaml index b3bd76faf..8eab0706b 100644 --- a/nodepool/tests/fixtures/node_disabled_label.yaml +++ b/nodepool/tests/fixtures/node_disabled_label.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_diskimage_fail.yaml b/nodepool/tests/fixtures/node_diskimage_fail.yaml index ad8fbc02c..0a84a8707 100644 --- a/nodepool/tests/fixtures/node_diskimage_fail.yaml +++ b/nodepool/tests/fixtures/node_diskimage_fail.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_diskimage_only.yaml b/nodepool/tests/fixtures/node_diskimage_only.yaml index c3d43ab2e..01770bddd 100644 --- a/nodepool/tests/fixtures/node_diskimage_only.yaml +++ b/nodepool/tests/fixtures/node_diskimage_only.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_diskimage_pause.yaml b/nodepool/tests/fixtures/node_diskimage_pause.yaml index 6c206f6f9..db013c5cd 100644 --- a/nodepool/tests/fixtures/node_diskimage_pause.yaml +++ b/nodepool/tests/fixtures/node_diskimage_pause.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_flavor_name.yaml b/nodepool/tests/fixtures/node_flavor_name.yaml index bae2adbd4..8fb2c03d7 100644 --- a/nodepool/tests/fixtures/node_flavor_name.yaml +++ b/nodepool/tests/fixtures/node_flavor_name.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_image_upload_pause.yaml b/nodepool/tests/fixtures/node_image_upload_pause.yaml index ce8ee5c31..0b7569e05 100644 --- a/nodepool/tests/fixtures/node_image_upload_pause.yaml +++ b/nodepool/tests/fixtures/node_image_upload_pause.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_ipv6.yaml b/nodepool/tests/fixtures/node_ipv6.yaml index 06e908559..3ece14f74 100644 --- a/nodepool/tests/fixtures/node_ipv6.yaml +++ b/nodepool/tests/fixtures/node_ipv6.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_label_provider.yaml b/nodepool/tests/fixtures/node_label_provider.yaml index 9a600056c..8de7135bb 100644 --- a/nodepool/tests/fixtures/node_label_provider.yaml +++ b/nodepool/tests/fixtures/node_label_provider.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_launch_retry.yaml b/nodepool/tests/fixtures/node_launch_retry.yaml index ecf41011b..72d483bf8 100644 --- a/nodepool/tests/fixtures/node_launch_retry.yaml +++ b/nodepool/tests/fixtures/node_launch_retry.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_lost_requests.yaml b/nodepool/tests/fixtures/node_lost_requests.yaml index 0b1a82961..b8168c558 100644 --- a/nodepool/tests/fixtures/node_lost_requests.yaml +++ b/nodepool/tests/fixtures/node_lost_requests.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_many_labels.yaml b/nodepool/tests/fixtures/node_many_labels.yaml index 7e165e25c..ec67e765a 100644 --- a/nodepool/tests/fixtures/node_many_labels.yaml +++ b/nodepool/tests/fixtures/node_many_labels.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_max_ready_age.yaml b/nodepool/tests/fixtures/node_max_ready_age.yaml index 15789aa45..396dbf41a 100644 --- a/nodepool/tests/fixtures/node_max_ready_age.yaml +++ b/nodepool/tests/fixtures/node_max_ready_age.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_min_ready_capacity.yaml b/nodepool/tests/fixtures/node_min_ready_capacity.yaml index 0c31e5590..d00dee8a9 100644 --- a/nodepool/tests/fixtures/node_min_ready_capacity.yaml +++ b/nodepool/tests/fixtures/node_min_ready_capacity.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_net_name.yaml b/nodepool/tests/fixtures/node_net_name.yaml index a983fdbfa..ac1a4bb8d 100644 --- a/nodepool/tests/fixtures/node_net_name.yaml +++ b/nodepool/tests/fixtures/node_net_name.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_no_min_ready.yaml b/nodepool/tests/fixtures/node_no_min_ready.yaml index 4ea152558..8568ad8f2 100644 --- a/nodepool/tests/fixtures/node_no_min_ready.yaml +++ b/nodepool/tests/fixtures/node_no_min_ready.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_quota_cloud.yaml b/nodepool/tests/fixtures/node_quota_cloud.yaml index f7684ae9c..2804cdeca 100644 --- a/nodepool/tests/fixtures/node_quota_cloud.yaml +++ b/nodepool/tests/fixtures/node_quota_cloud.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_quota_pool_cores.yaml b/nodepool/tests/fixtures/node_quota_pool_cores.yaml index a43144348..c90118b9a 100644 --- a/nodepool/tests/fixtures/node_quota_pool_cores.yaml +++ b/nodepool/tests/fixtures/node_quota_pool_cores.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_quota_pool_instances.yaml b/nodepool/tests/fixtures/node_quota_pool_instances.yaml index 08013c6fb..b5888f190 100644 --- a/nodepool/tests/fixtures/node_quota_pool_instances.yaml +++ b/nodepool/tests/fixtures/node_quota_pool_instances.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_quota_pool_ram.yaml b/nodepool/tests/fixtures/node_quota_pool_ram.yaml index 608ff8d32..83aaeb645 100644 --- a/nodepool/tests/fixtures/node_quota_pool_ram.yaml +++ b/nodepool/tests/fixtures/node_quota_pool_ram.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_two_image.yaml b/nodepool/tests/fixtures/node_two_image.yaml index 862cd9177..fe9c714d5 100644 --- a/nodepool/tests/fixtures/node_two_image.yaml +++ b/nodepool/tests/fixtures/node_two_image.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_two_image_remove.yaml b/nodepool/tests/fixtures/node_two_image_remove.yaml index 902554748..10a60418e 100644 --- a/nodepool/tests/fixtures/node_two_image_remove.yaml +++ b/nodepool/tests/fixtures/node_two_image_remove.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_two_provider.yaml b/nodepool/tests/fixtures/node_two_provider.yaml index 748e4b6d5..734e8f2bd 100644 --- a/nodepool/tests/fixtures/node_two_provider.yaml +++ b/nodepool/tests/fixtures/node_two_provider.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_two_provider_remove.yaml b/nodepool/tests/fixtures/node_two_provider_remove.yaml index f4887abc2..a8831b19c 100644 --- a/nodepool/tests/fixtures/node_two_provider_remove.yaml +++ b/nodepool/tests/fixtures/node_two_provider_remove.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_unmanaged_image.yaml b/nodepool/tests/fixtures/node_unmanaged_image.yaml index 15645da84..8cebef554 100644 --- a/nodepool/tests/fixtures/node_unmanaged_image.yaml +++ b/nodepool/tests/fixtures/node_unmanaged_image.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_upload_fail.yaml b/nodepool/tests/fixtures/node_upload_fail.yaml index 766fa6c87..1cffcc284 100644 --- a/nodepool/tests/fixtures/node_upload_fail.yaml +++ b/nodepool/tests/fixtures/node_upload_fail.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_vhd.yaml b/nodepool/tests/fixtures/node_vhd.yaml index 6f71d702a..5faa58e34 100644 --- a/nodepool/tests/fixtures/node_vhd.yaml +++ b/nodepool/tests/fixtures/node_vhd.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/node_vhd_and_qcow2.yaml b/nodepool/tests/fixtures/node_vhd_and_qcow2.yaml index 39f368ffa..70d4ed561 100644 --- a/nodepool/tests/fixtures/node_vhd_and_qcow2.yaml +++ b/nodepool/tests/fixtures/node_vhd_and_qcow2.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/pause_declined_1.yaml b/nodepool/tests/fixtures/pause_declined_1.yaml index 0568b21ff..c581e0b11 100644 --- a/nodepool/tests/fixtures/pause_declined_1.yaml +++ b/nodepool/tests/fixtures/pause_declined_1.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/pause_declined_2.yaml b/nodepool/tests/fixtures/pause_declined_2.yaml index 0c31e5590..d00dee8a9 100644 --- a/nodepool/tests/fixtures/pause_declined_2.yaml +++ b/nodepool/tests/fixtures/pause_declined_2.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/secure_file_config.yaml b/nodepool/tests/fixtures/secure_file_config.yaml index 094284a32..3aca1da3d 100644 --- a/nodepool/tests/fixtures/secure_file_config.yaml +++ b/nodepool/tests/fixtures/secure_file_config.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: invalid_host diff --git a/nodepool/tests/fixtures/unmanaged_image_provider_name.yaml b/nodepool/tests/fixtures/unmanaged_image_provider_name.yaml index c95561432..a5100a02f 100644 --- a/nodepool/tests/fixtures/unmanaged_image_provider_name.yaml +++ b/nodepool/tests/fixtures/unmanaged_image_provider_name.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/fixtures/wedge_test.yaml b/nodepool/tests/fixtures/wedge_test.yaml index c624e2725..ebcc38f25 100644 --- a/nodepool/tests/fixtures/wedge_test.yaml +++ b/nodepool/tests/fixtures/wedge_test.yaml @@ -1,5 +1,6 @@ elements-dir: . images-dir: '{images_dir}' +build-log-dir: '{build_log_dir}' zookeeper-servers: - host: {zookeeper_host} diff --git a/nodepool/tests/test_builder.py b/nodepool/tests/test_builder.py index 8e092b468..3d18cf824 100644 --- a/nodepool/tests/test_builder.py +++ b/nodepool/tests/test_builder.py @@ -184,12 +184,18 @@ class TestNodePoolBuilder(tests.DBTestCase): configfile = self.setup_config('node.yaml') self.useBuilder(configfile) build = self.waitForBuild('fake-image', '0000000001') + log_path1 = os.path.join(self._config_build_log_dir.path, + 'fake-image-0000000001.log') + self.assertTrue(os.path.exists(log_path1)) image = self.waitForImage('fake-provider', 'fake-image') # Expire rebuild-age (default: 1day) to force a new build. build.state_time -= expire with self.zk.imageBuildLock('fake-image', blocking=True, timeout=1): self.zk.storeBuild('fake-image', build, '0000000001') self.waitForBuild('fake-image', '0000000002') + log_path2 = os.path.join(self._config_build_log_dir.path, + 'fake-image-0000000002.log') + self.assertTrue(os.path.exists(log_path2)) self.waitForImage('fake-provider', 'fake-image', [image]) builds = self.zk.getBuilds('fake-image', zk.READY) self.assertEqual(len(builds), 2) @@ -205,6 +211,16 @@ class TestNodePoolBuilder(tests.DBTestCase): self.zk.storeBuild('fake-image', build, '0000000002') self.waitForBuildDeletion('fake-image', '0000000001') self.waitForBuild('fake-image', '0000000003') + log_path1 = os.path.join(self._config_build_log_dir.path, + 'fake-image-0000000001.log') + log_path2 = os.path.join(self._config_build_log_dir.path, + 'fake-image-0000000002.log') + log_path3 = os.path.join(self._config_build_log_dir.path, + 'fake-image-0000000003.log') + # Our log retention is set to 1, so the first log should be deleted. + self.assertFalse(os.path.exists(log_path1)) + self.assertTrue(os.path.exists(log_path2)) + self.assertTrue(os.path.exists(log_path3)) builds = self.zk.getBuilds('fake-image', zk.READY) self.assertEqual(len(builds), 2)