Jira (PUP-8962) Type and provider info should be logged when prefetch fails

0 views
Skip to first unread message

Charlie Sharpsteen (JIRA)

unread,
Jun 26, 2018, 12:07:04 PM6/26/18
to puppe...@googlegroups.com
Charlie Sharpsteen updated an issue
 
Puppet / Bug PUP-8962
Type and provider info should be logged when prefetch fails
Change By: Charlie Sharpsteen
Summary: Type and provider info should always be logged when prefetch fails
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Charlie Sharpsteen (JIRA)

unread,
Jun 26, 2018, 12:10:26 PM6/26/18
to puppe...@googlegroups.com

Charlie Sharpsteen (JIRA)

unread,
Jun 26, 2018, 2:12:03 PM6/26/18
to puppe...@googlegroups.com
Charlie Sharpsteen updated an issue
While the puppet agent is applying a catalog, it will pre-fetch resource instances that share a common source. Such as packages from the same provider or cron jobs from the same crontab. Catalog application will abort with an error message if this prefetch operation fails. Often, these errors are terse, cryptic, and give no insight into which sort of resource type failed to fetch (cron job? package? SSH key?). In the case of types based on the ParsedFile provider, the prefetch code is shared among all types which means that the stack trace produced by {{--trace}} doesn't even help distinguish what type encountered the error.

Error messages should be clear about which type and provider failed so that users can proceed directly to debugging instead of puzzling out what happened.

h2. Reproduction Case

  - Install PE 2018.1.2 on CentOS 7.

  - Configure {{site.pp}} in the production environment with a cron resource:

{code:bash}
cat <<EOF > /etc/puppetlabs/code/environments/production/manifests/master_node.pp
node '$(hostname -f)' {
  cron {'cron job to trigger prefetch':
    command => '/bin/true',
    user => 'root',
    hour => 1,
  }
}
EOF
{code}

  - Write garbage to root's crontab to trigger a parse failure:

{code:bash}
printf '\0\0\0\0odelay' > /var/spool/cron/root
{code}

  - Run {{puppet agent -t}}

h3. Outcome

The catalog fails to apply with a very terse, cryptic error message:

{noformat}
# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for pe-201812-master.puppetdebug.vlan
Info: Applying configuration version '1530028114'
Error: Failed to apply catalog: Could not parse line "\u0000\u0000\u0000\u0000odelay" (file: root, line: 2)
{noformat}

h3. Expected Outcome

Error message should include the type and provider name as is done when
prefect prefetch fails due to a LoadError or Puppet::MissingCommand error:

{noformat}
# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for pe-201812-master.puppetdebug.vlan
Info: Applying configuration version '1530028653'
Error: Failed to apply catalog: Could not prefetch cron provider 'crontab': Could not parse line "\u0000\u0000\u0000\u0000odelay" (file: root, line: 2)
{noformat}

Josh Cooper (JIRA)

unread,
Jun 26, 2018, 2:50:03 PM6/26/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Platform Core Coremunity

Neil Binney (JIRA)

unread,
Jun 27, 2018, 3:51:03 AM6/27/18
to puppe...@googlegroups.com
Neil Binney updated an issue
Change By: Neil Binney
CS Priority: Needs Priority Reviewed

Josh Cooper (JIRA)

unread,
Sep 26, 2018, 9:01:06 PM9/26/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Coremunity Grooming

Josh Cooper (JIRA)

unread,
Sep 26, 2018, 9:02:06 PM9/26/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Coremunity Grooming Hopper

Josh Cooper (JIRA)

unread,
Sep 26, 2018, 9:05:07 PM9/26/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint: Coremunity Hopper Grooming

Josh Cooper (JIRA)

unread,
Sep 26, 2018, 9:11:05 PM9/26/18
to puppe...@googlegroups.com

Jacob Helwig (JIRA)

unread,
Oct 2, 2018, 6:01:04 PM10/2/18
to puppe...@googlegroups.com
Jacob Helwig commented on Bug PUP-8962
 
Re: Type and provider info should be logged when prefetch fails

Charlie Sharpsteen, it looks like the error message should get translated into something a bit more useful if you turn on future_features in the puppet.conf (prefetch in transaction.rb). I'm not sure what the plan was for when to move the new (actually old) prefetch behavior from PUP-7630 to being the default behavior, though. Might have been something that was missed for 6.0?

Jorie Tappa (JIRA)

unread,
Oct 19, 2018, 5:26:07 PM10/19/18
to puppe...@googlegroups.com
Jorie Tappa commented on Bug PUP-8962

Grooming session:

Looks like we forgot to un-gate some things attached to the future_features flag that should've been on by default in pup 6.

 

ping Charlie Sharpsteen

 

Jorie Tappa (JIRA)

unread,
Oct 22, 2018, 5:47:06 PM10/22/18
to puppe...@googlegroups.com
Jorie Tappa updated an issue
 
Change By: Jorie Tappa
Sprint: Coremunity Grooming Hopper

Charlie Sharpsteen (JIRA)

unread,
Oct 22, 2018, 6:12:05 PM10/22/18
to puppe...@googlegroups.com
Charlie Sharpsteen commented on Bug PUP-8962
 
Re: Type and provider info should be logged when prefetch fails

The crontab example still fails mysteriously with Puppet 6.0.3 in the latest PE 2019.0 nightly:

[root@pe-20190nightly-master ~]# puppet --version
6.0.3
 
[root@pe-20190nightly-master ~]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for pe-20190nightly-master.puppetdebug.vlan
Info: Applying configuration version '1540246020'
Error: Failed to apply catalog: Could not parse line "\u0000\u0000\u0000\u0000odelay" (file: root, line: 2)

The error message is much better if future_features is enabled and allows for a full catalog application to occur:

[root@pe-20190nightly-master ~]# puppet config set future_features true
 
[root@pe-20190nightly-master ~]# puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for pe-20190nightly-master.puppetdebug.vlan
Info: Applying configuration version '1540246148'
Error: Could not prefetch cron provider 'crontab': Could not parse line "\u0000\u0000\u0000\u0000odelay" (file: root, line: 2)
Warning: /Stage[main]/Main/Node[pe-20190nightly-master.puppetdebug.vlan]/Cron[cron job to trigger prefetch]: Skipping because provider prefetch failed
Warning: /Stage[main]/Pe_repo::Bulk_pluginsync/Cron[create tar.gz of pluginsync cache]: Skipping because provider prefetch failed
Notice: Applied catalog in 15.21 seconds

Josh Cooper (JIRA)

unread,
Oct 23, 2018, 2:28:03 AM10/23/18
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-8962

Yeah, looks like we missed it for 6.0. That said we should be able to log the exception before raising, which was the behavior for load errors and missing commands before PUP-7630 was implemented:

rescue => detail
  #TRANSLATORS `prefetch` is a function name and should not be translated
  Puppet.log_exception(detail, _("Could not prefetch %{type_name} provider '%{name}': %{detail}") % { type_name: type_name, name: provider_class.name, detail: detail })
  message = _("Could not prefetch %{type_name} provider '%{name}': %{detail}") % { type_name: type_name, name: provider_class.name, detail: detail }
  Puppet.log_exception(detail, message)
 
  if !detail.is_a?(LoadError) && !detail.is_a?(Puppet::MissingCommand)
    raise unless Puppet.settings[:future_features]
    @prefetch_failed_providers[type_name][provider_class.name] = true
  end
end

Secondary issue is that we're currently doing rescue => Exception which isn't desirable, because it will catch all exceptions like SystemExit, which we shouldn't. We should do rescue LoadError, StandardError instead.

Kris Bosland (JIRA)

unread,
Jan 3, 2019, 7:26:04 PM1/3/19
to puppe...@googlegroups.com

Kris Bosland (JIRA)

unread,
Jan 3, 2019, 7:27:03 PM1/3/19
to puppe...@googlegroups.com
Kris Bosland updated an issue
Change By: Kris Bosland
Sprint: Coremunity Hopper Platform Core KANBAN

Kris Bosland (JIRA)

unread,
Jan 9, 2019, 2:44:04 PM1/9/19
to puppe...@googlegroups.com
Kris Bosland updated an issue
Change By: Kris Bosland
Release Notes Summary: Puppet will now log exceptions that happen during prefetch.  Also exception handling in prefetch was fixed to the correct set of exceptions.
Release Notes: Bug Fix

Josh Cooper (JIRA)

unread,
Jan 10, 2019, 5:50:04 PM1/10/19
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Jan 11, 2019, 5:14:05 PM1/11/19
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Jan 11, 2019, 5:14:06 PM1/11/19
to puppe...@googlegroups.com
Josh Cooper updated an issue
 
Change By: Josh Cooper
Fix Version/s: PUP 5.5.z
Fix Version/s: PUP 6.2.0
Fix Version/s: PUP 6.0.6
Fix Version/s: PUP 5.5.10

Jean Bond (JIRA)

unread,
Jan 23, 2019, 2:16:04 PM1/23/19
to puppe...@googlegroups.com
Jean Bond updated an issue
Change By: Jean Bond
Labels: resolved-issue-added

Austin Boyd (JIRA)

unread,
Dec 12, 2019, 8:41:05 AM12/12/19
to puppe...@googlegroups.com
Austin Boyd updated an issue
Change By: Austin Boyd
Zendesk Ticket IDs: 33723
Zendesk Ticket Count: 1
Reply all
Reply to author
Forward
0 new messages