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

(PE-10956) windows upgrade #66

Merged
merged 11 commits into from Feb 3, 2016

Conversation

highb
Copy link
Contributor

@highb highb commented Sep 25, 2015

Adds a PE-hosted MSI option for upgrading pre-2015 agents.

@highb
Copy link
Contributor Author

highb commented Sep 25, 2015

Spec tests need an update.

$file_dest = "C:\\Program Files\\Puppet Labs\\Puppet Enterprise\\packages\\${package_file_name}"
} else {
$source = "puppet:///pe_packages/${pe_server_version}/${::platform_tag}/${package_file_name}"
$dest = "/opt/puppetlabs/packages"
Copy link
Contributor

Choose a reason for hiding this comment

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

Ya, this was on my list of things to clean up. @highb what do you think about pulling this back into params, and then either plumbing it through alongside $package_file_name or referencing it as something like $pupppet_agent::params::local_packages_dir. Either way, we can then replace all the /opt/puppetlabs/packages references.

And then I think the reference to puppet_agent::prepare:: package::file_dest in install.pp just becomes this variable + package_file_name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jpartlow Yeah I think that makes more sense.

@highb highb force-pushed the master-pe-10956_windows_upgrade branch 2 times, most recently from 244d5d9 to 5522a92 Compare September 29, 2015 22:54
@highb
Copy link
Contributor Author

highb commented Oct 6, 2015

I was going crazy about this-- be rake spec locally showed all of the specs passing, so I couldn't figure out what was going on. Looking at the actual Travis failure...

be rake test
---> syntax:manifests
---> syntax:templates
---> syntax:hiera:yaml
manifests/osfamily/windows.pp - WARNING: unquoted resource title on line 7
manifests/params.pp - WARNING: double quoted string containing no variables on line 29
manifests/params.pp - WARNING: double quoted string containing no variables on line 51

I didn't even know there was a rake test Fixing the WARNINGs now.

@highb
Copy link
Contributor Author

highb commented Oct 6, 2015

OK, latest push should resolve the linter errors and this should finally be good to review and/or merge?

@jpartlow
Copy link
Contributor

jpartlow commented Oct 7, 2015

Looks like it's having issues with Puppet 3.8. Most of the specs and the module itself are constrained around the Puppet version.

@highb highb force-pushed the master-pe-10956_windows_upgrade branch from 9298f1f to 0f15b98 Compare October 7, 2015 17:01
@highb
Copy link
Contributor Author

highb commented Oct 7, 2015

@jpartlow Fixed! :)

@jpartlow
Copy link
Contributor

jpartlow commented Dec 4, 2015

I think we just need a test run of a 3.8.3->2015.3.0 upgrade with a windows agent.

@highb highb force-pushed the master-pe-10956_windows_upgrade branch from 0f15b98 to d62fdfa Compare December 8, 2015 23:43
@highb
Copy link
Contributor Author

highb commented Dec 8, 2015

Rebased this commit off the OSX/Solaris changes that just went in.

@highb
Copy link
Contributor Author

highb commented Dec 9, 2015

Confirmed rebased code upgrades Win2012 agents by

  1. Installing 3.8.3 on centos 7
  2. Installing 3.8.3 on Win2012
  3. Verifying mco/puppet runs work
  4. Upgrading to 2015.3 on centos 7 master
  5. Installing windows pe_repo
  6. Blocking access to pm.puppetlabs.com on windows agent
  7. Classifying puppet_agent with puppet_agent class
  8. puppet run on windows agent, verified mco ping

@jpartlow
Copy link
Contributor

rake test is exiting with linting failures

@jpartlow
Copy link
Contributor

@highb there's something wrong with the merge on this branch:

https://github.com/highb/puppetlabs-puppet_agent/blob/highb-master-pe-10956_windows_upgrade/manifests/init.pp#L37

I'm not sure how you were able to verify it? Did you do a rebase after testing?

@highb
Copy link
Contributor Author

highb commented Dec 15, 2015

@jpartlow That stray merge hash isn't in my local copy and when I force push, there are no changes. I'm re-running specs and tests locally to figure out what is happening.

@highb
Copy link
Contributor Author

highb commented Dec 15, 2015

retest this please

@highb
Copy link
Contributor Author

highb commented Dec 15, 2015

@highb
Copy link
Contributor Author

highb commented Dec 15, 2015

Oh, I've been running rake spec not rake test. I'll fix the linter errors.

@jpartlow
Copy link
Contributor

@highb Are your local changes synced with your remote? I'm still seeing the <<<< in the branch from your remote.

@highb highb force-pushed the master-pe-10956_windows_upgrade branch from d62fdfa to 9b40529 Compare December 15, 2015 20:31
@highb
Copy link
Contributor Author

highb commented Dec 15, 2015

@jpartlow Yeah, my changes should be synced. Make sure you're not pointing to the other (broken) branch I accidentally pushed highb-master-pe-10956_windows_upgrade

@jpartlow
Copy link
Contributor

@highb ok, that's sorted out on my end, so that just leaves the lint.

$package_name = 'puppet-agent'
$service_names = ['puppet', 'mcollective']

$local_packages_dir = 'C:\\Program Files\\Puppet Labs\\Puppet Enterprise\\packages'
Copy link
Contributor

Choose a reason for hiding this comment

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

This may not be the correct directory in situations where the user has installed puppet elsewhere, or when running 32-bit puppet on 64-bit windows. I think there's an env_windows_installdir fact that you can use: https://github.com/puppetlabs/puppet_for_the_win/blob/master/conf/windows/stage/bin/environment.bat#L8 /cc @Iristyle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that's helpful.

Copy link
Contributor

Choose a reason for hiding this comment

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

Another thought is to use C:\ProgramData\PuppetLabs instead (I think there's a PE common_appdata fact for that). If you write to C:\Program Files then those files will prevent puppet from uninstalling cleanly (it will leave behind the new files and any parent directories). It's not a big deal, but not ideal. Also if you are running puppet as "non-root", puppet may not have permission to write to C:\Program Files, but it can write to C:\ProgramData

@highb
Copy link
Contributor Author

highb commented Dec 15, 2015

I'm going to run through upgrading a w2012 agent with this patch again.

@highb highb force-pushed the master-pe-10956_windows_upgrade branch from 567eca1 to 056888e Compare December 16, 2015 00:04
@highb
Copy link
Contributor Author

highb commented Dec 16, 2015

Worked on upgrading a 3.8.3 agent to 2015.3, with one error in the run:
Could not evaluate: Cannot get status of mcollective, error was: The specified service does not exist as an installed service. - OpenService: The specified service does not exist as an installed service. Wrapped exception: The specified service does not exist as an installed service. - OpenService: The specified service does not exist as an installed service.

But subsequent runs can find mco/pxp-agent just fine and mco ping/runonce from the console work fine.

@highb
Copy link
Contributor Author

highb commented Dec 16, 2015

Tests are failing on puppet 3.8.1. Fun. Looking into what is going on there.

@highb highb force-pushed the master-pe-10956_windows_upgrade branch 2 times, most recently from a235715 to 4e4533c Compare December 16, 2015 21:33
Brandon High added 4 commits January 25, 2016 10:05
Prior to this commit the specs were not up to date with the
latest functionality from the module, specifically, the
new PE windows upgrade, which required some path changes.
Prior to this commit I decided to check for a null
`::puppet_agent::service_names`, but I've since
realized that should never really be null at this
point in the module.
This commit reverts the change I made to add a
null check to `::puppet_agent::service_names`.
These syntax errors were causing `rake test` to fail, so they
have been fixed in this commit.
Prior to this commit we were hardcoding the location of
the puppet install to `C:\Program Files\Puppet Labs\Puppet Enterprise`,
but we can't count on the location being set there.
This commit changes the location to use `common_appdata` which
even non-root users should have write access to.
@highb highb force-pushed the master-pe-10956_windows_upgrade branch from 6788ade to dc14d0f Compare January 25, 2016 18:14
@highb
Copy link
Contributor Author

highb commented Jan 25, 2016

Rebased everything, I'll run this through some testing.

@highb
Copy link
Contributor Author

highb commented Jan 25, 2016

image
Looks like Puppet might be having trouble dealing with the Windows service changing underneath it?

@highb
Copy link
Contributor Author

highb commented Jan 25, 2016

Aside from the strange service error on the first run with puppet_agent, the upgrade seems to work fine.

@highb
Copy link
Contributor Author

highb commented Jan 25, 2016

Seems like it might be a race condition with the MSI finishing install because post puppet run I have no problem interacting with the puppet and mcollective services:
image

@MikaelSmith
Copy link
Contributor

/cc @puppetlabs/windows

@MikaelSmith
Copy link
Contributor

Oh, shouldn't be trying to manage the service for Windows installs. The actual install happens with a script scheduled to run after Puppet finishes, and the MSI will ensure the service is started.

class { '::puppet_agent::install':
package_file_name => $_package_file_name,
} ->
class { '::puppet_agent::service': }
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be skipped or not do anything on Windows.

@highb
Copy link
Contributor Author

highb commented Jan 25, 2016

Ah, alright. I was starting to dive in to start /wait and how that works, but just leaving it all to the MSI is much easier. ;)

Prior to this commit we were attempting to manage the
puppet/mcollective services on Windows systems, which
resulted in errors in the puppet run due to the MSI being
in the middle of configuring those services.
This commit removes management of the puppet/mco services
on windows systems, because the MSI is handling that already
and attempting to manage it in puppet just creates a race
condition.
@highb highb force-pushed the master-pe-10956_windows_upgrade branch from 3d01dc2 to f4d74e5 Compare January 25, 2016 21:46
@highb
Copy link
Contributor Author

highb commented Jan 25, 2016

