The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Bug #11798

vcsrepo doesn't actually update revisions with git.

Added by Ben Hughes over 2 years ago. Updated over 1 year ago.

Status:Merged - Pending ReleaseStart date:01/05/2012
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:vcsrepoSpent time:-
Target version:-
Keywords: Branch:https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/17

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

Overview

Using the git provider, vcsrepo fails to update to another SHA1 from where it currently is. It works fine for clone, but not if you want it to update a repo.

vcsrepo { '/opt/forge':
    source   => 'git@github.com/puppetlabs/ouramazing-forge.git,
    provider => git,
    revision => '32bdf3d7ddbdf92843e4bc437ce2aa94e821209b',
    ensure   => present,
  }

Expected Behaviour

Update my repo to the SHA1 specified.

Actual Behaviour

notice: /Stage[main]/Forge/Vcsrepo[/opt/forge]/revision: revision changed 'f9529be2b6c3f3fd2e2db44aa1fda5e797e449e9' to '32bdf3d7ddbdf92843e4bc437ce2aa9ee848209b'
[root@idun:/opt/forge]# git rev-list -n 1 HEAD 
f9529be2b6c3f3fd2e2db44aa1fda5e797e449e9

Detail

debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git fetch --tags origin'

Is about as far as it gets. It does no reset or pull nor rebase.

Work Around

There is none.


Related issues

Related to Puppet Labs Modules - Bug #11278: vcsrepo unable to `ensure => latest` with Git repository Merged - Pending Release 12/07/2011
Related to Puppet Labs Modules - Bug #11040: vcsrepo: type git change from present to latest failed Needs More Information 11/24/2011
Related to Puppet Labs Modules - Bug #12041: vcsrepo should use the force parameter to determine if lo... Rejected 01/19/2012

History

#1 Updated by Ben Hughes over 2 years ago

[ben@utu:~]% cat vcsrepo.pp 
vcsrepo{ '/tmp/vcsrepo':
    provider => git,
    source   => 'git@github.com:puppetlabs/puppet-vcsrepo.git',
    ensure   => present,
    revision => 'b4d763cef69e94301351c7eeef5b22c75c8bc6dd',
}
[ben@utu:~]% puppet apply --modulepath /Users/ben/foo --verbose --debug ./vcsrepo.pp                                                               1
warning: Could not retrieve fact fqdn
warning: Found multiple default providers for vcsrepo: hg, cvs, bzr, svn, git; using hg
debug: Creating default schedules
debug: Failed to load library 'rubygems' for feature 'rubygems'
debug: Failed to load library 'selinux' for feature 'selinux'
debug: Puppet::Type::File::ProviderMicrosoft_windows: feature microsoft_windows is missing
debug: Failed to load library 'ldap' for feature 'ldap'
debug: Failed to load library 'shadow' for feature 'libshadow'
debug: /File[/Users/ben/.puppet/ssl/public_keys]: Autorequiring File[/Users/ben/.puppet/ssl]
debug: /File[/Users/ben/.puppet/var/client_data]: Autorequiring File[/Users/ben/.puppet/var]
debug: /File[/Users/ben/.puppet/ssl]: Autorequiring File[/Users/ben/.puppet]
debug: /File[/Users/ben/.puppet/ssl/certificate_requests]: Autorequiring File[/Users/ben/.puppet/ssl]
debug: /File[/Users/ben/.puppet/ssl/private]: Autorequiring File[/Users/ben/.puppet/ssl]
debug: /File[/Users/ben/.puppet/var/facts]: Autorequiring File[/Users/ben/.puppet/var]
debug: /File[/Users/ben/.puppet/var/run]: Autorequiring File[/Users/ben/.puppet/var]
debug: /File[/Users/ben/.puppet/var/log]: Autorequiring File[/Users/ben/.puppet/var]
debug: /File[/Users/ben/.puppet/var/clientbucket]: Autorequiring File[/Users/ben/.puppet/var]
debug: /File[/Users/ben/.puppet/var/state]: Autorequiring File[/Users/ben/.puppet/var]
debug: /File[/Users/ben/.puppet/ssl/private_keys]: Autorequiring File[/Users/ben/.puppet/ssl]
debug: /File[/Users/ben/.puppet/var/lib]: Autorequiring File[/Users/ben/.puppet/var]
debug: /File[/Users/ben/.puppet/var/state/state.yaml]: Autorequiring File[/Users/ben/.puppet/var/state]
debug: /File[/Users/ben/.puppet/var/client_yaml]: Autorequiring File[/Users/ben/.puppet/var]
debug: /File[/Users/ben/.puppet/var]: Autorequiring File[/Users/ben/.puppet]
debug: /File[/Users/ben/.puppet/ssl/certs]: Autorequiring File[/Users/ben/.puppet/ssl]
debug: /File[/Users/ben/.puppet/var/state/graphs]: Autorequiring File[/Users/ben/.puppet/var/state]
debug: Finishing transaction 2230473300
debug: Loaded state in 0.00 seconds
info: Applying configuration version '1325830709'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git clone git@github.com:puppetlabs/puppet-vcsrepo.git /tmp/vcsrepo'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git branch -a'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git tag -l'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git branch -a'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git submodule init'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git submodule update'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git submodule foreach git submodule init'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git submodule foreach git submodule update'
notice: /Stage[main]//Vcsrepo[/tmp/vcsrepo]/ensure: created
debug: Finishing transaction 2232005280
debug: Storing state
debug: Stored state in 0.00 seconds

Which gives us…


[ben@utu:vcsrepo]% git show                                                                                                   vcsrepo:master:c3dabc3
commit c3dabc322b33ed8dc3acc2dcfe05d58a3c21424b
Merge: 33cca51 924e133
Author: James Turnbull 
Date:   Mon Dec 26 15:42:13 2011 -0800

    Merge pull request #15 from webfactory/fix_10787
    
    Fix (#10787) - Various fixes/tweaks for the CVS provider

Which isn’t the revision I specified. It’s HEAD.

So lets run it again.

[ben@utu:vcsrepo]% puppet apply --modulepath /Users/ben/foo --verbose --debug ~/vcsrepo.pp
[snip]
debug: Finishing transaction 2246931920
debug: Loaded state in 0.00 seconds
info: Applying configuration version '1325830970'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git fetch --tags origin'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git rev-parse HEAD'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git tag -l'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git rev-parse b4d763cef69e94301351c7eeef5b22c75c8bc6dd'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git branch -a'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git tag -l'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git branch -a'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git branch -a'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git submodule init'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git submodule update'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git submodule foreach git submodule init'
debug: Puppet::Type::Vcsrepo::ProviderGit: Executing '/usr/bin/git submodule foreach git submodule update'
notice: /Stage[main]//Vcsrepo[/tmp/vcsrepo]/revision: revision changed 'c3dabc322b33ed8dc3acc2dcfe05d58a3c21424b' to 'b4d763cef69e94301351c7eeef5b22c75c8bc6dd'
debug: Finishing transaction 2248458760
debug: Storing state
debug: Stored state in 0.00 seconds

Yes, despite the “revision changed ‘c3dabc322b33ed8dc3acc2dcfe05d58a3c21424b’ to ‘b4d763cef69e94301351c7eeef5b22c75c8bc6dd’” it hasn’t changed.

[ben@utu:vcsrepo]% git rev-list -n 1 HEAD
c3dabc322b33ed8dc3acc2dcfe05d58a3c21424b

#2 Updated by Matthias Pigulla over 2 years ago

I really cannot tell if the following is the right thing to do ™ as I don’t regularly use git. However, to me it seems it at least fixes the problem.

--- a/modules/puppetlabs-vcsrepo/lib/puppet/provider/vcsrepo/git.rb
+++ b/modules/puppetlabs-vcsrepo/lib/puppet/provider/vcsrepo/git.rb
@@ -194,6 +194,8 @@
       at_path { git_with_identity('checkout', revision) }
     elsif remote_branch_revision?
       at_path { git_with_identity('checkout', '-b', revision, '--track', "origin/#{revision}") }
+    else
+      reset(revision)
     end
   end
 

#3 Updated by Matt Robinson over 2 years ago

Matthias, I think that’s the right area of code to make the fix, but I think doing a reset --hard is a bad idea.

In fact, I think it’s a bug that we’re doing a reset for branches.

def checkout_or_reset(revision = @resource.value(:revision))
  if local_branch_revision?
    reset(revision)
  elsif tag_revision?
    at_path { git_with_identity('checkout', revision) }
  elsif remote_branch_revision?
    at_path { git_with_identity('checkout', '-b', revision, '--track', "origin/#{revision}") }
  end
end

This means that if you’re on the master branch and you want to checkout another branch, lets say stable, then the current implementation will actually reset your master branch to the same commit as the stable branch. What we really want is to just do a checkout for branches, tags or any old SHA1.

However, I need to figure out what to do with local changes. Sometimes a checkout isn’t allowed because you have uncommitted local changes, but that can be overridden with a —force flag to checkout. It doesn’t look like that kind of options is part of the type exactly. There’s a —force option, but it’s said to only apply to repo creation, not updating. I think it could apply to either, but will need to think about that in context of the other support version control systems.

#4 Updated by Matt Robinson over 2 years ago

  • Category set to vcsrepo
  • Status changed from Unreviewed to Merged - Pending Release
  • Assignee set to Matt Robinson
  • Branch set to https://github.com/puppetlabs/puppet-vcsrepo/pull/17

For now I’m not going to worry about force and local changes being overridden. The current behavior was already doing a reset hard, so doing a checkout —force isn’t any worse. I’ll make new tickets for that issue.

The pull request has already been merged for this, I’m not sure when we “release” new versions of modules.

#5 Updated by Matthias Pigulla over 2 years ago

Maybe in update_references (around line 95) there should also be a

 git_with_identity('fetch', 'origin')

to make sure we’ve got all revisions and not only tags?

A fetch on every puppet run is not nice, but should probably be addressed in another case.

#6 Updated by Matt Robinson over 2 years ago

  • Status changed from Merged - Pending Release to Code Insufficient

Matthias Pigulla wrote:

Maybe in update_references (around line 95) there should also be a

 git_with_identity('fetch', 'origin')

to make sure we’ve got all revisions and not only tags?

A fetch on every puppet run is not nice, but should probably be addressed in another case.

Good point, otherwise we don’t get new revisions automatically.

It also appears that putting a new branch name in the revision property causes problems too since rev-parse will blow up when trying to get info on it as if it were a local branch.

I need to get the specs running on this module so we don’t keep regressing in this area. I made a quick stab at it today, but didn’t succeed.

I’m marking this ticket as code insufficient even though a partial fix has been merged in. When I can get branches, tags and revisions to work correctly from both clone and updating (checkout), and run on specs I’ll consider this done. I may not get this done in the next few days, but I’ll keep this on my radar for the near future TODO.

#7 Updated by Daniel Pittman about 2 years ago

  • Assignee deleted (Matt Robinson)

#8 Updated by Ryan Coleman over 1 year ago

  • Status changed from Code Insufficient to Merged - Pending Release
  • Branch changed from https://github.com/puppetlabs/puppet-vcsrepo/pull/17 to https://github.com/puppetlabs/puppetlabs-vcsrepo/pull/17

#9 Updated by Aaron Stone over 1 year ago

Please update to vcsrepo 0.1.0 and report back if it’s working now or still a problem.

Also available in: Atom PDF