puppetlabs-docker icon indicating copy to clipboard operation
puppetlabs-docker copied to clipboard

Dependency cycle

Open BarnumD opened this issue 2 years ago • 3 comments

Describe the Bug

I've recently upgraded from v4.1.2 to v6.0.2 and ever since my server has been failing to run puppet.

A clear and concise description of what the bug is. There are two or more profiles being applied to the host. Each of the two include a docker_compose and docker::image, but the two are unique. This configuration was working in version 4.1.2.

We are now getting the following error: Error: Found 1 dependency cycle: (Docker_compose[elasticsearch] => Class[Profiles::elasticsearch] => Class[Profiles::traefik] => Docker::Image[traefik] => Exec[/usr/local/bin/update_docker_image.sh traefik:latest] => Docker::Image[traefik] => Docker_compose[elasticsearch])\nCycle graph written to /opt/puppetlabs/puppet/cache/state/graphs/cycles.dot. Error: Failed to apply catalog: One or more resource dependency cycles detected in graph

Expected Behavior

Puppet should check the image and compose and proceed with changes, but probably not do anything since no changes are required.

Steps to Reproduce

#Traefik profile
class profiles::traefik (
  $traefik_image_tag = 'latest'
){
  docker::image { 'traefik':
    image_tag => $traefik_image_tag,
  }

  docker_compose { 'traefik':
    ensure        => present,
    compose_files => ['/docker/traefik/docker-compose.yml'],
    subscribe     => File['/docker/traefik/docker-compose.yml'],
    require       => [File['/docker/traefik/docker-compose.yml'],File['/docker/traefik/traefik.yml'],File['/docker/traefik/traefik-dynamic.yml']],
  }
}

#ElasticSearch Profile
class profiles::elasticsearch (
  $elasticsearch_image_tag                  = '8.6.1',
){

  docker::image { 'elasticsearch':
    image_tag => $elasticsearch_image_tag,
  }

  docker_compose { 'elasticsearch':
    ensure        => present,
    compose_files => ['/docker/elasticsearch/docker-compose.yml'],
    subscribe     => File['/docker/elasticsearch/docker-compose.yml'],
  }
}

Environment

  • Module Version: 6.0.2
  • Puppet agent: 7.21.0
  • Platform: Ubuntu 22.04.

BarnumD avatar Feb 07 '23 22:02 BarnumD

I'd guess that the problem is that you have both require and subscribe to the compose files in the docker_compose resource. You only need subscribe, that already implies that the compose files are applied before the docker_compose.

kenyon avatar Feb 07 '23 22:02 kenyon

I removed require entirely, but got basically the same error. I subsequently removed subscribe but got the same.

(Docker_compose[elasticsearch] => Class[Profiles::elasticsearch] => Class[Profiles::traefik] => Docker::Image[traefik] => Exec[/usr/local/bin/update_docker_image.sh traefik:latest] => Docker::Image[traefik] => Docker_compose[elasticsearch])\nTry the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz

BarnumD avatar Feb 08 '23 13:02 BarnumD

I did some more testing and this problem exists in 4.2.0 and above, but not in 4.1.2.

If I remove the following it works, but not the other way around (if I remove docker::image { 'elasticsearch'

docker::image { 'traefik':
  image_tag => $traefik_image_tag,
}

BarnumD avatar Feb 08 '23 20:02 BarnumD