Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Added which-broken-replicas to list replicas with errors #660

Merged
merged 5 commits into from
Oct 18, 2018

Conversation

cezmunsta
Copy link
Contributor

Adding which-broken-replicas to address #588; Any replicas of instance xxx that show with LastSQLError or LastIOError are reported back to the user.

orchestrator-client -c which-broken-replicas -i xxx

Copy link
Collaborator

@shlomi-noach shlomi-noach left a 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

@@ -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)'
Copy link
Collaborator

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:

Suggested change
cat - | jq 'reduce .[] as $instance ([]; if $instance.LastSQLError != "\"\"" then . + [$instance] elif $instance.LastIOError != "\"\"" then . + [$instance] else . + [] end)'
cat - | jq '.[] | select(.LastSQLError != "" or .LastIOError != "")'

Copy link
Collaborator

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.

Copy link
Contributor Author

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

@shlomi-noach
Copy link
Collaborator

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 != "")) | [.]'
Copy link
Collaborator

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.

@shlomi-noach shlomi-noach merged commit 566ebcb into openark:master Oct 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants