Skip to content
Open
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
4 changes: 4 additions & 0 deletions chef/cookbooks/provisioner/recipes/update_nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ def find_node_boot_mac_addresses(node, admin_data_net)
cloud_available = true if name.include? "Cloud"
end

ntp_servers = search(:node, "roles:ntp-server")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use search_env_filtered

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't seem to be very consistent on this. there is no other usage of search_env_filtered in crowbar-core (actually I can find it only in the nova barclamp, which is strange..)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

search_env_filtered (and get_instance) should only be used when a proposal references another proposal through its attributes. It's not the case here, as the provisioner proposal doesn't reference the ntp proposal.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you replace this line with:

          ntp_instance = CrowbarHelper.get_proposal_instance(node, "ntp", "default")
          ntp_servers = node_search_with_cache("roles:ntp-server", ntp_instance)

Copy link
Copy Markdown
Member

@aspiers aspiers Feb 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vuntz Why can't it retrieve the servers from the new config databag, like in #947?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible now; my comment was from before this got merged :-)

ntp_servers_ips = ntp_servers.map { |n| Chef::Recipe::Barclamp::Inventory.get_network_by_type(n, "admin").address }
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. 125/100

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a hint: you don't need the Chef::Recipe:: prefix (but that won't help with the hound warning)

Copy link
Copy Markdown
Member

@rsalevsky rsalevsky Jul 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a multiline do block should do the trick here and hound should be happy.

ntp_servers_ips = ntp_servers.map do |n|  
    Chef::Recipe::Barclamp::Inventory.get_network_by_type(n, "admin").address
end


autoyast_template = mnode[:state] == "os-upgrading" ? "autoyast-upgrade" : "autoyast"
template "#{node_cfg_dir}/autoyast.xml" do
mode 0644
Expand All @@ -341,6 +344,7 @@ def find_node_boot_mac_addresses(node, admin_data_net)
node_ip: mnode[:crowbar][:network][:admin][:address],
node_fqdn: mnode[:fqdn],
node_hostname: mnode[:hostname],
ntp_servers: ntp_servers_ips,
platform: target_platform_distro,
target_platform_version: target_platform_version,
architecture: arch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<final_reboot config:type="boolean">false</final_reboot>
<halt config:type="boolean">false</halt>
<second_stage config:type="boolean">true</second_stage>
<ntp_sync_time_before_installation><%= @ntp_servers.first %></ntp_sync_time_before_installation>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will possibly fail if there are no ntp servers configured; don't know how autoyast behaves in that case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From AutoYaST:

Please keep in mind that you need a reachable NTP server and network connections while running the installation.

which sounds like the installation will fail in case of a missing NTP server.

</mode>
<mouse>
<id>none</id>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<final_reboot config:type="boolean">false</final_reboot>
<halt config:type="boolean">false</halt>
<second_stage config:type="boolean">true</second_stage>
<ntp_sync_time_before_installation><%= @ntp_servers.first %></ntp_sync_time_before_installation>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dirkmueller can you add something like <% unless @ntp_servers.empty? -%> to protect against an empty list of ntp servers?

</mode>
<mouse>
<id>none</id>
Expand Down