Fix encoding of shotgun stdout

Mcollective uses sustemu module to execute shell commands. This module
doesn't care about encoding and as a result we get shotgun stdout as a
string with ASCII-8BIT encoding. Later we get a failure at the attempt
to encode it to JSON. However, shotgun output depends on locale settings
and is usually UTF-8.

Change-Id: I838f1aa55ea2885c1353a352c537dfe1bcd1e7e3
Closes-Bug: #1604311
This commit is contained in:
Georgy Kibardin 2016-07-25 15:29:11 +03:00
parent b1f8e45077
commit 90d0aa8ecd
1 changed files with 1 additions and 1 deletions

View File

@ -44,7 +44,7 @@ module Astute
if result[:data][:exit_code] == 0
Astute.logger.info("#{ctx.task_id}: Snapshot is done.")
report_success(ctx, result[:data][:stdout].rstrip)
report_success(ctx, result[:data][:stdout].force_encoding(Encoding.default_external).rstrip)
elsif result[:data][:exit_code] == 28
Astute.logger.error("#{ctx.task_id}: Disk space for creating snapshot exceeded.")
report_error(ctx, "Shotgun exit code: #{result[:data][:exit_code]}. Disk space for creating snapshot exceeded.")