<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>60609</bug_id>
          
          <creation_ts>2026-09-18 11:00:05 +0300</creation_ts>
          <short_desc>gem-puppet: NoMethodError: undefined method &apos;exists?&apos; for nil:NilClass в indirector/yaml.rb (touch_dir) при первом сохранении фактов под puppetserver</short_desc>
          <delta_ts>2026-09-18 11:00:05 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Branch p11</product>
          <component>gem-puppet</component>
          <version>unspecified</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="obidinog@basealt.ru">obidinog</reporter>
          <assigned_to name="majioa@altlinux.org">majioa</assigned_to>
          
          
          <qa_contact name="qa-p11@altlinux.org">qa-p11</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>299542</commentid>
    <comment_count>0</comment_count>
    <who name="obidinog@basealt.ru">obidinog</who>
    <bug_when>2026-09-18 11:00:05 +0300</bug_when>
    <thetext>Проверено на стенде Alt Server p11 x86_64.

Описание проблемы:
При первом обращении Puppet-агента к Puppet Server (когда директория кэша фактов на мастере /var/lib/puppetserver/yaml/facts ещё не существует после чистой установки пакетов), Puppet Server аварийно завершает запрос с кодом HTTP 500 Internal Server Error:
undefined method `exists?&apos; for nil:NilClass

Агент прерывает работу, каталог не применяется. При этом метод touch_dir успевает создать директорию на диске перед падением, поэтому повторный запуск агента проходит успешно, маскируя проблему.

Пакеты на стенде:
- Master: gem-puppet-8.4.0-alt2, puppetserver-8.4.0-alt4
- Client: puppet-8.4.0-alt2

Шаги для воспроизведения:
1. На Master:
   hostnamectl set-hostname puppetmaster
   echo &quot;$(ip -4 route get 1 | awk &apos;{print $7}&apos;) puppet puppetmaster&quot; &gt;&gt; /etc/hosts
   apt-get update &amp;&amp; apt-get install -y puppetserver puppetserver-ca puppet

   cat &lt;&lt; &apos;EOF&apos; &gt; /etc/puppet/puppet.conf
   [main]
   server = puppet
   ca_server = puppet
   EOF

   cat &lt;&lt; &apos;EOF&apos; &gt; /etc/puppet/routes.yaml
   ---
   master:
     facts:
       terminus: facter
       cache: yaml
   EOF

   systemctl enable --now puppetserver

2. На Client:
   hostnamectl set-hostname puppetclient
   echo &quot;&lt;IP_MASTER&gt; puppet&quot; &gt;&gt; /etc/hosts
   apt-get update &amp;&amp; apt-get install -y puppet

   cat &lt;&lt; &apos;EOF&apos; &gt; /etc/puppet/puppet.conf
   [main]
   server = puppet
   EOF

3. Воспроизведение:
   - На клиенте: puppet agent -t (отправка CSR)
   - На мастере: puppetserver ca sign --all (подписание сертификата)
   - На клиенте: puppet agent -t (запрос каталога)

Фактический результат:
На клиенте:
Notice: Requesting catalog from puppet:8140 (...)
Notice: Catalog compiled by puppetmaster
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: undefined method `exists?&apos; for nil:NilClass
Did you mean?  exit
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

В /var/log/puppetserver/puppetserver.log:
ERROR [puppetserver] Puppet Server Error: undefined method `exists?&apos; for nil:NilClass
Did you mean?  exit
/usr/lib/ruby/gemie/gems/puppet-8.4.0/lib/puppet/type/user.rb:514:in `exists?&apos;
/usr/lib/ruby/gemie/gems/puppet-8.4.0/lib/puppet/indirector/yaml.rb:65:in `touch_dir&apos;
/usr/lib/ruby/gemie/gems/puppet-8.4.0/lib/puppet/indirector/yaml.rb:29:in `save&apos;
/usr/lib/ruby/gemie/gems/puppet-8.4.0/lib/puppet/indirector/indirection.rb:329:in `save&apos;
/usr/lib/ruby/gemie/gems/puppet-8.4.0/lib/puppet/node/facts.rb:22:in `save&apos;
/usr/lib/ruby/gemie/gems/puppet-8.4.0/lib/puppet/indirector/catalog/compiler.rb:45:in `save_facts_from_request&apos;

Ожидаемый результат:
Puppet Server отдаёт каталог клиенту (HTTP 200) при первом же запросе без ошибок.

Локализация в коде:
В /usr/lib/ruby/gemie/gems/puppet-8.4.0/lib/puppet/indirector/yaml.rb в методе touch_dir:
  user = Puppet::Type.type(:user).new(name: Puppet[:user]).exists? ? Puppet[:user] : nil
  group = Puppet::Type.type(:group).new(name: Puppet[:group]).exists? ? Puppet[:group] : nil

В /usr/lib/ruby/gemie/gems/puppet-8.4.0/lib/puppet/type/user.rb (строка 514):
  def exists?
    provider.exists?
  end

В окружении Puppet Server (JRuby) нативные системные провайдеры для типа user не загружаются, поэтому provider равен nil. Вызов nil.exists? вызывает NoMethodError.

Дополнительно:
Проверить наличие данной ошибки на Sisyphus в данный момент не удаётся из-за другого блокирующего бага: в репозитории обновлён пакет gem-multi-json (1.21.1), использующий метод Fiber.[] (из Ruby 3.0), который отсутствует в JRuby внутри puppetserver, в результате чего puppetserver на Sisyphus падает ещё раньше — при любой десериализации JSON («Could not intern from json: undefined method `[]&apos; for Fiber:Class»).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>