Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes compute object update failure due to autosign key after build #208

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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