Commit 81ca71cb authored by Julien Muchembled's avatar Julien Muchembled

check_port_listening: workaround for sheband limitation, reduce to a single file

The whole code is small enough and having the template
in a separate file only made editing more annoying.
parent f6aa1348
......@@ -26,24 +26,34 @@
#
##############################################################################
from slapos.recipe.librecipe import GenericBaseRecipe
from zc.buildout.easy_install import _safe_arg, script_header
import sys
template = script_header + r"""
  • @gabriel Indeed, it breaks under buildout 1.x. Here, it would be simple to fix but I prefer that you upgrade, since buildout 2 has new features that are so useful that we want to use them now.

    /cc @vpelletier @kazuhiko

  • (for cc, I forgot to mention that script_header contains %(dash_S)s under buildout 1.x)

  • I did not get norified (and opened this commit because I was curious), so I guess adding CCs after the initial post does not work. So re-cc-ing @kazuhiko .

    About the topic, I do not have a very strong opinion because I lack background on buildout 1 vs. 2: I know work was done to support 2 and I guess it is good to follow upstream releases, but I have no idea how hard it is to upgrade or the constraints @gabriel has (btw, I do not see a post from gabriel above, is gitlab broken or did it happen outside ?).

  • I did not get notified too.

    @vpelletier, It happening in my test suite that is broken.

    2017-08-30 19:53:28,061 testsuite    : INFO     slapgrid_cp : 2017-08-30 19:53:28 
    slapos[6717] INFO     return f()
    2017-08-30 19:53:28,061 testsuite    : INFO     slapgrid_cp : 2017-08-30 19:53:28 
    slapos[6717] INFO   File 
    "/srv/slapgrid/slappart9/srv/testnode/atv/soft/3d31c3ca2d49f7ad5f1d66dc2ea9f187/parts/slapos.cookbook-repository/slapos/recipe/check_port_listening.py", line 56, in 
    install
    2017-08-30 19:53:28,062 testsuite    : INFO     slapgrid_cp : 2017-08-30 19:53:28 
    slapos[6717] INFO     'port': self.options['port'],
    2017-08-30 19:53:28,062 testsuite    : INFO     slapgrid_cp : 2017-08-30 19:53:28 
    slapos[6717] INFO KeyError: 'dash_S'

    I just ping @jm, because I saw my test suite broken and the commit. It means no constraints and no idea how hard it is to upgrade.

    I also agree that is good follow upstream releases. Then, let's try upgrade to buildout 2. @jm, any advice?

    /cc @aurel

  • I replied here before read all emails. This issue seems fixed by @aurel.

    Thanks

Please register or sign in to reply
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
import socket
import sys
addr = "%(hostname)s", %(port)s
try:
socket.create_connection(addr).close()
except (socket.error, socket.timeout):
sys.stderr.write("%%s on %%s isn't listening\n" %% addr)
sys.exit(127)
"""
class Recipe(GenericBaseRecipe):
"""
Check listening port promise
"""
def install(self):
config = dict(
hostname=self.options['hostname'],
port=self.options['port'],
python_path=sys.executable,
)
vnc_promise = self.createExecutable(
self.options['path'],
self.substituteTemplate(
self.getTemplateFilename('socket_connection_attempt.py.in'),
config))
promise = self.createExecutable(self.options['path'], template % {
'python': _safe_arg(sys.executable),
'hostname': self.options['hostname'],
'port': self.options['port'],
})
return [vnc_promise]
return [promise]
#!%(python_path)s
# BEWARE: This file is operated by slapgrid
# BEWARE: It will be overwritten automatically
import socket
import sys
hostname = "%(hostname)s"
port = %(port)s
try:
s = socket.create_connection((hostname, port))
s.close()
except (socket.error, socket.timeout):
sys.stderr.write("%(port)s on %(hostname)s isn't listening\n")
sys.exit(127)
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