-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interface to support pause/resume gart service
Signed-off-by: Lei Wang <[email protected]>
- Loading branch information
1 parent
92863c8
commit bda8114
Showing
9 changed files
with
139 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ include "gart.controller-service.fullname" . }} | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
app: converter | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: converter | ||
ports: | ||
- protocol: TCP | ||
port: {{ .Values.controller.port }} | ||
targetPort: {{ .Values.controller.containerPort }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from flask import Flask | ||
import subprocess | ||
import os | ||
|
||
app = Flask(__name__) | ||
port = int(os.getenv("CONTROLLER_FLASK_PORT", 5000)) | ||
|
||
|
||
@app.route("/control/pause", methods=["POST"]) | ||
def pause(): | ||
subprocess.run( | ||
[ | ||
"/bin/bash", | ||
"-c", | ||
"/workspace/gart/scripts/pause_resume_data_processing.sh pause", | ||
] | ||
) | ||
return "Paused", 200 | ||
|
||
|
||
@app.route("/control/resume", methods=["POST"]) | ||
def resume(): | ||
subprocess.run( | ||
[ | ||
"/bin/bash", | ||
"-c", | ||
"/workspace/gart/scripts/pause_resume_data_processing.sh resume", | ||
] | ||
) | ||
return "Resumed", 200 | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", port=port) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/bin/bash | ||
|
||
op=$1 | ||
|
||
check_env_vars() { | ||
if [[ -z $DEBEZIUM_SERVICE ]] || [[ -z $DEBEZIUM_CONNECTOR_NAME ]]; then | ||
echo "Debezium service URL or connector name not set." | ||
exit 1 | ||
fi | ||
} | ||
|
||
if [[ $op == "pause" ]]; then | ||
echo "Pausing data processing" | ||
check_env_vars | ||
response=$(curl -s -o /dev/null -w "%{http_code}" -X PUT "http://${DEBEZIUM_SERVICE}/connectors/${DEBEZIUM_CONNECTOR_NAME}/pause") | ||
if [[ $response != 202 ]]; then | ||
echo "Failed to pause connector" | ||
exit 1 | ||
else | ||
echo "Connector paused successfully" | ||
exit 0 | ||
fi | ||
elif [[ $op == "resume" ]]; then | ||
echo "Resuming data processing" | ||
check_env_vars | ||
response=$(curl -s -o /dev/null -w "%{http_code}" -X PUT "http://${DEBEZIUM_SERVICE}/connectors/${DEBEZIUM_CONNECTOR_NAME}/resume") | ||
if [[ $response != 202 ]]; then | ||
echo "Failed to resume connector" | ||
exit 1 | ||
else | ||
echo "Connector resumed successfully" | ||
exit 0 | ||
fi | ||
else | ||
echo "Invalid operation $op" | ||
exit 1 | ||
fi |