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

(PUP-10319) Invalidate rubygems cache after uninstalling puppet_gem package #8009

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

alexjfisher
Copy link
Contributor

Without this patch after a gem is uninstalled from puppet's ruby
environment using the puppet_gem package provider other actions in
an agent's run fail. For instance, modifying a file fails whilst trying
to back it up.

eg.

Error: Could not back up /some/file: pid: 21277 nil spec! included in [#<Gem::StubSpecifi...
--- SNIP (massive array ommitted) ---
]
/opt/puppetlabs/puppet/lib/ruby/2.5.0/rubygems/specification.rb:743:in `_all'
/opt/puppetlabs/puppet/lib/ruby/2.5.0/rubygems/specification.rb:1153:in `latest_specs'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/rubygems.rb:44:in `directories'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:142:in `gem_directories'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:172:in `search_directories'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:98:in `get_file'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:62:in `load_file'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:201:in `load'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/instance_loader.rb:51:in `loaded_instance'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/terminus.rb:112:in `terminus_class'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:366:in `make_terminus'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:140:in `terminus'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/file_bucket_file/selector.rb:16:in `get_terminus'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/file_bucket_file/selector.rb:20:in `head'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:260:in `head'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/file_bucket/dipper.rb:48:in `backup'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/backups.rb:82:in `backup_file_with_filebucket'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/backups.rb:28:in `perform_backup_with_bucket'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/backups.rb:15:in `perform_backup'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file.rb:1024:in `backup_existing'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file.rb:761:in `remove_existing'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file.rb:888:in `write'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file/data_sync.rb:93:in `contents_sync'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file/content.rb:136:in `sync'
--- SNIP ---

This commit is inspired by
b61fa20
(#2415)

@alexjfisher alexjfisher requested review from a team February 28, 2020 12:40
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@puppetcla
Copy link

CLA signed by all contributors.

@jtappa
Copy link
Contributor

jtappa commented Mar 9, 2020

jenkins please test this

spec/unit/provider/package/puppet_gem_spec.rb Outdated Show resolved Hide resolved
it 'should invalidate the rubygems cache' do
@gem_source = double('gem_source')
allow(Puppet::Util::Autoload).to receive(:gem_source).and_return(@gem_source)
expect(described_class).to receive(:execute_gem_command).with(provider_gem_cmd, %w{uninstall --executables --all myresource}).and_return('')
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure this expect is needed as it is alos tested on :61

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this line, builds were failing with Provider puppet_gem package command 'gem' does not exist on this host

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, sorry i didn't see that this line is also returning something
It is ok like this 👍

@alexjfisher
Copy link
Contributor Author

My update isn't passing in CI (but still works for me locally). Sorry for the noise whilst I try to figure out which change broke it.

…ackage

Without this patch after a gem is uninstalled from puppet's ruby
environment using the `puppet_gem` `package` provider other actions in
an agent's run fail.  For instance, modifying a file fails whilst trying
to back it up.

eg.
```
Error: Could not back up /some/file: pid: 21277 nil spec! included in [#<Gem::StubSpecifi...
--- SNIP (massive array ommitted) ---
]
/opt/puppetlabs/puppet/lib/ruby/2.5.0/rubygems/specification.rb:743:in `_all'
/opt/puppetlabs/puppet/lib/ruby/2.5.0/rubygems/specification.rb:1153:in `latest_specs'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/rubygems.rb:44:in `directories'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:142:in `gem_directories'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:172:in `search_directories'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:98:in `get_file'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:62:in `load_file'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/autoload.rb:201:in `load'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/instance_loader.rb:51:in `loaded_instance'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/terminus.rb:112:in `terminus_class'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:366:in `make_terminus'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:140:in `terminus'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/file_bucket_file/selector.rb:16:in `get_terminus'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/file_bucket_file/selector.rb:20:in `head'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/indirector/indirection.rb:260:in `head'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/file_bucket/dipper.rb:48:in `backup'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/backups.rb:82:in `backup_file_with_filebucket'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/backups.rb:28:in `perform_backup_with_bucket'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/backups.rb:15:in `perform_backup'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file.rb:1024:in `backup_existing'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file.rb:761:in `remove_existing'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file.rb:888:in `write'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file/data_sync.rb:93:in `contents_sync'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type/file/content.rb:136:in `sync'
--- SNIP ---
```

This commit is inspired by
puppetlabs@b61fa20
(puppetlabs#2415)
@gimmyxd gimmyxd merged commit c66a098 into puppetlabs:master Mar 26, 2020
@alexjfisher alexjfisher deleted the PUP-10319 branch March 26, 2020 10:54
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.

6 participants