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

[SHACK-179] Support for upgrading chef-client #112

Merged
merged 4 commits into from
May 10, 2018

Conversation

marcparadise
Copy link
Member

@marcparadise marcparadise commented May 9, 2018

This change updates the install action to verify that the target host
is running a minimum chef client version, and show an error when they are not.

It contains the logic to automatically upgrade, but that path has been disabled until
we determine how to best safely handle automatic upgrades.

The converge command and i18n has been updated to report
whether an upgrade or install is being performed, and to include
version info in install messages.

This also includes:

  • beginning to consolidate all things that rae in the domain of the target system (mappings of OS, platform, etc) into TargetHost.
  • error handling within actions so that command is notified of a raised exception. Implemented a default notification handler that accepts the error notification and marks the current task as failed via the reporter. This corrects an issue where a failed action would correctly report the error, but the visual status was never updated to reflect the failure.

TODO:

  • add flag to disable install/upgrade
  • error if install/ugprade is disabled and target does not have chef or does not have it at the minimum version
  • tests for new functionality of target_host
  • ensure we properly raise UnsupportedOS - currently this lives in the action, but it should probably now move to TargetHost
    • Where it is now works, but a minor refactor would make it make more sense. I'll add a card...
  • Remove TODO around old versions - tball's suggestion below is the default behavior with the current logic.

Copy link
Contributor

@tyler-ball tyler-ball left a comment

Choose a reason for hiding this comment

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

One minor comment but I think this is looking good so far

# installer action
end
manifest_content = backend.file(manifest_path).content
# TODO - handle where it is installed, but at such an old version there is no manifest?
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems something worth fixing as part of this PR. Perhaps if the manifest file does not exist we can return a version of 0.0.0? That would force an upgrade

Copy link
Member Author

Choose a reason for hiding this comment

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

It occurs to me that we do, indirectly - if the file content is nil, we treat it as not installed.

We plan to support a wide range of target operating systems,
but during this targeted pre-release we are constraining our efforts
We plan to support a range of target operating systems,
but during this targeted beta we are constraining our efforts
to Windows and Linux.

Choose a reason for hiding this comment

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

Windows and Linux but not OSX?

Copy link
Member Author

Choose a reason for hiding this comment

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

For the target host, yeah - at least for now: https://chefio.slack.com/archives/C8PKULC6S/p1525963099000551

@marcparadise
Copy link
Member Author

Outstanding items have been completed. There is further discussion around whether we want the default desired behavior to be an upgrade, or if this should require explicit action on the part of the operator. Any changes as a result of that discussion will be implemented under a separate PR.

@@ -3,20 +3,11 @@
require "chef-workstation/action/install_chef/linux"

module ChefWorkstation::Action::InstallChef
def self.instance_for_target(target_host, opts = {})
def self.instance_for_target(target_host, opts = { check_only: false })
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved the 'unsupported os' logic into TargetHost, so that we can start the process of not scattering OS-specific behaviors in places that don't need to worry about it.

jonsmorrow
jonsmorrow previously approved these changes May 10, 2018
Copy link
Contributor

@jonsmorrow jonsmorrow left a comment

Choose a reason for hiding this comment

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

This is a tentative approval pending our conversation at standup about wether we want to default to upgrade or not.

requires a minimum version of %2.

Re-running this command without the '--no-install' flag will permit
me to automatically upgrade the target to the latest Chef client.
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need to change this but we should decide what we want. I personally don't like tools the personify themselves such as 'me' in this message. I'd rather see it say something like:

Re-running this command without the '--no-install' flag will automatically perform the installation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm alright with the new wording. In general I like personification for a couple of reasons:

  1. it gives more of a feel with interacting with an agent doing work on your behalf
  2. it avoid awkward phrasing that exists only to avoid naming a sentence subject. (Your suggestion avoids this pitfall)

tyler-ball
tyler-ball previously approved these changes May 10, 2018
Copy link
Contributor

@tyler-ball tyler-ball left a comment

Choose a reason for hiding this comment

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

One request but 🚀 🍰 otherwise!

long: "--[no-]install",
default: true,
description: T.install_description(Action::InstallChef::Base::MIN_CHEF_VERSION)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs boolean: true also

jonsmorrow
jonsmorrow previously approved these changes May 10, 2018
Copy link
Contributor

@jonsmorrow jonsmorrow left a comment

Choose a reason for hiding this comment

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

LGTM

# will get re-visited once we determine how we want automatic
# upgrades to behave.
# @upgrading = true
# perform_local_install
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the comment

cheeseplus
cheeseplus previously approved these changes May 10, 2018
jonsmorrow
jonsmorrow previously approved these changes May 10, 2018
This change updates the install action to perform installation
when chef client is present on the target, but below minimum version.

The converge command and i18n has been updated to report
whether an upgrade or install is being performed, and to include
version info in install messages.
The --no-install flag will prevent install or upgrade of the target's
chef client installation. If an update or installation is required,
an appropriate error message is shown with instructions on permitting
the change.

This also improves in-task error handling so that the
UI gets a chance to be refreshed when a task fails. Previously
the error would be reported, but the summary 'spinner' line would
never be updated for the failure.
This continues the move of consolidating all target-related
lookups and translations into TargetHost, which is the only place
that should need to know about them.

This change also adds test coverage for the new TargetHost
methods get_chef_version_manifest, base_os, and installed_chef_version.
Until we determine how we want to handle upgrading chef client
on workstation-managed nodes, we have decided to disable the
behavior of automatically upgrading out-of-date chef clients

This changes the wording of CHEFINS003 to reflect that, and
changes the install action so that it will simply raise if
the chef client installation is out of date instead of conditionally
continuing.
@marcparadise marcparadise merged commit e8417d7 into master May 10, 2018
@chef-ci chef-ci deleted the SHACK-179/upgrade-client branch May 10, 2018 18:50
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.

4 participants