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

With multiple sources in configuration only one is used #90

Closed
igalic opened this issue Feb 5, 2014 · 19 comments
Closed

With multiple sources in configuration only one is used #90

igalic opened this issue Feb 5, 2014 · 19 comments

Comments

@igalic
Copy link

igalic commented Feb 5, 2014

---
# The location to use for storing cached Git repos
:cachedir: '/var/cache/r10k'

# A list of git repositories to create
:sources:
  :hieradata:
    remote: 'ssh://git@git.example.com/hieradata'
    basedir: '/etc/puppet/hieradata'
  :local:
    remote: 'ssh://git@git.example.com/puppetmaster'
    basedir: '/etc/puppet/environments'

When running r10k -v 1 deploy environment we get the following:

[R10K::Git::Cache - DEBUG1] Execute: "git branch, args: {:git_dir=>\"/var/cache/r10k/ssh---git@git.example.com-hieradata\"}"
[R10K::Git::Cache - DEBUG2] [git branch, args: {:git_dir=>"/var/cache/r10k/ssh---git@git.example.com-hieradata"}] STDOUT: * production
  production_redux
[R10K::Git::Cache - DEBUG1] Execute: "git branch, args: {:git_dir=>\"/var/cache/r10k/ssh---git@git.example.com-puppetmaster\"}"
[R10K::Git::Cache - DEBUG2] [git branch, args: {:git_dir=>"/var/cache/r10k/ssh---git@git.example.com-puppetmaster"}] STDOUT:   antaflos_scaling_puppetmasters
  antaflos_testing
* production
  production_redux
[R10K::Task::Deployment::DeployEnvironments - INFO] Loading environments from all sources
[R10K::Git::Cache - DEBUG1] Execute: "git fetch --prune, args: {:git_dir=>\"/var/cache/r10k/ssh---git@git.example.com-hieradata\"}"
[R10K::Git::Cache - DEBUG1] Execute: "git branch, args: {:git_dir=>\"/var/cache/r10k/ssh---git@git.example.com-hieradata\"}"
[R10K::Git::Cache - DEBUG2] [git branch, args: {:git_dir=>"/var/cache/r10k/ssh---git@git.example.com-hieradata"}] STDOUT: * production
  production_redux
[R10K::Git::Cache - DEBUG1] Execute: "git fetch --prune, args: {:git_dir=>\"/var/cache/r10k/ssh---git@git.example.com-puppetmaster\"}"
[R10K::Git::Cache - DEBUG1] Execute: "git branch, args: {:git_dir=>\"/var/cache/r10k/ssh---git@git.example.com-puppetmaster\"}"
[R10K::Git::Cache - DEBUG2] [git branch, args: {:git_dir=>"/var/cache/r10k/ssh---git@git.example.com-puppetmaster"}] STDOUT:   antaflos_scaling_puppetmasters
  antaflos_testing
* production
  production_redux
