longhorn: bound settings sync curl calls and rerun job
This commit is contained in:
parent
26fab34de5
commit
2df830f01b
@ -2,10 +2,11 @@
|
|||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
metadata:
|
metadata:
|
||||||
name: longhorn-settings-ensure-5
|
name: longhorn-settings-ensure-6
|
||||||
namespace: longhorn-system
|
namespace: longhorn-system
|
||||||
spec:
|
spec:
|
||||||
backoffLimit: 0
|
backoffLimit: 0
|
||||||
|
activeDeadlineSeconds: 240
|
||||||
ttlSecondsAfterFinished: 3600
|
ttlSecondsAfterFinished: 3600
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
|
|||||||
@ -4,11 +4,12 @@ set -eu
|
|||||||
# Longhorn blocks direct CR patches for some settings; use the internal API instead.
|
# Longhorn blocks direct CR patches for some settings; use the internal API instead.
|
||||||
|
|
||||||
api_base="http://longhorn-backend.longhorn-system.svc:9500/v1/settings"
|
api_base="http://longhorn-backend.longhorn-system.svc:9500/v1/settings"
|
||||||
|
curl_opts="-fsS --connect-timeout 3 --max-time 15"
|
||||||
|
|
||||||
wait_for_api() {
|
wait_for_api() {
|
||||||
attempts=30
|
attempts=30
|
||||||
while [ "${attempts}" -gt 0 ]; do
|
while [ "${attempts}" -gt 0 ]; do
|
||||||
if curl -fsS "${api_base}" >/dev/null 2>&1; then
|
if curl ${curl_opts} "${api_base}" >/dev/null 2>&1; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
attempts=$((attempts - 1))
|
attempts=$((attempts - 1))
|
||||||
@ -22,14 +23,14 @@ update_setting() {
|
|||||||
name="$1"
|
name="$1"
|
||||||
value="$2"
|
value="$2"
|
||||||
|
|
||||||
current="$(curl -fsS "${api_base}/${name}" || true)"
|
current="$(curl ${curl_opts} "${api_base}/${name}" || true)"
|
||||||
if echo "${current}" | grep -Fq "\"value\":\"${value}\""; then
|
if echo "${current}" | grep -Fq "\"value\":\"${value}\""; then
|
||||||
echo "Setting ${name} already set."
|
echo "Setting ${name} already set."
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Setting ${name} -> ${value}"
|
echo "Setting ${name} -> ${value}"
|
||||||
curl -fsS -X PUT \
|
curl ${curl_opts} -X PUT \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"value\":\"${value}\"}" \
|
-d "{\"value\":\"${value}\"}" \
|
||||||
"${api_base}/${name}" >/dev/null
|
"${api_base}/${name}" >/dev/null
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user