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

[dd-agent] Add attribute to allow agent downgrade #359

Merged
merged 3 commits into from Sep 19, 2016

Conversation

Projects
None yet
2 participants
@olivielpeau
Copy link
Member

commented Sep 14, 2016

Still not allowed by default. Switching the attribute to true allows downgrades:

  • Straightforward for rhel/fedora: the yum and rpm package providers
    support a parameter that does just that
  • Uses --force-yes on debian because:
    1. there's no direct option on the apt
      provider
    2. apt-get supports a more fine-grained option
      (--allow-downgrades) since version 1.1 of apt, but it ships with
      ubuntu starting from 16.04 only, so we stick to using --force-yes. It could be nice to switch the option depending on the version of apt, but it'd add some complexity to the logic.

Notes on downgrading packages with apt

With apt, downgrading can be dangerous for packages that have dependencies/on which other packages depend. From dpkg's manpage, on downgrades:

Warning: At present dpkg does not do any dependency checking on downgrades and therefore will not warn you if the downgrade breaks the dependency of some other package. This can have serious side effects, downgrading essential system components can even make your whole system unusable.

This shouldn't be the case of the datadog-agent package so downgrading should be relatively safe.

Also, using --force-yes is equivalent to allowing remove-essential, downgrades and change-held-packages. None of these should be dangerous when applied to the datadog-agent package only. For reference see the manpage of apt 1.2: http://manpages.ubuntu.com/manpages/xenial/en/man8/apt-get.8.html

@degemer

This comment has been minimized.

Copy link
Member

commented Sep 14, 2016

Despite the Foodcritic warning, it works. If you don't find a way to fix it, I'm fine with silencing this error in this specific case.

Tested on Ubuntu 15.04 and Centos 7.0. 👍

@olivielpeau olivielpeau force-pushed the olivielpeau/allow-agent-downgrade branch 3 times, most recently from 3e2d26d to 544e665 Sep 15, 2016

@olivielpeau

This comment has been minimized.

Copy link
Member Author

commented Sep 15, 2016

@degemer The Foodcritic warning kind of makes sense, so I separated the package providers explicitly, let me know if you think it's worth it.

Also added spec tests on the new attribute

@olivielpeau olivielpeau added this to the 2.6.0 milestone Sep 15, 2016

@degemer
Copy link
Member

left a comment

A BC comment, I know you like them. No comment otherwise, and CI is broken on the url issue...

version dd_agent_version
action node['datadog']['agent_package_action'] # default is :install
allow_downgrade node['datadog']['agent_allow_downgrade']
end

This comment has been minimized.

Copy link
@degemer

degemer Sep 19, 2016

Member

If we want to be really cautious, we could add a default with the old resource.
List of all the Linux platform_family: https://github.com/chef/ohai/blob/af061dd99e771197b9aaec8c63a42b07a72662f2/lib/ohai/plugins/linux/platform.rb

I don't see anything missing, but...

This comment has been minimized.

Copy link
@olivielpeau

olivielpeau Sep 19, 2016

Author Member

Discussed this offline: since we're doing the same test in recipes/repository.rb, the cookbook doesn't work on other platforms anyway, so no need to fall back on a default here.

@@ -298,6 +306,98 @@ def set_env_var(name, value)
end
end

context 'package downgrade' do

This comment has been minimized.

Copy link
@degemer

olivielpeau added some commits Sep 14, 2016

[dd-agent] Add attribute to allow agent downgrade
Still not allowed by default. Switching the attribute to `true` allows
downgrades:

* Straightforward for rhel/fedora: the yum and rpm package providers
support a parameter that does just that
* Uses `--force-yes` on debian: there's no direct option on the apt
provider. `apt-get` supports a more fine-grained option
(`--allow-downgrades`) since version `1.1` of `apt`, but it ships with
ubuntu starting from `16.04` only, so we stick to using `--force-yes`.
Use different providers for debian and rhel
`allow_downgrade` is available on `yum_package` but not on the generic
`package` resource, so it makes sense to designate the provider
explicitely.

Also:
* update the spec tests to adapt to this change
* test that the `datadog-agent-base` package is removed

@olivielpeau olivielpeau force-pushed the olivielpeau/allow-agent-downgrade branch from 544e665 to f04306f Sep 19, 2016

@olivielpeau

This comment has been minimized.

Copy link
Member Author

commented Sep 19, 2016

CI is 💚 , merging, thanks @degemer!

@olivielpeau olivielpeau merged commit 2ac0f08 into master Sep 19, 2016

2 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@olivielpeau olivielpeau deleted the olivielpeau/allow-agent-downgrade branch Sep 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.