[R10K::Task::Environment::Deploy - NOTICE] Deploying environment antaflos_scaling_puppetmasters
[R10K::Git::WorkingDir - DEBUG1] Execute: "git remote -v, args: {:path=>\"/etc/puppet/environments/antaflos_scaling_puppetmasters\"}"
[R10K::Git::WorkingDir - DEBUG2] [git remote -v, args: {:path=>"/etc/puppet/environments/antaflos_scaling_puppetmasters"}] STDOUT: cache        /var/cache/r10k/ssh---git@git.example.com-puppetmaster (fetch)
cache   /var/cache/r10k/ssh---git@git.example.com-puppetmaster (push)
origin  ssh://git@git.example.com/puppetmaster (fetch)
origin  ssh://git@git.example.com/puppetmaster (push)
[R10K::Git::WorkingDir - DEBUG1] Git repo /etc/puppet/environments/antaflos_scaling_puppetmasters cache remote already set correctly
[R10K::Git::WorkingDir - DEBUG1] Execute: "git fetch --prune cache, args: {:path=>\"/etc/puppet/environments/antaflos_scaling_puppetmasters\"}"
[R10K::Git::Cache - DEBUG1] Execute: "git rev-parse antaflos_scaling_puppetmasters^{commit}, args: {:git_dir=>\"/var/cache/r10k/ssh---git@git.example.com-puppetmaster\"}"
[R10K::Git::Cache - DEBUG2] [git rev-parse antaflos_scaling_puppetmasters^{commit}, args: {:git_dir=>"/var/cache/r10k/ssh---git@git.example.com-puppetmaster"}] STDOUT: c8a8aa898a08d2fd26b324ce8f9b0a9e61fe9228
[R10K::Git::WorkingDir - DEBUG1] Execute: "git rev-parse HEAD^{commit}, args: {:path=>\"/etc/puppet/environments/antaflos_scaling_puppetmasters\"}"
[R10K::Git::WorkingDir - DEBUG2] [git rev-parse HEAD^{commit}, args: {:path=>"/etc/puppet/environments/antaflos_scaling_puppetmasters"}] STDOUT: c8a8aa898a08d2fd26b324ce8f9b0a9e61fe9228
[R10K::Git::WorkingDir - DEBUG1] Git repo /etc/puppet/environments/antaflos_scaling_puppetmasters is already at c8a8aa898a08d2fd26b324ce8f9b0a9e61fe9228, no need to reset
[R10K::Task::Environment::Deploy - NOTICE] Deploying environment production_redux
[R10K::Git::WorkingDir - DEBUG1] Execute: "git remote -v, args: {:path=>\"/etc/puppet/environments/production_redux\"}"
[R10K::Git::WorkingDir - DEBUG2] [git remote -v, args: {:path=>"/etc/puppet/environments/production_redux"}] STDOUT: cache      /var/cache/r10k/ssh---git@git.example.com-puppetmaster (fetch)
cache   /var/cache/r10k/ssh---git@git.example.com-puppetmaster (push)
origin  ssh://git@git.example.com/puppetmaster (fetch)
origin  ssh://git@git.example.com/puppetmaster (push)
[R10K::Git::WorkingDir - DEBUG1] Git repo /etc/puppet/environments/production_redux cache remote already set correctly
[R10K::Git::WorkingDir - DEBUG1] Execute: "git fetch --prune cache, args: {:path=>\"/etc/puppet/environments/production_redux\"}"
[R10K::Git::Cache - DEBUG1] Execute: "git rev-parse production_redux^{commit}, args: {:git_dir=>\"/var/cache/r10k/ssh---git@git.example.com-puppetmaster\"}"
[R10K::Git::Cache - DEBUG2] [git rev-parse production_redux^{commit}, args: {:git_dir=>"/var/cache/r10k/ssh---git@git.example.com-puppetmaster"}] STDOUT: c8b1b3fb2bf3df75ef056eb5386e43d93c680c68
[R10K::Git::WorkingDir - DEBUG1] Execute: "git rev-parse HEAD^{commit}, args: {:path=>\"/etc/puppet/environments/production_redux\"}"
[R10K::Git::WorkingDir - DEBUG2] [git rev-parse HEAD^{commit}, args: {:path=>"/etc/puppet/environments/production_redux"}] STDOUT: c8b1b3fb2bf3df75ef056eb5386e43d93c680c68
[R10K::Git::WorkingDir - DEBUG1] Git repo /etc/puppet/environments/production_redux is already at c8b1b3fb2bf3df75ef056eb5386e43d93c680c68, no need to reset
[R10K::Task::Environment::Deploy - NOTICE] Deploying environment production
[R10K::Git::WorkingDir - DEBUG1] Execute: "git remote -v, args: {:path=>\"/etc/puppet/environments/production\"}"
[R10K::Git::WorkingDir - DEBUG2] [git remote -v, args: {:path=>"/etc/puppet/environments/production"}] STDOUT: cache    /var/cache/r10k/ssh---git@git.example.com-puppetmaster (fetch)
cache   /var/cache/r10k/ssh---git@git.example.com-puppetmaster (push)
origin  ssh://git@git.example.com/puppetmaster (fetch)
origin  ssh://git@git.example.com/puppetmaster (push)
[R10K::Git::WorkingDir - DEBUG1] Git repo /etc/puppet/environments/production cache remote already set correctly
[R10K::Git::WorkingDir - DEBUG1] Execute: "git fetch --prune cache, args: {:path=>\"/etc/puppet/environments/production\"}"
[R10K::Git::Cache - DEBUG1] Execute: "git rev-parse production^{commit}, args: {:git_dir=>\"/var/cache/r10k/ssh---git@git.example.com-puppetmaster\"}"
[R10K::Git::Cache - DEBUG2] [git rev-parse production^{commit}, args: {:git_dir=>"/var/cache/r10k/ssh---git@git.example.com-puppetmaster"}] STDOUT: 226fb3cf7a5749ad24112eac09beda38885e424c
[R10K::Git::WorkingDir - DEBUG1] Execute: "git rev-parse HEAD^{commit}, args: {:path=>\"/etc/puppet/environments/production\"}"
[R10K::Git::WorkingDir - DEBUG2] [git rev-parse HEAD^{commit}, args: {:path=>"/etc/puppet/environments/production"}] STDOUT: 226fb3cf7a5749ad24112eac09beda38885e424c
[R10K::Git::WorkingDir - DEBUG1] Git repo /etc/puppet/environments/production is already at 226fb3cf7a5749ad24112eac09beda38885e424c, no need to reset
[R10K::Task::Environment::Deploy - NOTICE] Deploying environment antaflos_testing
[R10K::Git::WorkingDir - DEBUG1] Execute: "git remote -v, args: {:path=>\"/etc/puppet/environments/antaflos_testing\"}"
[R10K::Git::WorkingDir - DEBUG2] [git remote -v, args: {:path=>"/etc/puppet/environments/antaflos_testing"}] STDOUT: cache      /var/cache/r10k/ssh---git@git.example.com-puppetmaster (fetch)
cache   /var/cache/r10k/ssh---git@git.example.com-puppetmaster (push)
origin  ssh://git@git.example.com/puppetmaster (fetch)
origin  ssh://git@git.example.com/puppetmaster (push)
[R10K::Git::WorkingDir - DEBUG1] Git repo /etc/puppet/environments/antaflos_testing cache remote already set correctly
[R10K::Git::WorkingDir - DEBUG1] Execute: "git fetch --prune cache, args: {:path=>\"/etc/puppet/environments/antaflos_testing\"}"
[R10K::Git::Cache - DEBUG1] Execute: "git rev-parse antaflos_testing^{commit}, args: {:git_dir=>\"/var/cache/r10k/ssh---git@git.example.com-puppetmaster\"}"
[R10K::Git::Cache - DEBUG2] [git rev-parse antaflos_testing^{commit}, args: {:git_dir=>"/var/cache/r10k/ssh---git@git.example.com-puppetmaster"}] STDOUT: d356852700c385c0bbc37cf55103582cbef3f4cf
[R10K::Git::WorkingDir - DEBUG1] Execute: "git rev-parse HEAD^{commit}, args: {:path=>\"/etc/puppet/environments/antaflos_testing\"}"
[R10K::Git::WorkingDir - DEBUG2] [git rev-parse HEAD^{commit}, args: {:path=>"/etc/puppet/environments/antaflos_testing"}] STDOUT: d356852700c385c0bbc37cf55103582cbef3f4cf
[R10K::Git::WorkingDir - DEBUG1] Git repo /etc/puppet/environments/antaflos_testing is already at d356852700c385c0bbc37cf55103582cbef3f4cf, no need to reset
[R10K::Task::Deployment::PurgeEnvironments - INFO] Purging stale environments from /etc/puppet/hieradata
[R10K::Task::Deployment::PurgeEnvironments - INFO] Purging stale environments from /etc/puppet/environments
@igalic
Copy link
Author

igalic commented Feb 5, 2014

What we expect to happen is the same that happens when we only have :hieradata: stanza in r10k.yml. That is, for r10k to checkout the hieradata repo's branches into /etc/puppet/hieradata/

igalic@puppet01 /etc/puppet/hieradata % ls -lah
total 16K
drwxr-xr-x  4 root root 4,0K Feb  5 16:42 ./
drwxr-xr-x 16 root root 4,0K Feb  5 16:42 ../
drwxr-xr-x  7 root root 4,0K Feb  5 16:42 production/
drwxr-xr-x  7 root root 4,0K Feb  5 16:42 production_redux/
igalic@puppet01 /etc/puppet/hieradata %

and

igalic@puppet01 /etc/puppet/hieradata % ls -lah */
production/:
total 120K
drwxr-xr-x 7 root root 4,0K Feb  5 16:42 ./
drwxr-xr-x 4 root root 4,0K Feb  5 16:42 ../
-rw-r--r-- 1 root root 1,5K Feb  5 16:42 common.yaml
drwxr-xr-x 2 root root 4,0K Feb  5 16:42 domains/
drwxr-xr-x 2 root root 4,0K Feb  5 16:42 fqdn/
drwxr-xr-x 8 root root 4,0K Feb  5 16:42 .git/
-rw-r--r-- 1 root root    6 Feb  5 16:42 .gitignore
drwxr-xr-x 3 root root 4,0K Feb  5 16:42 os/
drwxr-xr-x 4 root root 4,0K Feb  5 16:42 projects/
-rw-r--r-- 1 root root 6,5K Feb  5 16:42 repos.yaml
-rw-r--r-- 1 root root  72K Feb  5 16:42 ssldata.yaml
-rw-r--r-- 1 root root 3,5K Feb  5 16:42 users.yaml

