-
Notifications
You must be signed in to change notification settings - Fork 937
Added which-broken-replicas to list replicas with errors #660
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR! Let me also dig around and see if I can make something that suits you better
resources/bin/orchestrator-client
Outdated
@@ -233,6 +233,10 @@ function filter_keys { | |||
cat - | jq '.[] | .Key' | |||
} | |||
|
|||
function filter_broken { | |||
cat - | jq 'reduce .[] as $instance ([]; if $instance.LastSQLError != "\"\"" then . + [$instance] elif $instance.LastIOError != "\"\"" then . + [$instance] else . + [] end)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's a shorter way to write this:
cat - | jq 'reduce .[] as $instance ([]; if $instance.LastSQLError != "\"\"" then . + [$instance] elif $instance.LastIOError != "\"\"" then . + [$instance] else . + [] end)' | |
cat - | jq '.[] | select(.LastSQLError != "" or .LastIOError != "")' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or I think I need to re-array the result though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I used select
before but had a problem with something, but it was late and I probably mistyped something
This PR depends on #662 to be merged. |
@@ -233,6 +233,10 @@ function filter_keys { | |||
cat - | jq '.[] | .Key' | |||
} | |||
|
|||
function filter_broken_replicas { | |||
cat - | jq '.[] | select((.Slave_SQL_Running == false or .Slave_IO_Running == false) and (.LastSQLError != "" or .LastIOError != "")) | [.]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[.]
is a trick that wraps each element in its own array, which is not technically an array of objects, but works well for the rest of filtering.
Adding
which-broken-replicas
to address #588; Any replicas of instancexxx
that show withLastSQLError
orLastIOError
are reported back to the user.