Skip to content

Commit 23ae2cb

Browse files
adamlazik1adamruzicka
authored andcommitted
Fixes #38468 - Reset HostProxyInvocations when rebuilding a host
Rebuilding a provisioned host in-place generates new host ssh keys, but does not reset the host-proxy mapping in the host_proxy_invocations table. As a result, the ssh keys are not pruned from the known hosts proxy file, and REX jobs won't succeed on the host because of the offending keys. Resetting host-proxy mapping solves this issue.
1 parent c42da6c commit 23ae2cb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app/models/concerns/foreman_remote_execution/host_extensions.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def self.prepended(base)
2828
end
2929
}
3030

31+
after_build :reset_host_proxy_invocations
32+
3133
def search_by_job_invocation(key, operator, value)
3234
if key == 'job_invocation.result'
3335
operator = operator == '=' ? 'IN' : 'NOT IN'
@@ -46,6 +48,10 @@ def search_by_job_invocation(key, operator, value)
4648
end
4749
end
4850

51+
def reset_host_proxy_invocations
52+
HostProxyInvocation.where(host_id: self.id).delete_all
53+
end
54+
4955
def cockpit_url
5056
ScriptExecutionProvider.cockpit_url_for_host(self.name)
5157
end

0 commit comments

Comments
 (0)