production_redux/:
total 120K
drwxr-xr-x 7 root root 4,0K Feb  5 16:42 ./
drwxr-xr-x 4 root root 4,0K Feb  5 16:42 ../
-rw-r--r-- 1 root root 1,5K Feb  5 16:42 common.yaml
drwxr-xr-x 2 root root 4,0K Feb  5 16:42 domains/
drwxr-xr-x 2 root root 4,0K Feb  5 17:00 fqdn/
drwxr-xr-x 8 root root 4,0K Feb  5 16:42 .git/
-rw-r--r-- 1 root root    6 Feb  5 16:42 .gitignore
drwxr-xr-x 3 root root 4,0K Feb  5 16:42 os/
drwxr-xr-x 4 root root 4,0K Feb  5 16:42 projects/
-rw-r--r-- 1 root root 6,5K Feb  5 16:42 repos.yaml
-rw-r--r-- 1 root root  72K Feb  5 16:42 ssldata.yaml
-rw-r--r-- 1 root root 3,5K Feb  5 16:42 users.yaml
igalic@puppet01 /etc/puppet/hieradata %  

@adrienthebo
Copy link
Contributor

I've had confirmation from another user that this is happening, but I've been unable to figure out what's going on myself. I'll update this issue as soon as I can reproduce this issue.

@adrienthebo
Copy link
Contributor

@igalic I think that I'm going to need more debug info from your end of things because I'm still unable to reproduce this. If rolled a new branch with improved logging for you would you be able to build a gem from that source and install it?

And for the heck of it could you try http://rubygems.org/gems/r10k/versions/1.2.0rc1 and see if it fixes anything for you?

@igalic
Copy link
Author

igalic commented Feb 13, 2014

@antaflos ping

@igalic
Copy link
Author

igalic commented Feb 17, 2014

Tested now on my own, this seems to work out perfectly fine

