Skip to content

Commit

Permalink
12084 - STDIN detection in mco rpc fails when run non interactively
Browse files Browse the repository at this point in the history
When running mco rpc from at, scripts, jenkins etc STDIN would not
be a tty but there would be no data on STDIN.

In the past it would assume there was discovery data on STDIN in
this scenario and fail.  Now it checks if the data read is empty
and does a normal discovery if it is
  • Loading branch information
ripienaar committed Jan 27, 2012
1 parent b77874e commit a95ba21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions plugins/mcollective/application/rpc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,15 @@ def main
else
# if there's stuff on STDIN assume its JSON that came from another
# rpc or printrpc, we feed that in as discovery data
discover_args = {:verbose => true}

unless STDIN.tty?
discovery_data = STDIN.read
mc.discover(:json => discovery_data)
else
mc.discover :verbose => true
discovery_data = STDIN.read.chomp
discover_args = {:json => discovery_data} unless discovery_data == ""
end

mc.discover discover_args

printrpc mc.send(configuration[:action], configuration[:arguments])

printrpcstats :caption => "#{configuration[:agent]}##{configuration[:action]} call stats"
Expand Down
1 change: 1 addition & 0 deletions website/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ title: Changelog

|Date|Description|Ticket|
|----|-----------|------|
|2012/01/27|Improve handling of discovery data on STDIN to avoid failures when run without a TTY and without supplying discovery data|12084|
|2012/01/25|Allow the syslog facility to be configured|12109|
|2012/01/13|Add a RPC agent validator to ensure input is one of list of known good values|11935|
|2012/01/09|The printrpc helper did not correctly display empty strings in received output|11012|
Expand Down

0 comments on commit a95ba21

Please sign in to comment.