summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Jia <mjia@redhat.com>2016-10-25 12:12:41 +1000
committerMatt Jia <mjia@redhat.com>2016-10-31 23:36:04 +0000
commitda355153e4583da4e3147a2f0daa2dcc54e64d84 (patch)
tree057cb19dde18b1c673334099d229fcd8fb3fd214
parent7f3afca8227db5412425ac34da6bd6210e6a9b2a (diff)
recipe page: show the progress of creating OpenStack instances
-rw-r--r--IntegrationTests/src/bkr/inttest/server/selenium/test_recipes.py14
-rw-r--r--Server/assets/jst/recipe-installation-progress.html14
-rw-r--r--Server/assets/recipe-installation.js8
-rw-r--r--Server/assets/scheduler-model.js4
-rw-r--r--Server/bkr/server/alembic/versions/4e8b85360255_record_openstack_instance_creation_and_deletion_timestamp.py28
-rw-r--r--Server/bkr/server/model/scheduler.py7
-rw-r--r--Server/bkr/server/tests/data_setup.py1
-rw-r--r--Server/bkr/server/tools/beakerd.py1
8 files changed, 76 insertions, 1 deletions
diff --git a/IntegrationTests/src/bkr/inttest/server/selenium/test_recipes.py b/IntegrationTests/src/bkr/inttest/server/selenium/test_recipes.py
index 931e963..8338161 100644
--- a/IntegrationTests/src/bkr/inttest/server/selenium/test_recipes.py
+++ b/IntegrationTests/src/bkr/inttest/server/selenium/test_recipes.py
@@ -645,6 +645,20 @@ class TestRecipeViewInstallationTab(WebDriverTestCase):
'//td[contains(string(following-sibling::td), "Netboot configured")]').text
self.assertEqual(netboot_configured_timestamp, '-00:00:59')
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1361961
+ def test_create_openstack_instance_progress_is_shown(self):
+ with session.begin():
+ recipe = data_setup.create_recipe()
+ data_setup.create_job_for_recipes([recipe])
+ data_setup.mark_recipe_installing(recipe, virt=True)
+ b = self.browser
+ go_to_recipe_view(b, recipe, tab='Installation')
+ tab = b.find_element_by_id('installation')
+ openstack_instance_progress = tab.find_element_by_xpath(
+ './/div[@class="recipe-installation-progress"]/table'
+ '//td[contains(text(), "OpenStack instance created")]').text
+ self.assertIn(recipe.installation.kernel_options, openstack_instance_progress)
+
class TestRecipeViewReservationTab(WebDriverTestCase):
def setUp(self):
diff --git a/Server/assets/jst/recipe-installation-progress.html b/Server/assets/jst/recipe-installation-progress.html
index f980fb8..436f73c 100644
--- a/Server/assets/jst/recipe-installation-progress.html
+++ b/Server/assets/jst/recipe-installation-progress.html
@@ -13,6 +13,20 @@
</td>
</tr>
<% } %>
+ <% if (openstack_instance_created) { %>
+ <tr>
+ <td>
+ <time datetime="<%- openstack_instance_created.toISOString() %>"
+ title="<%- openstack_instance_created.local().format('YYYY-MM-DD HH:mm:ss Z') %>">
+ <%= get_time_difference(openstack_instance_created, start_time) %>
+ </time>
+ </td>
+ <td>
+ OpenStack instance created
+ <div class="recipe-installation-kernel-options"><code><%- kernel_options %></code></div>
+ </td>
+ </tr>
+ <% } %>
<% if (rebooted) { %>
<tr>
<td>
diff --git a/Server/assets/recipe-installation.js b/Server/assets/recipe-installation.js
index cb55548..c724c6a 100644
--- a/Server/assets/recipe-installation.js
+++ b/Server/assets/recipe-installation.js
@@ -88,6 +88,7 @@ var RecipeInstallationProgress = Backbone.View.extend({
},
render: function () {
var netboot_configured = null;
+ var openstack_instance_created = null;
var rebooted = null;
var install_started = null;
var install_finished = null;
@@ -103,17 +104,22 @@ var RecipeInstallationProgress = Backbone.View.extend({
configure_netboot_cmd.get('status') == 'Completed') {
netboot_configured = configure_netboot_cmd.get('finish_time');
}
+ var resource = this.model.get('resource');
+ if(!_.isEmpty(resource.get('instance_id'))) {
+ openstack_instance_created = resource.get('instance_created');
+ }
rebooted = installation.get('rebooted');
install_started = installation.get('install_started');
install_finished = installation.get('install_finished');
postinstall_finished = installation.get('postinstall_finished');
}
- if (!_.any([netboot_configured, rebooted, install_started,
+ if (!_.any([netboot_configured, openstack_instance_created, rebooted, install_started,
install_finished, postinstall_finished])) {
this.$el.text('No installation progress reported.');
} else {
this.$el.html(this.template({
netboot_configured: netboot_configured,
+ openstack_instance_created: openstack_instance_created,
rebooted: rebooted,
install_started: install_started,
install_finished: install_finished,
diff --git a/Server/assets/scheduler-model.js b/Server/assets/scheduler-model.js
index 6d013a7..eb52817 100644
--- a/Server/assets/scheduler-model.js
+++ b/Server/assets/scheduler-model.js
@@ -395,6 +395,10 @@ window.RecipeTaskResult = Backbone.Model.extend({
window.RecipeResource = Backbone.Model.extend({
parse: function (data) {
data['system'] = !_.isEmpty(data['system']) ? new System(data['system']) : null;
+ if (data['instance_created']) {
+ var parsed = moment.utc(data['instance_created']);
+ data['instance_created'] = parsed.isSame(this.get('instance_created')) ? this.get('instance_created') : parsed;
+ }
return data;
},
});
diff --git a/Server/bkr/server/alembic/versions/4e8b85360255_record_openstack_instance_creation_and_deletion_timestamp.py b/Server/bkr/server/alembic/versions/4e8b85360255_record_openstack_instance_creation_and_deletion_timestamp.py
new file mode 100644
index 0000000..80ca90a
--- /dev/null
+++ b/Server/bkr/server/alembic/versions/4e8b85360255_record_openstack_instance_creation_and_deletion_timestamp.py
@@ -0,0 +1,28 @@
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+"""record OpenStack instance creation and deletion timestamps
+
+Revision ID: 4e8b85360255
+Revises: 32f962a53c31
+Create Date: 2016-10-26 13:08:43.952818
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '4e8b85360255'
+down_revision = '32f962a53c31'
+
+from alembic import op
+from sqlalchemy import Column, DateTime, func
+
+def upgrade():
+ # The existing rows may have NULL in these columns.
+ op.add_column('virt_resource', Column('instance_created', DateTime, nullable=True))
+ op.add_column('virt_resource', Column('instance_deleted', DateTime, nullable=True))
+
+def downgrade():
+ op.drop_column('virt_resource', 'instance_created')
+ op.drop_column('virt_resource', 'instance_deleted')
diff --git a/Server/bkr/server/model/scheduler.py b/Server/bkr/server/model/scheduler.py
index 7d29a54..e980fcd 100644
--- a/Server/bkr/server/model/scheduler.py
+++ b/Server/bkr/server/model/scheduler.py
@@ -4047,6 +4047,8 @@ class VirtResource(RecipeResource):
network_id = Column(UUID, nullable=True)
subnet_id = Column(UUID, nullable=True)
router_id = Column(UUID, nullable=True)
+ instance_created = Column(DateTime, nullable=True, default=None)
+ instance_deleted = Column(DateTime, nullable=True, default=None)
lab_controller_id = Column(Integer, ForeignKey('lab_controller.id',
name='virt_resource_lab_controller_id_fk'))
lab_controller = relationship(LabController)
@@ -4100,6 +4102,8 @@ class VirtResource(RecipeResource):
def __json__(self):
data = super(VirtResource, self).__json__()
data['instance_id'] = unicode(self.instance_id)
+ data['instance_created'] = self.instance_created
+ data['instance_deleted'] = self.instance_deleted
data['href'] = self.href
return data
@@ -4133,6 +4137,8 @@ class VirtResource(RecipeResource):
yield InstallOptions.from_strings('hwclock_is_utc', u'console=tty0 console=ttyS0,115200n8', '')
def release(self):
+ if self.instance_deleted:
+ return
try:
log.debug('Releasing vm %s for recipe %s',
self.instance_id, self.recipe.id)
@@ -4140,6 +4146,7 @@ class VirtResource(RecipeResource):
from bkr.server import dynamic_virt
manager = dynamic_virt.VirtManager(self.recipe.recipeset.job.owner)
manager.destroy_vm(self)
+ self.instance_deleted = datetime.utcnow()
except Exception:
log.exception('Failed to destroy vm %s, leaked!',
self.instance_id)
diff --git a/Server/bkr/server/tests/data_setup.py b/Server/bkr/server/tests/data_setup.py
index 8101a2a..4c4bbb1 100644
--- a/Server/bkr/server/tests/data_setup.py
+++ b/Server/bkr/server/tests/data_setup.py
@@ -645,6 +645,7 @@ def mark_recipe_scheduled(recipe, start_time=None, system=None, fqdn=None,
router_id = uuid.uuid4()
recipe.resource = VirtResource(instance_id, network_id,
subnet_id, router_id, lab_controller)
+ recipe.resource.instance_created = datetime.datetime.utcnow()
recipe.recipeset.lab_controller = lab_controller
else:
if not system:
diff --git a/Server/bkr/server/tools/beakerd.py b/Server/bkr/server/tools/beakerd.py
index 132b539..b13bd2f 100644
--- a/Server/bkr/server/tools/beakerd.py
+++ b/Server/bkr/server/tools/beakerd.py
@@ -640,6 +640,7 @@ def provision_virt_recipe(recipe_id):
#if self.recipe.distro_tree.distro.osversion.osmajor.osmajor == "RedHatEnterpriseLinux3":
# virtio_possible = False
vm = manager.create_vm(vm_name, flavor)
+ vm.instance_created = datetime.utcnow()
try:
recipe.createRepo()
recipe.systems = []