Make expire_nodes and expire_nodes_archive behave correctly

This commit is contained in:
Oliver Gorwits
2018-01-04 20:17:47 +00:00
parent 1c877ed4b3
commit 94f80f3c70
2 changed files with 33 additions and 26 deletions

View File

@@ -40,6 +40,14 @@ register_worker({ phase => 'main' }, sub {
});
}
# also have to clean up node_ip that have no correspoding node
schema('netdisco')->resultset('NodeIp')->search({
mac => { -in => schema('netdisco')->resultset('NodeIp')->search(
{ port => undef },
{ join => 'nodes', select => [{ distinct => 'me.mac' }], }
)->as_query },
})->delete;
if (setting('expire_jobs') and setting('expire_jobs') > 0) {
schema('netdisco')->txn_do_locked('admin', 'EXCLUSIVE', sub {
schema('netdisco')->resultset('Admin')->search({