Jira (FACT-2934) Facter::Core::Execution does not set status variables in Facter 4
Title: Message Title Charlie Sharpsteen commented on FACT-2934 Re: Facter::Core::Execution does not set status variables in Facter 4 I tried out PE 2021.0.0-rc5-67-gbfc68f0 and the new behavior looks good # /opt/puppetlabs/puppet/bin/ruby -rfacter -e 'Facter::Core::Execution.execute("false") and puts($?.exitstatus)' 1 Add Comment This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.385912.1612301794000.135003.1612566180025%40Atlassian.JIRA.
Jira (FACT-2934) Facter::Core::Execution does not set status variables in Facter 4
Title: Message Title Claire Cadman updated an issue Facter / FACT-2934 Facter::Core::Execution does not set status variables in Facter 4 Change By: Claire Cadman Labels: doc_reviewed Add Comment This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.385912.1612301794000.134135.1612516740031%40Atlassian.JIRA.
Jira (FACT-2934) Facter::Core::Execution does not set status variables in Facter 4
Title: Message Title Oana Tanasoiu updated an issue Facter / FACT-2934 Facter::Core::Execution does not set status variables in Facter 4 Change By: Oana Tanasoiu Release Notes: Bug Fix Release Notes Summary: Description of the problem: The exec and execute methods of the Facter::Core::Execution module are commonly used to execute external processes in custom facts. In Facter 4, these methods no longer set the global Ruby variables $CHILD_STATUS or $? because Open3 is used and it consumes the exit status of the child process.Description of the fix: Reimplement Open3.popen3 to not use Process.detach but Process.wait instead. Add Comment This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.385912.1612301794000
Jira (FACT-2934) Facter::Core::Execution does not set status variables in Facter 4
Title: Message Title Ciprian Badescu updated an issue Facter / FACT-2934 Facter::Core::Execution does not set status variables in Facter 4 Change By: Ciprian Badescu Fix Version/s: FACT 4.0.50 Add Comment This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.385912.1612301794000.133022.1612435200037%40Atlassian.JIRA.
Jira (FACT-2934) Facter::Core::Execution does not set status variables in Facter 4
Title: Message Title Nick Walker commented on FACT-2934 Re: Facter::Core::Execution does not set status variables in Facter 4 Mihai BuzgauGheorghe Popescu Add Comment This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.385912.1612301794000.131307.1612302780148%40Atlassian.JIRA.
Jira (FACT-2934) Facter::Core::Execution does not set status variables in Facter 4
Title: Message Title Charlie Sharpsteen updated an issue Facter / FACT-2934 Facter::Core::Execution does not set status variables in Facter 4 Change By: Charlie Sharpsteen The {{exec}} and {{execute}} methods of the {{Facter::Core::Execution}} module are commonly used to execute external processes in custom facts. In Facter 4, these methods no longer set the global Ruby variables {{$CHILD_STATUS}} or {{$?}}.This is a regression of FACT-1284 which was its self a regression of behavior present in Facter 2.x and 1.x.h2. Reproduction Case - Install {{puppet-agent}} 7 on CentOS 7:{code:bash}yum install -y http://yum.puppetlabs.com/puppet7-release-el-7.noarch.rpmyum install -y puppet-agentsource /etc/profile.d/puppet-agent.sh{code} - Create a directory containing a custom fact that uses the {{$?}} variable:{code:bash}mkdir exit_code_testcat <<'EOF' > exit_code_test/exit_code_test.rbFacter.add("exit_code_test") do setcode doFacter::Util::Resolution.exec('/usr/bin/false')"/usr/bin/false exited with code: %{ code status }" % { code status : $?.exitstatus} endendEOF{code} - Run Facter:{code:bash}env FACTERLIB=$PWD/exit_code_test facter exit_code_test{code}h3. OutcomeThe fact fails to resolve, logging an error from a `nil` reference:{noformat}# facter --version4.0.49# env FACTERLIB=$PWD/exit_code_test facter exit_code_test[2021-02-02 21:33:19.961928 ] ERROR Facter - Error while resolving custom fact fact='exit_code_test', resolution='': undefined method `exitstatus' for nil:NilClass{noformat}h3. Expected OutcomeThe exit status resolves to 1 as it does in Facter 3:{noformat}# facter --version3.14.14 (commit e36657bea27254f003c8fc71d8ef57454db643e2)# env FACTERLIB=$PWD/exit_code_test facter exit_code_test/usr/bin/false exited with code: 1{noformat}And in Facter 2:{noformat}# facter --version2.5.7# env FACTERLIB=$PWD/exit_code_test facter exit_code_test/usr/bin/false exited with code: 1{noformat} Add Comment
Jira (FACT-2934) Facter::Core::Execution does not set status variables in Facter 4
Title: Message Title Charlie Sharpsteen commented on FACT-2934 Re: Facter::Core::Execution does not set status variables in Facter 4 I think this is occurring because Facter 4 implements Facter::Core::Execution using Open3.popen3: https://github.com/puppetlabs/facter/blob/4.0.49/lib/facter/custom_facts/core/execution/base.rb#L73 However, Open3 calls Process.detach which spawns a thread to reap the child process. This consumes the exit status of the child without setting the global status variables: https://github.com/ruby/ruby/blob/v2_7_2/lib/open3.rb#L214 Add Comment This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935) -- You received this message because you are subscribed to the Google Groups "Puppet Bugs" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-bugs+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-bugs/JIRA.385912.1612301794000.131288.1612302060024%40Atlassian.JIRA.
Jira (FACT-2934) Facter::Core::Execution does not set status variables in Facter 4
Title: Message Title Charlie Sharpsteen created an issue Facter / FACT-2934 Facter::Core::Execution does not set status variables in Facter 4 Issue Type: Bug Affects Versions: FACT 4.0.49 Assignee: Unassigned Created: 2021/02/02 1:36 PM Priority: Critical Reporter: Charlie Sharpsteen The exec and execute methods of the Facter::Core::Execution module are commonly used to execute external processes in custom facts. In Facter 4, these methods no longer set the global Ruby variables $CHILD_STATUS or $?. This is a regression of FACT-1284 which was its self a regression of behavior present in Facter 2.x and 1.x. Reproduction Case Install puppet-agent 7 on CentOS 7: yum install -y http://yum.puppetlabs.com/puppet7-release-el-7.noarch.rpm yum install -y puppet-agent source /etc/profile.d/puppet-agent.sh