return $self->{plug}->watchdog_close($wfh);
}
-# hack to support regression tests
-sub can_fork {
+sub after_fork {
my ($self) = @_;
- return $self->{plug}->can_fork();
+ return $self->{plug}->after_fork();
}
-sub after_fork {
+# maximal number of workers to fork,
+# return 0 as a hack to support regression tests
+sub get_max_workers {
my ($self) = @_;
- return $self->{plug}->after_fork();
+ return $self->{plug}->get_max_workers();
}
1;
}
}
-sub can_fork {
- my ($self) = @_;
-
- return 1;
-}
-
sub after_fork {
my ($self) = @_;
PVE::Cluster::cfs_update();
}
+sub get_max_workers {
+ my ($self) = @_;
+
+ my $datacenterconfig = cfs_read_file('datacenter.cfg');
+
+ return $datacenterconfig->{max_workers} || 4;
+}
+
1;
my $starttime = $haenv->get_time();
- # start workers
- my $max_workers = 4;
+ # number of workers to start, if 0 we exec the command directly witouth forking
+ my $max_workers = $haenv->get_max_workers();
my $sc = $haenv->read_service_config();
my $count = $self->check_active_workers();
foreach my $sid (keys %{$self->{workers}}) {
- last if $count >= $max_workers;
+ last if $count >= $max_workers && $max_workers > 0;
+
my $w = $self->{workers}->{$sid};
if (!$w->{pid}) {
- if ($haenv->can_fork()) {
+ # only fork if we may else call exec_resource_agent
+ # directly (e.g. for regression tests)
+ if ($max_workers > 0) {
my $pid = fork();
if (!defined($pid)) {
$haenv->log('err', "fork worker failed");
return $self->{hardware}->watchdog_close($wfh);
}
-sub can_fork {
+sub after_fork {
my ($self) = @_;
- return 1;
+ # nothing to clean up in the simulation environment
}
-sub after_fork {
+
+sub get_max_workers {
my ($self) = @_;
- # nothing to clean up in the simulation environment
+ return 4;
}
1;
$self->{cur_time} += 1; # easier for simulation
}
-sub can_fork {
- my ($self) = @_;
-
- return 0;
-}
-
sub is_node_shutdown {
my ($self) = @_;
return defined($cstatus->{$node}->{shutdown}) ? 1 : 0;
}
+# must be 0 as we do not want to fork in the regression tests
+sub get_max_workers {
+ my ($self) = @_;
+
+ return 0;
+}
+
1;