Alexandros Kosiaris has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/356212 )

Change subject: Force fact stringification in servermon reporter
......................................................................


Force fact stringification in servermon reporter

We want to enable structured facts in puppet. However, servermon, while
being generally agnostic to fact structure, is not developed with
structured facts in mind. For now, and while the future of the project
is still under discussion, force fact stringification in the reporter

Bug: T166203
Change-Id: I24413825342c4926b24eba530c8feefcee24790f
---
M modules/puppetmaster/lib/puppet/reports/servermon.rb
1 file changed, 3 insertions(+), 2 deletions(-)

Approvals:
  Alexandros Kosiaris: Verified; Looks good to me, approved
  Volans: Looks good to me, but someone else must approve



diff --git a/modules/puppetmaster/lib/puppet/reports/servermon.rb 
b/modules/puppetmaster/lib/puppet/reports/servermon.rb
index 71e8d92..adfc134 100644
--- a/modules/puppetmaster/lib/puppet/reports/servermon.rb
+++ b/modules/puppetmaster/lib/puppet/reports/servermon.rb
@@ -64,6 +64,7 @@
                 # This part of the code causes highly concurrent queries to the
                 # DB, so extra care is taken to avoid LOCKs, deadlocks etc
                 node_facts.values.each do |key, value|
+                    string_value = value.to_s
                     # First try to see if the fact_name already exists
                     con.query('BEGIN')
                     select_fact_name = "SELECT id from fact_names \
@@ -93,7 +94,7 @@
                     # Now try to update the fact_value, it is fails, insert it
                     update_fact_value = "UPDATE fact_values SET \
                     updated_at = '#{self.time}', \
-                    value = '#{value}' \
+                    value = '#{string_value}' \
                     WHERE fact_name_id=#{fact_id} AND host_id=#{host_id}"
                     if log_level == 'debug'
                         puts(update_fact_value)
@@ -103,7 +104,7 @@
                     if con.affected_rows == 0
                         insert_fact_value = "INSERT INTO fact_values( \
                         value,fact_name_id,host_id,updated_at,created_at) \
-                        VALUES('#{value}', #{fact_id}, #{host_id}, 
'#{self.time}', '#{self.time}')"
+                        VALUES('#{string_value}', #{fact_id}, #{host_id}, 
'#{self.time}', '#{self.time}')"
                         if log_level == 'debug'
                             puts(insert_fact_value)
                         end

-- 
To view, visit https://gerrit.wikimedia.org/r/356212
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I24413825342c4926b24eba530c8feefcee24790f
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <akosia...@wikimedia.org>
Gerrit-Reviewer: Alexandros Kosiaris <akosia...@wikimedia.org>
Gerrit-Reviewer: Volans <rcocci...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to