Skip to content

Commit 32857f4

Browse files
committed
worker: disconnect dbus from NameOwnerChanged signal (POO #183833)
This avoids us piling up signals we never handle and eventually exceeding a dbus quota limit and causing all subsequent tap jobs to fail. New Net::DBus instances are automatically connected to this signal on creation, you cannot change this. If the instance is kept around but nothing iterates the dbus event loop once in a while, that signal will just keep piling up messages indefinitely. We encountered this once before in os-autoinst and "solved" it by not persisting the dbus connection, but in this case it doesn't seem a good idea to re-initialize that connection every time we want to check on the status of a tap worker. So instead let's disconnect it from the signal. The 1 here is a bit magical. The Net::DBus connect_to_signal method issues signal numbers on a first-come, first-served basis, starting at 1 (0 is never used), and returns the number it issued. When Net::DBus _new calls it, though, it doesn't record the return value. So we have to know/guess that this will always be the first signal connected. Related ticket: https://progress.opensuse.org/issues/183833 Signed-off-by: Adam Williamson <[email protected]>
1 parent 371ad64 commit 32857f4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/OpenQA/Worker.pm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,12 @@ sub is_qemu_running ($self) {
611611
sub is_ovs_dbus_service_running ($self) {
612612
try { defined &Net::DBus::system or require Net::DBus }
613613
catch ($e) { return 0 }
614-
my $bus = ($self->{_system_dbus} //= Net::DBus->system(nomainloop => 1));
615-
try { return defined $bus->get_service('org.opensuse.os_autoinst.switch') }
614+
unless (defined $self->{_system_dbus}) {
615+
$self->{_system_dbus} = Net::DBus->system(nomainloop => 1);
616+
# this avoids piling up signals we never do anything with - POO #183833
617+
$self->{_system_dbus}->get_bus_object->disconnect_from_signal('NameOwnerChanged', 1);
618+
}
619+
try { return defined $self->{_system_dbus}->get_service('org.opensuse.os_autoinst.switch') }
616620
catch ($e) { return 0 }
617621
}
618622

t/24-worker-overall.t

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@ my $guard = scope_guard sub { chdir $FindBin::Bin };
8080
use Mojo::Base -base;
8181
has availability_error => 'Cache service info error: Connection refused';
8282
}
83+
{
84+
package Test::FakeDBusObject;
85+
use Mojo::Base -base, -signatures;
86+
sub disconnect_from_signal ($self, $signal, $id) {}
87+
}
8388
{
8489
package Test::FakeDBus; # uncoverable statement count:2
8590
use Mojo::Base -base, -signatures;
8691
has mock_service_value => 1;
8792
sub get_service ($self, $service_name) { $self->mock_service_value }
93+
sub get_bus_object ($self) { Test::FakeDBusObject->new }
8894
}
8995

9096
my $dbus_mock = Test::MockModule->new('Net::DBus', no_auto => 1);

0 commit comments

Comments
 (0)