Skip to content

Commit

Permalink
fix: 🐛 curl silent mode, add log, fix env
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy Okladin committed Nov 29, 2021
1 parent 46d0095 commit b531893
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions connector-restart
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,31 @@ info REQUEST_DELAY="$REQUEST_DELAY"

if [ "$SIDECAR_MODE" = true ]
then
#wait start kafka-connect
info 'Wait start kafka-connect 60 second'
sleep 60s
while true
do
do
info 'Get status connectors'
if connectorsjson=$(
curl -Lff "http://$KAFKA_CONNECT_HOST:$KAFKA_CONNECT_PORT/connectors?expand=status"
curl -Lffs "http://$KAFKA_CONNECT_HOST:$KAFKA_CONNECT_PORT/connectors?expand=status"
)
then
info 'Status connectors already'
# List current connectors and status
echo connectorsjson | \
echo $connectorsjson | \
jq '. | to_entries[] | [ .value.info.type, .key, .value.status.connector.state,.value.status.tasks[].state,.value.info.config."connector.class"]|join(":|:")' | \
column -s : -t| sed 's/\"//g'| sort
column -s : -t| sed 's/\"//g'
# Restart any connector tasks that are FAILED
echo connectorsjson | \
echo $connectorsjson | \
jq -c -M 'map({name: .status.name } + {tasks: .status.tasks}) | .[] | {task: ((.tasks[]) + {name: .name})} | select(.task.state=="FAILED") | {name: .task.name, task_id: .task.id|tostring} | ("/connectors/"+ .name + "/tasks/" + .task_id + "/restart")' | \
xargs -I{connector_and_task} curl -v -X POST "http://$KAFKA_CONNECT_HOST:$KAFKA_CONNECT_PORT"\{connector_and_task\}
else
fail 'Connect to API Kafka Connect' \
http://$KAFKA_CONNECT_HOST:$KAFKA_CONNECT_PORT \
'failed with status code' $? 'and message' $connectorsjson
fi
info 'Wait next check after' $REQUEST_DELAY 'minut(s)'
sleep "$REQUEST_DELAY"m
done
else
Expand Down

0 comments on commit b531893

Please sign in to comment.