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

Purging all environments when specifying more than one #52

Closed
lutaylor opened this issue Aug 1, 2013 · 5 comments
Closed

Purging all environments when specifying more than one #52

lutaylor opened this issue Aug 1, 2013 · 5 comments

Comments

@lutaylor
Copy link

lutaylor commented Aug 1, 2013

We are currently having the following problem.

If we specify more than one git repo in our yaml file it will purge out the directories right after deploying them.

e.g.
...
[R10K::Task::Module::Sync - INFO] Deploying fedora into /etc/puppet/environments/metro/modules
[R10K::Task::Module::Sync - INFO] Deploying stackbase into /etc/puppet/environments/metro/modules
[R10K::Task::Deployment::PurgeEnvironments - INFO] Purging stale environments from /etc/puppet/environments
[R10K::Task::Deployment::PurgeEnvironments - INFO] Purging stale environments from /etc/puppet/environments

Here is our yaml file

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

# A list of git repositories to create
:sources:
 :metro:
   remote: 'git@github.com:discoverygardenpuppet/env_metro.git'
   basedir: '/etc/puppet/environments'
 :env_ir:
   remote: 'git@github.com:discoverygardenpuppet/env_ir.git'
   basedir: '/etc/puppet/environments'

:purgedirs:
  - '/etc/puppet/environments'

If we comment out either one and rerun it deploys fine and doesn't delete them after. I have tried deleting the /var/cache/r10k as well and it has no impact.

@Ancillas
Copy link

Ancillas commented Aug 1, 2013

I created a small workaround for this last week in my environment, but it's not good enough to be considered a patch.

https://gist.github.com/Ancillas/6135084

Line 72 is what I commented out to stop r10k from purging.

@adam-vessey
Copy link
Contributor

Been looking into this a bit... Looks like it's because both use the same "basedir", and so detect each others directories as being "stale"... So when the first purges it's stale stuff, it deletes those of the second, and then the second deletes those of the first. This seem to come out of a bad assumption made in https://github.com/adrienthebo/r10k/blob/master/lib/r10k/util/purgeable.rb#L21-L28, where assumes each "managed directory" is only used by a single source.

... I'm thinking that it may be necessary to:

  1. list the contents of each managed directory (in a hash of arrays?),
  2. iterate over each source and remove the "desired" contents from our listing
  3. delete all entries remaining in the listing from the filesystem

Poking around the code (and being new to Ruby), I'm not sure where would be the place to make this change... Alternatively, could make the created environments be prefixed with the name used in yaml? So in the example above, we might end up metro_dev, metro_test, env_ir_dev and env_ir_test... Seems like this alternative might address #48 as well.

... I may take a shot at this...

@adam-vessey
Copy link
Contributor

... Which is to say, that I have. :P

#53 allows prefixes to be used... Would pretty much have to be used in the case that multiple sources are in use. This should satisfy #48.

@Ancillas
Copy link

Ancillas commented Aug 2, 2013

What does the file system look like if prefixes are used?

Greg

On Thursday, August 1, 2013, Adam wrote:

... Which is to say, that I have. :P

#53 #53 allows prefixes to be
used... Would pretty much have to be used in the case that multiple sources
are in use. This should satisfy #48#48
.


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

@lutaylor
Copy link
Author

lutaylor commented Oct 9, 2013

This has been addressed by Adam's fix.

@lutaylor lutaylor closed this as completed Oct 9, 2013
sarameisburger pushed a commit to sarameisburger/r10k that referenced this issue Apr 12, 2019
Bump the gem version in the component
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

3 participants