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

Calling "pkg update -n" on Solaris too frequently causes problems with zones #9298

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alanhargreaves
Copy link

On a Solaris system, running "pkg update -n" in the global zone at the same time that it is running in a non-global zone, can cause the command to fail in one or the other.

If we have puppet running this command, it causes the puppet run to fail for that specific resource.

This patch removes some unnecessary calls to this command, and appropriately updates rspec.

Runs cleanly under rubocop.

@alanhargreaves alanhargreaves requested a review from a team as a code owner March 18, 2024 01:41
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@alanhargreaves
Copy link
Author

…h zones

On a Solaris system, running "pkg update -n" in the global zone at the same time that it is running in a non-global zone, can cause the command to fail in one or the other.

If we have puppet running this command, it causes the puppet run to fail for that specific resource.

This patch removes some unnecessary calls to this command, and appropriately updates rspec.
@joshcooper
Copy link
Contributor

I'm a little confused by how the pkg provider worked before your PR. If I specify an exact match like:

package { 'git':
  ensure => '2.15.2-11.4.0.0.1.9.0:20180618T171726Z'
}

Then the should value (from the manifest) will match the regexp:

irb(main):003> /^[0-9.]+(,[0-9.]+)?(-[0-9.]+)?:[0-9]+T[0-9]+Z$/.match?("2.15.2-11.4.0.0.1.9.0:20180618T171726Z")
=> true

So we never call pkg list to detect that it's already installed and the insync? method returns false

That seems wrong to me... If an exact match is specified, I would expect the provider to compare if the current value (passed in as is) matches the desired value (should), something like:

def insync?(is)
  should = @resource[:ensure]
  if  /^[0-9.]+(,[0-9.]+)?(-[0-9.]+)?:[0-9]+T[0-9]+Z$/.match?(should)
    return is == should
  else
    # search for potential matches
  end
end

@joshcooper joshcooper added the bug Something isn't working label Apr 23, 2024
@alanhargreaves
Copy link
Author

alanhargreaves commented Apr 25, 2024

With regard to the recent comment about the call to insync?, The comments at the top of the function state:

  def insync?(is)
    # this is called after the generic version matching logic (insync? for the
    # type), so we only get here if should != is, and 'should' is a version
    # number. 'is' might not be, though.

which lead me to believe that the function is not called in this module if we have an exact match in the type call for it.

On checking lib/puppet/type/package.rb, I can see that the loop in that instance of insync? does exact version comparisons, justifying the comment in the provider inync?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants