Skip to content

Commit

Permalink
Fixes compute object update failure due to autosign key after build
Browse files Browse the repository at this point in the history
  • Loading branch information
Manisha15 authored and sbernhard committed Sep 13, 2024
1 parent cc7fc16 commit d49ba1f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def inherited_attributes

validate :salt_modules_in_host_environment

after_build :ensure_salt_autosign, if: ->(host) { host.salt_proxy }
before_provision :ensure_salt_autosign, if: ->(host) { host.salt_proxy }
before_destroy :remove_salt_minion, if: ->(host) { host.salt_proxy }
end

Expand Down
7 changes: 3 additions & 4 deletions test/unit/host_extensions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,17 @@ class HostExtensionsTest < ActiveSupport::TestCase

context 'autosign handling' do
before do
@host = FactoryBot.create(:host, :managed)
@host = FactoryBot.create(:host, salt_autosign_key: 'asdfasdfasfasdf')
@host.salt_proxy = @proxy
stub_request(:post, "#{@proxy.url}/salt/autosign_key/asdfasdfasfasdf")
.to_return(status: 200, body: '', headers: {})
stub_request(:delete, "#{@proxy.url}/salt/key/#{@host.name}")
.to_return(status: 200, body: '', headers: {})
end

test 'host autosign is created when host is built' do
test 'host autosign is created before host is provisioned' do
autosign_key = 'asdfasdfasfasdf'
@host.expects(:generate_provisioning_key).returns(autosign_key)
@host.build = true
@host.build = false

assert @host.save!
@host.clear_host_parameters_cache!
Expand Down

0 comments on commit d49ba1f

Please sign in to comment.