Merge branch 'ent-8304-correccion-en-comportamiento-al-aplicar-politicas' into 'develop'

Fix db lock stopping policy apply

See merge request artica/pandorafms!4589
This commit is contained in:
Daniel Rodriguez 2021-12-27 12:46:17 +00:00
commit 02dfea8e58
4 changed files with 25 additions and 3 deletions

View File

@ -0,0 +1,5 @@
START TRANSACTION;
ALTER TABLE `tpolicy_queue` MODIFY COLUMN `progress` int(10) NOT NULL default '0';
COMMIT;

View File

@ -578,7 +578,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_queue` (
`id_policy` int(10) unsigned NOT NULL default '0',
`id_agent` int(10) unsigned NOT NULL default '0',
`operation` varchar(15) default '',
`progress` int(10) unsigned NOT NULL default '0',
`progress` int(10) NOT NULL default '0',
`end_utimestamp` int(10) unsigned NOT NULL default 0,
`priority` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)

View File

@ -2951,7 +2951,7 @@ CREATE TABLE IF NOT EXISTS `tpolicy_queue` (
`id_policy` int(10) unsigned NOT NULL default '0',
`id_agent` int(10) unsigned NOT NULL default '0',
`operation` varchar(15) default '',
`progress` int(10) unsigned NOT NULL default '0',
`progress` int(10) NOT NULL default '0',
`end_utimestamp` int(10) unsigned NOT NULL default 0,
`priority` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)

View File

@ -5540,7 +5540,24 @@ sub pandora_process_policy_queue ($) {
}
if($operation->{'operation'} eq 'apply' || $operation->{'operation'} eq 'apply_db') {
enterprise_hook('pandora_apply_policy', [$dbh, $pa_config, $operation->{'id_policy'}, $operation->{'id_agent'}, $operation->{'id'}, $operation->{'operation'}]);
my $policy_applied = enterprise_hook(
'pandora_apply_policy',
[
$dbh,
$pa_config,
$operation->{'id_policy'},
$operation->{'id_agent'},
$operation->{'id'},
$operation->{'operation'}
]
);
if($policy_applied == 0) {
sleep($pa_config->{'server_threshold'});
# Skip.
next;
}
}
elsif($operation->{'operation'} eq 'delete') {
if($operation->{'id_agent'} == 0) {