7934db1
@@ -8,6 +8,7 @@
import shlex
import signal
import multiprocessing
+ import random
import socket
import subprocess
import sys
@@ -105,7 +106,8 @@
def start_qemu(image, cloudinit, log, portrange=(2222, 5555)):
- for port in range(*portrange):
+ for _ in range(10):
+ port = random.randint(*portrange)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
I'm working changing rpm-ostree to spawn VMs in parallel, and currently this races because we release the socket, then start qemu.
I have a plan for a reliable fix, but even with that let's use a random port since it makes collissions a lot less likely.
@walters Hi! I re-created you PR #188
It works for me.
TEST_SUBJECTS=/root/test_subject.qcow2 ./standard-inventory-qcow2 --list Launching virtual machine for /root/test_subject.qcow2 { "subjects": { "hosts": [ "/root/test_subject.qcow2" ], "vars": {} }, "_meta": { "hostvars": { "/root/test_subject.qcow2": { "ansible_ssh_common_args": "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no", "ansible_port": "5205", "ansible_ssh_private_key_file": "/tmp/inventory-cloudIWiVfP/identity", "ansible_python_interpreter": "/usr/bin/python3", "ansible_ssh_pass": "foobar", "ansible_user": "root", "ansible_host": "127.0.0.3" } } }, "localhost": { "hosts": [ "/root/test_subject.qcow2" ], "vars": {} } }[root@qeos-26 ~]#ssh 127.0.0.3 -p 5205 The authenticity of host '[127.0.0.3]:5205 ([127.0.0.3]:5205)' can't be established. ECDSA key fingerprint is SHA256:erggSrUEtds6JVvRbHAJFo72hBbKl0tbUWIuIc0mm7s. ECDSA key fingerprint is MD5:e3:14:8b:a4:f5:c6:a2:2e:7a:9c:1f:58:ba:ba:68:1e. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[127.0.0.3]:5205' (ECDSA) to the list of known hosts. root@127.0.0.3's password: Last login: Thu May 24 16:16:32 2018 from 10.0.2.2 [root@ibm-p8-kvm-03-guest-02 ~]# logout Connection to 127.0.0.3 closed. [root@qeos-26 ~]# TEST_DEBUG=1 TEST_SUBJECTS=/root/test_subject.qcow2 ./standard-inventory-qcow2 --list Launching virtual machine for /root/test_subject.qcow2 DIAGNOSE: qemu-kvm is running with VNC server. PID: 3564 { "subjects": { "hosts": [ "/root/test_subject.qcow2" ], "vars": {} }, "_meta": { "hostvars": { "/root/test_subject.qcow2": { "ansible_ssh_common_args": "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no", "ansible_port": "3497", "ansible_ssh_private_key_file": "/tmp/inventory-cloudJUycEc/identity", "ansible_python_interpreter": "/usr/bin/python3", "ansible_ssh_pass": "foobar", "ansible_user": "root", "ansible_host": "127.0.0.3" } } }, "localhost": { "hosts": [ "/root/test_subject.qcow2" ], "vars": {} } }
@walters Do you think it is OK to merge it? Thank you.
Yep, LGTM thanks!
@waters but it CI check fails with
https://jenkins-fedora-atomic-process.apps.ci.centos.org/job/str_pr_test/98/console
Running: inspekt indent /home/jenkins/workspace/str_pr_test/inventory/standard-inventory-qcow2 Indentation check PASS Running: inspekt lint --enable W0611,W0612,W0622 --disable W,R,C,E1002,E1101,E1103,E1120,F0401,I0011,E0611 /home/jenkins/workspace/str_pr_test/inventory/standard-inventory-qcow2 Pylint disabled: W,R,C,E1002,E1101,E1103,E1120,F0401,I0011,E0611 Pylint enabled : W0611,W0612,W0622 Syntax check FAIL ************* Module standard-inventory-qcow2 W0612:115,8: start_qemu: Unused variable 'tries'
rebased onto 7934db1
@walters updated, I changed
tries to _
pretty please pagure-ci rebuild
https://copr.fedorainfracloud.org/coprs/g/osci/standard-test-roles/build/758594/
ACK to merge.
I don't have merge access here AFAICS.
Commit 4e62020 fixes this pull-request
Pull-Request has been merged by astepano
I'm working changing rpm-ostree to spawn VMs in parallel, and
currently this races because we release the socket, then start
qemu.
I have a plan for a reliable fix, but even with that let's use a random port
since it makes collissions a lot less likely.