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

Avoid potential dependency cycles when used with other modules #463

Merged
merged 7 commits into from
Dec 27, 2018

Conversation

remicalixte
Copy link
Contributor

Hopefully fixes the dependency cycle

Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

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

ensure_packages I believe is part of the puppet stdlib (see: https://github.com/puppetlabs/puppetlabs-stdlib#ensure_packages)... can you elaborate a little on how it creates a dependency cycle? Could you also add to the PR what the dependency cycle is?

Thanks!

@remicalixte
Copy link
Contributor Author

We require Package[apt-transport-https] to run Class[apt_update] but some other packages require the opposite, creating a dependency cycle. I know it is very ugly to install this package like this but I can't find any other solution. However, I can't reproduce the issue myself so I had to deduce this from some logs, thus I might be wrong

@remicalixte remicalixte force-pushed the remicalixte/puppet-dependency-cycle branch 2 times, most recently from 1ecda90 to d9bb827 Compare October 23, 2018 18:21
@remicalixte
Copy link
Contributor Author

The dependency cycle is Exec[apt_update] => Class[Apt::Update] => Package[apt-transport-https] => Apt::Source[datadog6] => Apt::Setting[list-datadog6] => File[/etc/apt/sources.list.d/datadog6.list] => Class[Apt::Update] => Exec[apt_update]

@remicalixte
Copy link
Contributor Author

remicalixte commented Oct 31, 2018

@truthbk

Dependency graph before:
expanded_relationships.pdf
Dependency graph after:
expanded_relationships.pdf

Since we don't use Package[apt-transport-https] anymore the Package[apt-transport-https] => Apt::Source[datadog6] link is gone and it should break the cycle.

Some external module is adding the Class[Apt::Update] => Package[apt-transport-https] link (Which is really weird) to the graph and causing the cycle. We have to break the cycle on the part of the graph we can control.

@remicalixte remicalixte force-pushed the remicalixte/puppet-dependency-cycle branch from d9bb827 to 207a6c1 Compare November 14, 2018 17:00
@remicalixte remicalixte changed the title Some improvements for the puppet module Avoid potential dependency cycles when used with other modules Nov 14, 2018
@remicalixte remicalixte force-pushed the remicalixte/puppet-dependency-cycle branch from 207a6c1 to 42c1ea0 Compare November 14, 2018 17:06
@remicalixte
Copy link
Contributor Author

@truthbk I've removed some unrelated changes and made the commit messages clearer. Hopefully we can merge this soon and release a new version of the puppet module

@remicalixte remicalixte force-pushed the remicalixte/puppet-dependency-cycle branch 2 times, most recently from 134765b to 685e919 Compare November 15, 2018 21:11
Copy link
Member

@truthbk truthbk left a comment

Choose a reason for hiding this comment

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

Some notes, in general the PR looks good, but if possible I would like to keep ensure_packages() around as a sane, standard way to ensure some required packages are available, I think that would be preferable. If you are sure we can't use it due to the dependency cycle, I understand.

We also need to make sure these changes don't make the module chatty, we don't want to be calling apt-get update every time the manifest runs.

Finally, I am unable to spot the cycle in the first PDF. Being a DAG I see no actual loops in the graph, but I may be missing something as I see repeated node names.

before => Apt::Source['datadog6'],
$key = {
'id' => $apt_key,
'server' => $apt_keyserver
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I can't remember if it's necessary to do this in case $skip_apt_key_trusting is true.

else  {
  $key = {}
}

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 guess it doesn't hurt to add it, and it is a bit more explicit

manifests/ubuntu/agent6.pp Show resolved Hide resolved
@@ -16,11 +16,14 @@
Optional[String] $apt_keyserver = undef,
) inherits datadog_agent::params {

ensure_packages(['apt-transport-https'])
exec { 'apt-transport-https':
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 like to continue using ensure_packages to be honest. I'm not sure how it would cause a cycle. If you're positive it's partly to blame we can go ahead and do this, but I'd rather not. Also, the line replaced should probably be:

ensure_packages(['apt-transport-https'], {'ensure' => 'present'})

require => Package['apt-transport-https'],
notify => Exec['apt_update'],
key => $key,
require => Exec['apt-transport-https'],
Copy link
Member

Choose a reason for hiding this comment

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

If we decide to keep ensure_packages, we could probably remove this line as ensure_packages would do its thing and ensure the package is available. I wonder if the reason this was here was due to the order in which puppet applied these statements, we'll have to test that out.

manifests/ubuntu/agent6.pp Show resolved Hide resolved
manifests/ubuntu/install_key.pp Show resolved Hide resolved
require => Package['apt-transport-https'],
notify => [Exec['datadog_apt-get_remove_agent6'],Exec['apt_update']],
key => $key,
require => Exec['apt-transport-https'],
Copy link
Member

Choose a reason for hiding this comment

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

As mentioned for A6, I would like to keep ensure_packages(), unless it's 100% clear that we cannot, and just remove this require.

@truthbk
Copy link
Member

truthbk commented Dec 19, 2018

Hoping to address: #423

@remicalixte remicalixte force-pushed the remicalixte/puppet-dependency-cycle branch from 685e919 to 7ef196e Compare December 19, 2018 21:19
@truthbk truthbk added this to the 2.4.0 milestone Dec 20, 2018
@truthbk truthbk merged commit 8a29860 into master Dec 27, 2018
@truthbk truthbk deleted the remicalixte/puppet-dependency-cycle branch December 27, 2018 12:34
truthbk added a commit that referenced this pull request Mar 21, 2019
truthbk added a commit that referenced this pull request Mar 21, 2019
cegeka-jenkins pushed a commit to cegeka/puppet-datadog_agent that referenced this pull request Apr 6, 2020
…og#463)

* Use native pgp key support of the apt module

* apt::source notify apt_update by default

* require Class['apt::update'] as the documentation suggests: https://github.com/puppetlabs/puppetlabs-apt\#adding-new-sources-or-ppas

* Use 'exec' instead of 'ensure_packages' to break a dependencies cycle with some other modules

* Fix spec tests

* Set $key to empty dict if skipping apt key trusting
cegeka-jenkins pushed a commit to cegeka/puppet-datadog_agent that referenced this pull request Apr 6, 2020
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.

2 participants