OK, tested this out on a mono 3.8.3->2015.3.2-rc upgrade with the change to not manage the service on windows, and I'm no longer seeing the error, as expected. I'd call this ready for someone to test/review again.

@jpartlow
Copy link
Contributor

@highb which Windows platform were you testing? I'm seeing failures upgrading 2008r2 64. (I'm updating the ticket with details.)

Ok the ticket has the details for reproduction and a Beaker log. In summary I'm seeing:

qubl1edmr2gecx6.delivery.puppetlabs.net (windows2008r2-64-1) 10:35:34$ cmd.exe /c puppet resource service puppet ensure=stopped
Error: Could not run: No such file or directory @ rb_sysopen - C:/ProgramData/PuppetLabs/puppet/cache/state/graphs/relationships.dot

after what seems like an otherwise successful puppet_agent upgrade of the windows node.

Prior to this commit our call to msiexec would not block until
the msi finished. This resulted in any commands dependent on
puppet that were run after a puppet_agent upgrade puppet run would
fail due to puppet still being in the middle of upgrading.
This commit adds a `start /wait` to the msiexec so that, hopefully,
we will block until the MSI finishes running and puppet is actually
upgraded.
@@ -6,7 +6,7 @@ FOR /F "tokens=*" %%A IN ('tasklist /FI "PID eq %AGENT_PID%" /NH') DO set _task=
echo %_task% | findstr "No tasks are running" >nul
IF NOT %errorlevel% == 0 ( GOTO wait_for_pid )

msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*v "<%= @_logfile %>"
start /wait msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*v "<%= @_logfile %>"
Copy link
Contributor

Choose a reason for hiding this comment

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

For reference, Beaker is always a good place to look to see how we install the Puppet MSI - https://github.com/puppetlabs/beaker/blob/f3d87f2b3463c2c49e1dd2b3e34b028336e7151e/lib/beaker/dsl/install_utils/windows_utils.rb#L18-L39

You've fixed the problem now with the /wait ... but I don't see the exit status being returned - i.e. exit /B %errorlevel%

Prior to this commit when re-installing the MSI on windows systems,
it would automatically revert the Puppet server setting to whatever
was defined when puppet was initially installed. If that value was
configured to be 'puppet' because no argument was given (as is the
case in beaker) then it would default back to 'puppet', even though
we had set the server to the appropriate master with beaker post-MSI
install.
This commit gets around that surprising behavior by always providing
the currently configured Puppet server value to the MSI.
@highb highb force-pushed the master-pe-10956_windows_upgrade branch from c7a758c to c2c3ef6 Compare January 29, 2016 23:08
@@ -6,7 +6,7 @@ FOR /F "tokens=*" %%A IN ('tasklist /FI "PID eq %AGENT_PID%" /NH') DO set _task=
echo %_task% | findstr "No tasks are running" >nul
IF NOT %errorlevel% == 0 ( GOTO wait_for_pid )

msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*v "<%= @_logfile %>"
start /wait msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*v "<%= @_logfile %>" PUPPET_MASTER_SERVER="<%= @_puppet_master %>"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

D'oh: note to future me, the settings::server is being read on the master. https://docs.puppetlabs.com/puppet/latest/reference/lang_facts_and_builtin_vars.html#puppet-master-variables So if I want to get the existing value, I should write a custom fact. :/

edit: This is fixed with the puppet_master_server fact added in 9b349a5

@highb
Copy link
Contributor Author

highb commented Feb 1, 2016

Tested with this change https://github.com/puppetlabs/pe_acceptance_tests/pull/836 and it works, but I need to change the use of settings::server to a custom fact that reads the server value from the config.

Prior to this commit we were setting the agent's `server` setting
to whatever `settings::server` was set to, which in a compile master
scenario, would be the MoM. This certainly isn't what a user would
want to have happen in production.
This commit creates a `puppet_master_server` fact populated with the
value of `Puppet.settings['server']` on the agent and uses that as the
argument to the windows MSI upgrade so we don't override the existing
config value with the default of `puppet` or whatever was written to
the registry on install.
@jpartlow
Copy link
Contributor

jpartlow commented Feb 1, 2016

Is the problem that puppet.conf is being overwritten, or just the server setting is being overwritten? If just the later, then this fix may be fine.

@highb
Copy link
Contributor Author

highb commented Feb 1, 2016

@jpartlow As far as I can tell, the MSI just overwrites the specific INI setting. So reading it before upgrading, then passing it in during the MSI run should preserve it. Even if it does mess up other settings, having the server correct should make it much easier to remediate any problems.

As for the settings::server problem, I've added the puppet_master_server fact to read the server value.

@mwbutcher
Copy link
Contributor

👍 successfully tested against windows2012r2 upgrading from puppet 3.8.5 to 4.3.2

mwbutcher added a commit that referenced this pull request Feb 3, 2016
@mwbutcher mwbutcher merged commit f3af4eb into puppetlabs:master Feb 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants