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

[provisioner] Add autoyast self update option #823

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nicolasbock
Copy link
Contributor

@nicolasbock nicolasbock commented Nov 23, 2016

AutoYaST can update itself before installing the OS. This patch enables
this feature and adds a field to the provisioner barclamp so that a
repository URL can be set by the user. The special token <ADMINWEB> resolves
to the IP:port of the admin node. An empty URL defaults to the SUSE
customer center (scc.suse.com).

@nicolasbock nicolasbock force-pushed the installer_update branch 3 times, most recently from b3caa83 to 910de87 Compare November 24, 2016 13:49
@@ -9,6 +9,8 @@
"access_keys": "",
"shell_prompt": "USER@HOST:CWD SUFFIX",
"enable_pxe": true,
"self_update": false,
"self_update_url": "http://updates.suse.com/sle12/$arch",
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we default this to a repo that is mirrored on the admin server, like all the other repos we have there?

Copy link
Member

Choose a reason for hiding this comment

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

Also, I'm not convinced we need a boolean to enable this or not. Either the repo is present locally (we enable), or the user provides an external URL (we enable), or the repo is not present locally and there's no url (we disable)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vuntz Thanks. I changed the PR.

@@ -26,6 +26,7 @@
<import_gpg_key config:type="boolean">true</import_gpg_key>
</signature-handling>
<storage/>
<self_update_url><%= @self_update_url %></self_update_url>
Copy link
Member

Choose a reason for hiding this comment

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

Didn't we want to add some unless @self_update_url.nil? || @self_update_url.empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done. Now, if the URL is empty AutoYaST will default to scc.suse.com if it's there.

@@ -9,6 +9,7 @@
"access_keys": "",
"shell_prompt": "USER@HOST:CWD SUFFIX",
"enable_pxe": true,
"self_update_url": "http://crowbar/sle12/$arch",
Copy link
Member

Choose a reason for hiding this comment

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

I would change the default to: http://<ADMINWEB>/suse-12.2/$arch/repos/installer-update (or something similar).

A couple of things:

  • <ADMINWEB> should be substituted in the rails app (see glance & tempest barclamps)
  • if we put suse-12.2 in the path, then maybe that attribute should live in a versioned suse attribute path somewhere (we already have that in the provisioner barclamp, I think)
  • we need a doc bug to document how to mirror that repo in the location

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -7,6 +7,9 @@
%span.help-block
= t(".access_keys_hint")

= boolean_field :self_update
Copy link
Member

Choose a reason for hiding this comment

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

This one is gone :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I removed it.

@@ -333,6 +334,8 @@ def find_node_boot_mac_addresses(node, admin_data_net)
web_port: web_port,
packages: packages,
repos: repos,
self_update_url: node[:provisioner][:self_update_url].gsub(
/<ADMINWEB>/, "#{admin_ip}:#{web_port}"),

Choose a reason for hiding this comment

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

Style/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.

@@ -21,6 +21,7 @@ en:
edit_attributes:
access_keys: 'Additional SSH keys'
access_keys_hint: 'Each SSH key must be on its own line'
self_update_url: 'AutoYaST Self-update URL (The alias <ADMINWEB> can be used to specify the admin node)'
Copy link
Member

Choose a reason for hiding this comment

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

s/admin node/admin server/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -9,6 +9,7 @@
"access_keys": "",
"shell_prompt": "USER@HOST:CWD SUFFIX",
"enable_pxe": true,
"self_update_url": "",
Copy link
Member

Choose a reason for hiding this comment

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

So we don't provide a default value that just works? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:) Well, the default in this case is to use scc.suse.com which works. But we could also use a crowbar local default. Which would you prefer?

Copy link
Member

Choose a reason for hiding this comment

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

I think the default should be the mirror on the admin server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, done.

@@ -290,6 +290,7 @@ def find_node_boot_mac_addresses(node, admin_data_net)
append << "ifcfg=dhcp4 netwait=60"
append << "squash=0" # workaround bsc#962397
append << "autoupgrade=1" if mnode[:state] == "os-upgrading"
append << "self_update"
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we pass this only if self_update_url is not empty?

Copy link
Member

Choose a reason for hiding this comment

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

Also, if the URL contains <ADMINWEB>, I think we could do some quick check with File.exists? so that if we use a default with <ADMINWEB> but the repo is not mirrored, we just don't enable the update feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added settings to autoyast.xml so that failures in self update don't mean failure anymore. AutoYaST will log those failure but continue with the installation process.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a check whether the repository is actually there.

Copy link
Member

Choose a reason for hiding this comment

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

I guess the check you mention here is still not there? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added it now.

return if all_nodes.empty?

nodes = NodeObject.find("roles:provisioner-server")
unless nodes.nil? or nodes.length < 1

Choose a reason for hiding this comment

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

Style/AndOr: Use || instead of or. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
Style/ZeroLengthPredicate: Use empty? instead of length < 1.

# "#{proposal["attributes"]["provisioner"]["self_update_url"]}"
# ))
# end
#end

Choose a reason for hiding this comment

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

Style/LeadingCommentSpace: Missing space after #. (https://github.com/bbatsov/ruby-style-guide#hash-space)

@@ -50,6 +51,21 @@ def validate_proposal_after_save proposal
end
end

@logger.info("validating existence of #{proposal["attributes"]["provisioner"]["self_update_url"]}")

#if /<ADMINWEB>/ =~ proposal["attributes"]["provisioner"]["self_update_url"]

Choose a reason for hiding this comment

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

Style/LeadingCommentSpace: Missing space after #. (https://github.com/bbatsov/ruby-style-guide#hash-space)

@@ -50,6 +51,21 @@ def validate_proposal_after_save proposal
end
end

@logger.info("validating existence of #{proposal["attributes"]["provisioner"]["self_update_url"]}")

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. [103/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)

@nicolasbock nicolasbock force-pushed the installer_update branch 2 times, most recently from 3e5c773 to d719711 Compare November 30, 2016 21:53
@nicolasbock
Copy link
Contributor Author

@vuntz Here is where I am at with this PR:

  • The self update feature is always enabled now
  • I added some settings to the autoyast file so that a missing or unavailable self update URL is not fatal. A warning is shown and after 10 seconds the installation process continues. The warning is logged and will show up in a supportconfig.
  • The default URL points to a mirrored repository on the admin server
  • We don't verify that that mirror exists and instead rely on the logged error message from AutoYaST. To verify we need to know the http server root directory and replace the proper parts of the URI with that directory. Since we don't know what arch we will deploy the role on, we have to be happy with any $arch and testing for that seemed more than a line of code. Of course I might very well not seeing the simple solution here, so please correct me if I am making this too complicated 😉.
  • An empty URL means update from scc.suse.com
  • I still don't fully understand how the defaults from a role end up in a node's attributes. This PR replaces the <ADMINWEB> shortcut in the chef recipe. I tried to follow the glance barclamp but couldn't get it to work here. i.e. if I replace <ADMINWEB> in apply_role_pre_chef_call in models/provider_service.rb the replace URI does not end up in the node.

@rsalevsky
Copy link
Member

@nicolasbock Can you please change the prefix from [provisioner] to provisioner:?

@nicolasbock
Copy link
Contributor Author

@rsalevsky oop, sorry, of course.

Copy link
Member

@aspiers aspiers left a comment

Choose a reason for hiding this comment

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

No commit message and no PR description => automatic -1 ;-p

@nicolasbock
Copy link
Contributor Author

@aspiers I have added a description to the commit. Could you have another look?

@@ -19,6 +19,7 @@
"access_keys": { "type": "str", "required": true },
"shell_prompt": { "type": "str", "required": true },
"enable_pxe": { "type": "bool", "required": true },
"self_update_url": { "type": "str", "required": true },
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I failed to notice this earlier on, but we have a suse attribute, and this should live in there. See line 56.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved

@@ -290,6 +290,7 @@ def find_node_boot_mac_addresses(node, admin_data_net)
append << "ifcfg=dhcp4 netwait=60"
append << "squash=0" # workaround bsc#962397
append << "autoupgrade=1" if mnode[:state] == "os-upgrading"
append << "self_update"
Copy link
Member

Choose a reason for hiding this comment

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

I guess the check you mention here is still not there? :-)

do_self_update = node[:provisioner][:suse][:autoyast][:do_self_update]
if do_self_update && ! expanded_self_update_url.empty?
do_self_update = system("wget --quiet --spider #{expanded_self_update_url.gsub("$arch", "#{arch}")}")
if ! do_self_update

Choose a reason for hiding this comment

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

Metrics/BlockNesting: Avoid more than 3 levels of block nesting. (https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count)
Style/NegatedIf: Favor unless over if for negative conditions. (https://github.com/bbatsov/ruby-style-guide#unless-for-negatives)
Style/SpaceAfterNot: Do not leave space between ! and its argument. (https://github.com/bbatsov/ruby-style-guide#no-space-bang)

)
do_self_update = node[:provisioner][:suse][:autoyast][:do_self_update]
if do_self_update && ! expanded_self_update_url.empty?
do_self_update = system("wget --quiet --spider #{expanded_self_update_url.gsub("$arch", "#{arch}")}")

Choose a reason for hiding this comment

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

Style/UnneededInterpolation: Prefer to_s over string interpolation.
Metrics/LineLength: Line is too long. [109/100] (https://github.com/SUSE/style-guides/blob/master/Ruby.md#metricslinelength)

"<ADMINWEB>", "#{admin_ip}:#{web_port}"
)
do_self_update = node[:provisioner][:suse][:autoyast][:do_self_update]
if do_self_update && ! expanded_self_update_url.empty?

Choose a reason for hiding this comment

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

Style/SpaceAfterNot: Do not leave space between ! and its argument. (https://github.com/bbatsov/ruby-style-guide#no-space-bang)

@nicolasbock nicolasbock force-pushed the installer_update branch 2 times, most recently from 69174ee to e0eb5d2 Compare January 10, 2017 14:14
if do_self_update && !expanded_self_update_url.empty?
do_self_update = system("wget --quiet --spider " +
"#{expanded_self_update_url.gsub("$arch", "#{arch}")}")
unless do_self_update

Choose a reason for hiding this comment

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

Metrics/BlockNesting: Avoid more than 3 levels of block nesting. (https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count)

do_self_update = node[:provisioner][:suse][:autoyast][:do_self_update]
if do_self_update && !expanded_self_update_url.empty?
do_self_update = system("wget --quiet --spider " +
"#{expanded_self_update_url.gsub("$arch", "#{arch}")}")

Choose a reason for hiding this comment

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

Style/UnneededInterpolation: Prefer to_s over string interpolation.

)
do_self_update = node[:provisioner][:suse][:autoyast][:do_self_update]
if do_self_update && !expanded_self_update_url.empty?
do_self_update = system("wget --quiet --spider " +

Choose a reason for hiding this comment

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

Style/LineEndConcatenation: Use \ instead of + or << to concatenate those strings.

do_self_update = node[:provisioner][:suse][:autoyast][:do_self_update]
if do_self_update && !expanded_self_update_url.empty?
do_self_update = system("wget --quiet --spider " \
expanded_self_update_url.gsub("$arch", "#{arch}"))

Choose a reason for hiding this comment

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

unexpected token tIDENTIFIER
unexpected token tRPAREN

@nicolasbock
Copy link
Contributor Author

@aspiers I have added a commit message and a PR comment.

@nicolasbock
Copy link
Contributor Author

@vuntz I think I have addressed the issues you raised. Could you have another look?

AutoYaST can update itself before installing the OS. This patch enables
this feature and adds a field to the provisioner barclamp so that a
repository URL can be set by the user. The special token `<ADMINWEB>` resolves
to the IP:port of the admin node. An empty URL defaults to the SUSE
customer center (scc.suse.com).
@aspiers
Copy link
Member

aspiers commented Jan 25, 2017

@nicolasbock Removed my -1. I can't give +1 because I don't even understand why autoyast would need to self-update :-) If there's newer autoyast code then why wouldn't it be simply provided via TFTP/HTTP the first time around?

@nicolasbock
Copy link
Contributor Author

@aspiers Thanks! Regarding your question: I haven't checked but am guessing that the autoyast comes from the image pulled from tftp on the admin node. I don't know though how and where from it is updated and I think your question is very valid 😄.

I forgot to add this Trello card.

@nicolasbock
Copy link
Contributor Author

@vuntz Could you have another look, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

8 participants