puppetlabs/puppet · error · Puppet::Error

Pkg could not install %{name} after %{tries} tries. Aborting

Error message

Pkg could not install %{name} after %{tries} tries. Aborting run

What it means

Raised in the install retry loop (lib/puppet/provider/package/pkg.rb:247) of the Solaris `pkg` provider. `pkg install` exits 7 when the IPS image is locked by another process; the provider retries up to 4 times with exponential backoff (2**tries seconds) and then raises Puppet::Error aborting the run.

Source

Thrown at lib/puppet/provider/package/pkg.rb:247

    else
      command = 'update'
    end
    args = ['--accept']
    if Puppet::Util::Package.versioncmp(Puppet.runtime[:facter].value('os.release.full'), '11.2') >= 0
      args.push('--sync-actuators-timeout', '900')
    end
    args.concat(join_options(@resource[:install_options])) if @resource[:install_options]
    unless should.is_a? Symbol
      name += "@#{should}"
    end
    unhold if properties[:mark] == :hold
    begin
      tries = 1
      # pkg install exits with code 7 when the image is currently in use by another process and cannot be modified
      r = exec_cmd(command(:pkg), command, *args, name)
      while r[:exit] == 7
        if tries > 4
          raise Puppet::Error, _("Pkg could not install %{name} after %{tries} tries. Aborting run") % { name: name, tries: tries }
        end

        sleep 2**tries
        tries += 1
        r = exec_cmd(command(:pkg), command, *args, name)
      end
    ensure
      hold if @resource[:mark] == :hold
    end
    return r if nofail
    raise Puppet::Error, _("Unable to update %{package}") % { package: r[:out] } if r[:exit] != 0
  end

  # uninstall the package. The complication comes from the -r_ecursive flag which is no longer
  # present in newer package version.
  def uninstall
    cmd = [:uninstall]
    case (pkg :version).chomp

View on GitHub (pinned to e227c27540)

Solutions

  1. Identify the lock holder: `ps -ef | grep pkg` and inspect active pkg/SMF processes; wait for or terminate the stale one.
  2. Stagger schedules so puppet runs never overlap with unattended pkg updates.
  3. Simply re-run the agent a minute later - the contention is usually transient.
  4. If it recurs systematically, patch the retry budget (tries > 4 / sleep 2**tries) to fit your environment's lock hold times.
Defensive patterns

Strategy: retry

Validate before calling

# Skip the run while another pkg operation holds the image lock
pgrep -x pkg >/dev/null && { echo "pkg busy - deferring puppet run"; exit 0; }

Try / catch

retries = 0
begin
  provider.install
rescue Puppet::Error => e
  raise unless e.message =~ /after \d+ tries/
  retries += 1
  retry if retries < 3
  raise
end

Prevention

When it happens

Trigger: Concurrent pkg operations holding the image lock: a second puppet agent run, an in-progress `pkg update` / self-update, SMF refreshing image state, a GUI Package Manager session, or a hung pkg process.

Common situations: Overlapping cron schedules for puppet and OS updates; boot-time zone/image refresh still running; a stale pkg process wedged on the lock.

Related errors


AI-assisted analysis of puppetlabs/puppet@e227c27540 (2026-08-21). Data as JSON: /api/errors/a7f25d459d9f3f4d. Report an issue: GitHub.