-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add proper dry_run for OpenR #28
Comments
I was looking at the code and it is not as simple as implementing it within the openrd
I realized that piping is not possible with the current implementation of pexec in the router. Maybe an |
What you likely want is to launch openrd using One way to do that would be to rework how we use
def do_config_check(self):
out, err, code = self._node.pexec(shlex.split(self.dry_run))
if code:
lg.error(d.NAME, 'configuration check failed [ rcode:', str(code), ']\nstdout:',
str(out), '\nstderr:', str(err))
return code
import fcntl
import os
import time
# [...]
@property
def dry_run(self):
raise TypeError('OpenrDaemon requires to use its custom do_config_check')
def do_config_check(self):
p = self._node.popen('...')
# read p.stdout or p.stderr here and match on your target string
# naive example below
fcntl.fcntl(p.stdout.fileno(), fcntl.F_SETFL,
fcntl.fcntl(proc.stdout.fileno(), fcntl.F_GETFL) | os.O_NONBLOCK)
output = ''
start -= time.clock()
while True:
output += p.stdout.read(64)
if 'some_string' in output:
break
if start + time.clock() > 5:
p.terminate()
raise RuntimeError('OpenrDaemon took more than 5s to check the config')
time.sleep(.1)
p.terminate()
return perform_more_sanity_checks() The downside of this is that there would not be any integration with the current process management system that tries to ensure that all processes are cleaned up before the network is destroyed. |
Ok, this is exactly the direction I was thinking of. Maybe a decorator comes in handy. I need to study the cleanup code more. Thx for the guidance. |
Originally posted by @oliviertilmans in #18 (comment)
The dry_run for OpenR currently only calls the openr daemon with
--version
since it doesn't quit after parsing the config.The text was updated successfully, but these errors were encountered: