Jira (FACT-3120) Facter does not properly handle encoded ec2_userdata

13 views
Skip to first unread message

Colby Williams (Jira)

unread,
May 5, 2022, 11:18:01 AM5/5/22
to puppe...@googlegroups.com
Colby Williams created an issue
 
Facter / Bug FACT-3120
Facter does not properly handle encoded ec2_userdata
Issue Type: Bug Bug
Affects Versions: FACT 4.2.8
Assignee: Unassigned
Components: Facter 4
Created: 2022/05/05 8:17 AM
Priority: Normal Normal
Reporter: Colby Williams

Who found the bug?

Customer

Where was the bug found?

  • System: customer test environment in Amazon Web Services
  • Version: Facter 4.2.8
  • Operating system(s): RHEL 8 systems (Alma and Rocky Linux)
  • Puppet version: N/A

What is malfunctioning?

When an AWS EC2 instance is launched with cloud-init as the user data method it encodes the data in a format Facter does not parse (i.e., not UTF-8), which causes the following error when running facter.

Traceback (most recent call last):
13: from /opt/puppetlabs/puppet/bin/facter:10:in `<main>'
12: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/cli/cli_launcher.rb:23:in `start'
11: from /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
10: from /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
9: from /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
8: from /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
7: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/cli/cli.rb:124:in `query'
6: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter.rb:458:in `to_user_output'
5: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/formatters/legacy_fact_formatter.rb:16:in `format'
4: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/formatters/legacy_fact_formatter.rb:26:in `format_for_no_query'
3: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/formatters/legacy_fact_formatter.rb:63:in `hash_to_facter_format'
2: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/json/common.rb:286:in `pretty_generate'
1: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/json/common.rb:286:in `generate'
/opt/puppetlabs/puppet/lib/ruby/2.7.0/json/common.rb:286:in `to_json': source sequence is illegal/malformed utf-8 (JSON::GeneratorError)

What does success look like?

This can be corrected by creating /etc/puppetlabs/facter/facter.conf and adding a block for the ec2_userdata fact.

facts : {
  blocklist : [ "ec2_userdata"]
}

How will success be validated?

facter should detect whether the ec2_userdata fact is encoded properly before attempting to add it to the facts hash.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

Colby Williams (Jira)

unread,
May 5, 2022, 11:22:03 AM5/5/22
to puppe...@googlegroups.com
Colby Williams updated an issue
Change By: Colby Williams
h2. Who found the bug?

Customer
h2. Where was the bug found?
* System: customer test environment in Amazon Web Services
* Version: Facter 4.2.8
* Operating system(s): RHEL 8 systems (Alma and Rocky Linux)
* Puppet version: N/A

h2. What is malfunctioning?  

When an AWS EC2 instance is launched with [cloud-init|https://cloudinit.readthedocs.io/en/latest/index.html] as the user data method it encodes the data in a format Facter does not parse (i.e., not UTF-8), which causes the following error when running {{{}facter{}}}.
{code:java}

Traceback (most recent call last):
13: from /opt/puppetlabs/puppet/bin/facter:10:in `<main>'
12: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/cli/cli_launcher.rb:23:in `start'
11: from /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/base.rb:485:in `start'
10: from /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
9: from /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
8: from /opt/puppetlabs/puppet/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
7: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/cli/cli.rb:124:in `query'
6: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter.rb:458:in `to_user_output'
5: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/formatters/legacy_fact_formatter.rb:16:in `format'
4: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/formatters/legacy_fact_formatter.rb:26:in `format_for_no_query'
3: from /opt/puppetlabs/puppet/lib/ruby/vendor_ruby/facter/framework/formatters/legacy_fact_formatter.rb:63:in `hash_to_facter_format'
2: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/json/common.rb:286:in `pretty_generate'
1: from /opt/puppetlabs/puppet/lib/ruby/2.7.0/json/common.rb:286:in `generate'
/opt/puppetlabs/puppet/lib/ruby/2.7.0/json/common.rb:286:in `to_json': source sequence is illegal/malformed utf-8 (JSON::GeneratorError){code}
h2. What does success look like?  

This can be corrected by creating {{/etc/puppetlabs/facter/facter.conf}} and adding a block for the ec2_userdata fact.
{code:java}
facts : {
  blocklist : [ "ec2_userdata"]
}{code}
h2. How will success be validated?  

{{facter}} should detect whether the ec2_userdata fact is encoded properly before attempting to add it to the facts hash.

Michael Hashizume (Jira)

unread,
May 10, 2022, 4:32:01 PM5/10/22
to puppe...@googlegroups.com
Michael Hashizume updated an issue
Change By: Michael Hashizume
Acceptance Criteria: Mimic Facter 3 behavior in Factor 4 when ingesting ec2_userdata
Story Points: 3
Team: Phoenix
Reply all
Reply to author
Forward
0 new messages