Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't emit ProcessOutput objects #1608

Open
joshcooper opened this issue Dec 7, 2023 · 0 comments
Open

Don't emit ProcessOutput objects #1608

joshcooper opened this issue Dec 7, 2023 · 0 comments

Comments

@joshcooper
Copy link

Describe the Bug

https://puppet.atlassian.net/browse/PUP-7808 changed puppet resource <type> --to_yaml so that it emits structured data correctly, using pops serialization. One unintended side-effect is that any module whose instances method returns resources whose values are the result of executed commands (via Puppet::Util::Execution.execute or the commands provider framework) may be emitted as:

mysql_database:
  PERCONA_SCHEMA:
    ensure: present
    charset: !ruby/string:Puppet::Util::Execution::ProcessOutput utf8
    collate: !ruby/string:Puppet::Util::Execution::ProcessOutput utf8_general_ci

While it is technically valid YAML, it is not parseable if the puppet classes aren't loaded or tags aren't stripped.

We will fix puppet in https://puppet.atlassian.net/browse/PUP-10105 to not emit ProcessOutput classes (and likely warn).

But the mysql module should call ProcessOutput#to_s when creating resources. I think this could be handled when calling mysql_raw(...).to_s in

def self.mysql_caller(text_of_sql, type)
if type.eql? 'system'
if File.file?("#{Facter.value(:root_home)}/.mylogin.cnf")
ENV['MYSQL_TEST_LOGIN_FILE'] = "#{Facter.value(:root_home)}/.mylogin.cnf"
mysql_raw([system_database, '-e', text_of_sql].flatten.compact)
else
mysql_raw([defaults_file, system_database, '-e', text_of_sql].flatten.compact)
end
elsif type.eql? 'regular'
if File.file?("#{Facter.value(:root_home)}/.mylogin.cnf")
ENV['MYSQL_TEST_LOGIN_FILE'] = "#{Facter.value(:root_home)}/.mylogin.cnf"
mysql_raw(['-NBe', text_of_sql].flatten.compact)
else
mysql_raw([defaults_file, '-NBe', text_of_sql].flatten.compact)
end
else
raise Puppet::Error, _("#mysql_caller: Unrecognised type '%{type}'" % { type: type })
end
end

Expected Behavior

Running puppet resource mysql_database --to_yaml should not emit ProcessOuput tags

Additional Context

This originally was reported in https://puppet.atlassian.net/browse/PUP-7808?focusedCommentId=59303

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant