waitForUnit: Fail if the unit reaches inactive state with no pending jobs

This prevents waitForUnit for looping for many minutes before giving
up.
This commit is contained in:
Eelco Dolstra 2015-12-30 12:40:29 +01:00
parent e78bad5262
commit 146c727924

View File

@ -381,6 +381,11 @@ sub waitForUnit {
my $info = $self->getUnitInfo($unit);
my $state = $info->{ActiveState};
die "unit $unit reached state $state\n" if $state eq "failed";
if ($state eq "inactive") {
my ($status, $jobs) = $self->execute("systemctl list-jobs --full 2>&1");
die "unit $unit is inactive and there are no pending jobs\n"
if $jobs =~ /No jobs/; # FIXME: fragile
}
return 1 if $state eq "active";
};
});