igalic@levix ~/src/puppet % ~/.gem/ruby/1.9.1/bin/r10k deploy -v 3 --config ./r10k.yaml environment
[R10K::Task::Deployment::DeployEnvironments - INFO] Loading environments from all sources
[R10K::Task::Environment::Deploy - NOTICE] Deploying environment antaflos_scaling_puppetmasters
[R10K::Task::Environment::Deploy - NOTICE] Deploying environment antaflos_testing
[R10K::Task::Environment::Deploy - NOTICE] Deploying environment production
[R10K::Task::Environment::Deploy - NOTICE] Deploying environment production_redux
[R10K::Task::Deployment::PurgeEnvironments - INFO] Purging stale environments from ./environment
[R10K::Task::Deployment::PurgeEnvironments - INFO] Purging stale environments from ./hieradata
igalic@levix ~/src/puppet % ls -l ./hieradata
total 8
drwxr-xr-x 7 igalic igalic 4096 Feb 17 12:44 production/
drwxr-xr-x 8 igalic igalic 4096 Feb 17 12:44 production_redux/
igalic@levix ~/src/puppet % ls -l ./hieradata/production
total 108
-rw-r--r-- 1 igalic igalic  1559 Feb 17 12:44 common.yaml
drwxr-xr-x 2 igalic igalic  4096 Feb 17 12:44 domains/
drwxr-xr-x 2 igalic igalic  4096 Feb 17 12:44 fqdn/
drwxr-xr-x 3 igalic igalic  4096 Feb 17 12:44 os/
drwxr-xr-x 4 igalic igalic  4096 Feb 17 12:44 projects/
-rw-r--r-- 1 igalic igalic  6607 Feb 17 12:44 repos.yaml
-rw-r--r-- 1 igalic igalic 77814 Feb 17 12:44 ssldata.yaml
-rw-r--r-- 1 igalic igalic  3515 Feb 17 12:44 users.yaml
igalic@levix ~/src/puppet % ~/.gem/ruby/1.9.1/bin/r10k deploy -v 3 --config ./r10k.yaml module profile
[R10K::Task::Puppetfile::DeployModules - DEBUG] Updating module list for Puppetfile ./environment/antaflos_scaling_puppetmasters
[R10K::Task::Puppetfile::DeployModules - WARN] Unable to deploy module profile: not listed in ./environment/antaflos_scaling_puppetmasters/Puppetfile
[R10K::Task::Puppetfile::DeployModules - DEBUG] Updating module list for Puppetfile ./environment/antaflos_testing
[R10K::Task::Module::Sync - INFO] Deploying profile into ./environment/antaflos_testing/modules
[R10K::Task::Puppetfile::DeployModules - DEBUG] Updating module list for Puppetfile ./hieradata/production
[R10K::Puppetfile - DEBUG] Puppetfile "./hieradata/production/Puppetfile" missing or unreadable
[R10K::Task::Puppetfile::DeployModules - WARN] Unable to deploy module profile: not listed in ./hieradata/production/Puppetfile
[R10K::Task::Puppetfile::DeployModules - DEBUG] Updating module list for Puppetfile ./hieradata/production_redux
[R10K::Puppetfile - DEBUG] Puppetfile "./hieradata/production_redux/Puppetfile" missing or unreadable
[R10K::Task::Puppetfile::DeployModules - WARN] Unable to deploy module profile: not listed in ./hieradata/production_redux/Puppetfile
1 igalic@levix ~/src/puppet %

@igalic
Copy link
Author

igalic commented Feb 17, 2014

Here's the appropriate configuration file:

---
:cachedir: '/var/tmp/r10k-cache'

# A list of git repositories to create
:sources:
   :manifests:
       remote: 'git@git.es.at:dc01-puppetmaster'
       basedir: './environment'
   :hieradata:
       remote: 'git@git.es.at:dc01-hieradata'
       basedir: './hieradata'

@igalic
Copy link
Author

igalic commented Feb 17, 2014

hrm… I just realized we're getting a lot of problems with this new version(?) in that the checked out repos end up being detached heads that then, on a subsequent run are not being updated.

@adrienthebo
Copy link
Contributor

Okay, let's not worry about 1.2.0 for now if it's generating more problems. I'll push a branch with better logging statements shortly.

@adrienthebo
Copy link
Contributor

In addition does this behavior occur regardless of if --puppetfile is specified?

@antaflos
Copy link
Contributor

This is tricky to test and reproduce as there seems to be a bit of randomness to this problem.

I observe that in a configuration like @igalic posted above when there are identically named branches in both repos, r10k ignores these branch names in one of the repos but not the other.

I just tested this on my home machine with this config:

:cachedir: './r10k-cache'

# A list of git repositories to create
:sources:
  :puppetmaster:
    remote: 'ssh://git@git.example.com/dc01-puppetmaster'
    basedir: './puppet/environments'
  :hiera:
    remote: 'ssh://git@git.example.com/dc01-hieradata'
    basedir: './puppet/hieradata'

After running r10k -v 2 deploy environment I get the following directory structure:

