Commit 1a9b90d3 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

kvm: NDB server instance is OK even if no image is uploaded

NBD server is not running until an image is uploaded. Make sure that the
promise doesn't fail until the image is there. Also display a WARNING in
the connection parameter to say that the NBD server is not running.
parent 596fd444
......@@ -47,7 +47,7 @@ md5sum = b617d64de73de1eed518185f310bbc82
[template-nbd]
filename = instance-nbd.cfg.in
md5sum = c3667c9bbaa8627dad90f1abd62d2f16
md5sum = 70267d09442a7e5a048ebdf06217e21e
[template-ansible-promise]
filename = template/ansible-promise.in
......
......@@ -15,6 +15,7 @@ offline = true
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
bin = $${buildout:directory}/bin
etc = $${buildout:directory}/etc
srv = $${buildout:directory}/srv
log = $${buildout:directory}/log
......@@ -34,12 +35,18 @@ shell-path = ${dash:location}/bin/dash
# XXX TODO: Wait for the iso to be uploaded (execute_wait)
path = $${basedirectory:services}/nbdserver
[nbd-checker-bin]
recipe = slapos.recipe.template:jinja2
template = inline:#!/bin/sh
[ ! -f $${onetimeupload-instance:image-path} ] ||
$${buildout:executable} -c 'import socket ; socket.create_connection(("$${nbd-instance:ip}","$${nbd-instance:port}")).close()'
rendered = $${rootdirectory:bin}/check-nbd-running.sh
[nbd-promise]
<= monitor-promise-base
module = check_port_listening
module = check_command_execute
name = nbd_promise.py
config-hostname = $${nbd-instance:ip}
config-port = $${nbd-instance:port}
config-command = $${nbd-checker-bin:rendered}
[gen-passwd]
recipe = slapos.cookbook:generate.password
......@@ -66,6 +73,13 @@ config-port = $${onetimeupload-instance:port}
[publish-connection-information]
recipe = slapos.cookbook:publish
nbd_url = nbd://[$${nbd-instance:ip}]:$${nbd-instance:port}
upload_url = http://[$${onetimeupload-instance:ip}]:$${onetimeupload-instance:port}/
nbd_hostname = $${nbd-instance:ip}
nbd_port = $${nbd-instance:port}
upload_url = http://[$${onetimeupload-instance:ip}]:$${onetimeupload-instance:port}
upload_key = $${onetimeupload-instance:key}
status_message = $${detect-if-cdrom-present:status}
[detect-if-cdrom-present]
recipe = collective.recipe.shelloutput
commands =
status = [ -f $${onetimeupload-instance:image-path} ] && echo "image already uploaded, you can't upload it again" || echo "WARNING: no image yet, the NBD server doesn't work"
......@@ -308,3 +308,23 @@ class TestInstanceResilient(InstanceTestCase):
'takeover-kvm-1-password',
'takeover-kvm-1-url',
'url']))
class TestInstanceNbdServer(InstanceTestCase):
__partition_reference__ = 'ins'
instance_max_retry = 5
@classmethod
def getInstanceSoftwareType(cls):
return 'nbd'
def test(self):
connection_parameter_dict = self.computer_partition\
.getConnectionParameterDict()
self.assertNotIn("WARNING", connection_parameter_dict['upload_url'])
result = requests.get(connection_parameter_dict['upload_url'].strip(), verify=False)
self.assertEqual(
httplib.OK,
result.status_code
)
self.assertTrue('<title>Upload new File</title>' in result.text)
self.assertIn("WARNING", connection_parameter_dict['nbd_url'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment