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

Convert to PDK, fix log behavior with newer Puppet #44

Merged
merged 11 commits into from
Jul 18, 2022

Conversation

geoffdavis
Copy link
Contributor

Convert the module to use the latest, greatest Puppet development kit.

Lint fix various puppet modules
Fix multiple issues with the ruby code, including some ambiguous assignments and comparisons that weren't evaluating in the right order on all versions of ruby.

This pull request is admittedly a big one, but there wasn't an easy way for me to check for various Ruby ambiguities without having a working rubocop or test framework around.

Unit tests now pass for Puppet 5, 6, and 7.

Fixes #43

Make sure mocks run with mocha
This commit fixes multiple issues found with the ruby code and spec
tests as documented by Rubocop.

Add some recommend extensions

Document variable shadow with no clear resolution

It is unclear if assignment on line 336 is supposed to be to "v" instead of "value"

Use Ruby 1.9 hash format
Use not_to instead of to_not
Use %r around regex
Single quotes around string literals
Fixup most lint level rubocop warnings
Remove "should" from example wording
Use map instead of collect
Use new key methods
Rename is_to_s to to_s?
Use start_with rather than anchored regex
Clear up duplicate resource names in spec tests
Fixup abiguous assignment and compare statements.
Use throwaway value for unused variables
Update error type for some specs to RuntimeError
Regex in a start_with call isn't available in Ruby 2.4, and using a
regex in start_with removes any performance benefits of start_with
anyway.
@geoffdavis geoffdavis changed the title Convert to PDK, fix log behavior with newer Puppet Draft: Convert to PDK, fix log behavior with newer Puppet Jul 14, 2022
@geoffdavis
Copy link
Contributor Author

Still seeing the underlying bug with #43 on this updated branch, working on this some more.

@geoffdavis
Copy link
Contributor Author

It turns out that the @property_hash for the resource is mostly empty, as if the type isn't populating it fully before passing it on to the provider.

From: /opt/puppetlabs/puppet/cache/lib/puppet/provider/quagga_logging/quagga.rb:78 quagga#flush:

    73:     commands << 'configure terminal'
    74:
    75:     if exists?
    76:
    77:       command = ['log']
 => 78:       require 'pry'; binding.pry
    79:       command << @property_hash[:name]
    80:
    81:       if @property_hash[:name] == 'file'
    82:         command << filename
    83:       end

[1] pry(#<Puppet::Type::Quagga_logging::ProviderQuagga>)> @property_hash
=> {:ensure=>:present}

The type uses ruby symbols for the name, but the provider was using
strings inside the inspect method.

The create method did not get all of the parameters it needed from the
resource object.

Instances were not being destroyed properly.

Flush was always getting called even if the object wasn't "dirty."
@geoffdavis geoffdavis changed the title Draft: Convert to PDK, fix log behavior with newer Puppet Convert to PDK, fix log behavior with newer Puppet Jul 15, 2022
@geoffdavis
Copy link
Contributor Author

OK this is ready to merge. It turns out there were a number of issues, the biggest of which were:

  • The type uses symbols for the name property, but the provider's instances method was using strings, so Puppet never saw an equivalence.
  • Flushing based on the object's "dirty" state didn't appear to be implemented in this module, so I kludged that in based on another provider.

@bibigon812 bibigon812 merged commit 2d6b4c8 into bibigon812:master Jul 18, 2022
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.

Provider for quagga_logging failing
2 participants