ant@home [~/vagrant_puppet_dev] $ tree -L 2 puppet/
puppet/
├── environments
│   ├── antaflos_scaling_puppetmasters
│   └── antaflos_testing
└── hieradata
    ├── production
    └── production_redux

6 directories, 0 files

The repo dc01-puppetmaster also has branches production andproduction_redux but as you can see they are missing and were apparently completely ignored and not deployed in ./puppet/environments. Subsequent invocations of, say, r10k deploy environment production_redux only update the tree in ./puppet/hieradata/production_redux.

This seems to happen regardless of specifying --puppetfile but I am currently running a new test with r10k -v 3 deploy environment --puppetfile and an empty ./puppet directory. Will report back when it is finished (takes quite some time).

This is still using r10k 1.1.3, on Ubuntu 13.10, Ruby 1.9.3p194.

@antaflos
Copy link
Contributor

Just finished running r10k -v 3 deploy environment --puppetfile but the behaviour is the same:

ant@home [~/vagrant_puppet_dev/puppet] $ tree -L 2 puppet/
puppet/
├── environments
│   ├── antaflos_scaling_puppetmasters
│   └── antaflos_testing
└── hieradata
    ├── production
    └── production_redux

6 directories, 0 files

@adrienthebo
Copy link
Contributor

@antaflos that was it, I was able to duplicate the issue, thanks for your help on that! Now that I can reproduce this hopefully I'll be able to figure out what the expletive is going on.

@adrienthebo
Copy link
Contributor

Aaaaand I found it. https://github.com/adrienthebo/r10k/blob/master/lib/r10k/task/deployment.rb#L15-L18 when creating a lookup table of Hash<environment name => environment>, environments with the same names stomp each other.

facepalm

@antaflos
Copy link
Contributor

Great to hear you got to the bottom of this! 👍

@glarizza
Copy link

Yeah, I hit this back in #48 with https://gist.github.com/glarizza/5a81e45f2f489d87d464 and back then it was thought prefixing would fix this. It DOES fix the problem, but it's not the best of solutions (i.e. you shouldn't HAVE to use prefixing just to avoid this). Having some way for R10k to track all the environments regardless of name while also NOT requiring them to prefix is totally ideal (and may eliminate the need to prefix, really).

adrienthebo added a commit that referenced this issue Feb 25, 2014
Previously, when environments were being interacted with, a lookup table
was being created of names and associated environments for determining
what environments should be acted upon. However this didn't take into
account multiple sources where multiple environments could coexist with
the same name. In this case the duplicate environments would be silently
ignored.

This is resolved by getting rid of the lookup table and just scanning a
list of environments with the given names. It's a bit slower can could
theoretically take a fair amount of time, but that would require a
situation with 1k+ environments. For most normal operations
this will be very fast, and won't have the same collision issues.
@adrienthebo
Copy link
Contributor

I've released 1.1.4 (http://rubygems.org/gems/r10k/versions/1.1.4) which contains this fix, let me know if it works and I'll close out this issue. Thanks again for all the help!

@antaflos
Copy link
Contributor

Woohoo, this works now! Tested on my home machine and then in our productive Puppet infrastructure.

Most excellent, thanks a lot @adrienthebo! 👍

@glarizza
Copy link

RIGHT after my post! Well done, Finch - I dig :)

On Monday, February 24, 2014, Andreas Ntaflos notifications@github.com
wrote:

Woohoo, this works now! Tested on my home machine and then in our
productive Puppet infrastructure.

Most excellent, thanks a lot @adrienthebo https://github.com/adrienthebo!
[image: 👍]

Reply to this email directly or view it on GitHubhttps://github.com//issues/90#issuecomment-35967160
.

Gary Larizza
Professional Services Engineer
Puppet Labs

@adrienthebo
Copy link
Contributor

Glad to hear it was resolved! And @glarizza, sorry this was an outstanding issue for you for so long - I was completely at a loss as to what was going on until a few days ago!

sarameisburger pushed a commit to sarameisburger/r10k that referenced this issue Apr 12, 2019
(RE-8029) gettext gems now conflict with puppet-agent
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

No branches or pull requests

4 participants