Skip to content

Commit

Permalink
(CAT-2052 Pass target container URI instead of container SHA ID to ad…
Browse files Browse the repository at this point in the history
…d_feature_to_node() method

There is a bug in the 'install_agent' task.
It is supposed to install the agent on a host (a VM or a docker container) using bolt and then add the 'puppet-agent' feature to the host in the litmus_inventory file.
Bolt returns the SHA ID of the container instead of the localhost URI after it installs the agent.
The feature is added through the add_feature_to_node() method. The last parameter of the method is being sent as result["target"]. This is fine in the case of VMs since its their IPv4 address and the method is expecting just that.
But in case of docker containers it is their SHA container ID and the method expecting the localhost:{port} URI. This results in the feature not being added to the host.
Since bolt is returning the results in the same order it is provided the input 'targets', we can add the feature by indexing the 'targets' array in that order.

See https://perforce.atlassian.net/browse/CAT-2052?focusedCommentId=2970824
  • Loading branch information
shubhamshinde360 committed Oct 1, 2024
1 parent 6700713 commit 8a020e5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/puppet_litmus/rake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
Rake::Task['spec_prep'].invoke

results = install_agent(args[:collection], targets, inventory_hash)
target_index = 0

Check warning on line 131 in lib/puppet_litmus/rake_tasks.rb

View check run for this annotation

Codecov / codecov/patch

lib/puppet_litmus/rake_tasks.rb#L131

Added line #L131 was not covered by tests
results.each do |result|
command_to_run = "bolt task run puppet_agent::install --targets #{result['target']} --inventoryfile spec/fixtures/litmus_inventory.yaml --modulepath #{DEFAULT_CONFIG_DATA['modulepath']}"
raise "Failed on #{result['target']}\n#{result}\ntry running '#{command_to_run}'" if result['status'] != 'success'
Expand Down Expand Up @@ -157,7 +158,8 @@
end

# add puppet-agent feature to successful nodes
inventory_hash = add_feature_to_node(inventory_hash, 'puppet-agent', result['target'])
inventory_hash = add_feature_to_node(inventory_hash, 'puppet-agent', targets[target_index])
target_index += 1

Check warning on line 162 in lib/puppet_litmus/rake_tasks.rb

View check run for this annotation

Codecov / codecov/patch

lib/puppet_litmus/rake_tasks.rb#L161-L162

Added lines #L161 - L162 were not covered by tests
end

# update the inventory with the puppet-agent feature set per node
Expand Down

0 comments on commit 8a020e5

Please sign in to comment.