From 1418511d9ede3cdd24464f6870bcae42e021fbdb Mon Sep 17 00:00:00 2001 From: rdlrt <3169068+rdlrt@users.noreply.github.com> Date: Sun, 24 Sep 2023 23:43:44 +0000 Subject: [PATCH] Bump HAProxy version and update v1 --- scripts/cnode-helper-scripts/env | 2 +- scripts/grest-helper-scripts/grest-poll.sh | 6 ++--- scripts/grest-helper-scripts/setup-grest.sh | 29 ++++++++++++--------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/scripts/cnode-helper-scripts/env b/scripts/cnode-helper-scripts/env index ab8a4ff29..2357f18b7 100644 --- a/scripts/cnode-helper-scripts/env +++ b/scripts/cnode-helper-scripts/env @@ -1030,7 +1030,7 @@ esac test_koios() { # make sure KOIOS_API is reachable, else fall back to cli - [[ ${ENABLE_KOIOS} = 'Y' && -n ${KOIOS_API} && $(curl -Isf -m 5 ${KOIOS_API}/tip | head -1) = *"200 OK"* ]] || unset KOIOS_API + [[ ${ENABLE_KOIOS} = 'Y' && -n ${KOIOS_API} && $(curl -sfk -o /dev/null -w "%{http_code}" -m 5 ${KOIOS_API}/tip | awk '{print $1}') = "200" ]] || unset KOIOS_API } [[ ${OFFLINE_MODE} = "N" && ${SHELLEY_TRANS_EPOCH} -eq -1 ]] && getNodeMetrics && getShelleyTransitionEpoch diff --git a/scripts/grest-helper-scripts/grest-poll.sh b/scripts/grest-helper-scripts/grest-poll.sh index 8346624af..d1455eb41 100755 --- a/scripts/grest-helper-scripts/grest-poll.sh +++ b/scripts/grest-helper-scripts/grest-poll.sh @@ -119,7 +119,7 @@ function chk_tip() { } function chk_rpc_struct() { - srvr_spec="$(curl -skL "${1}" | jq 'leaf_paths as $p | [$p[] | tostring] |join(".")' 2>/dev/null)" + srvr_spec="$(curl -skL "${1}" | jq '[leaf_paths as $p | { "key": $p | map(tostring) | join("_"), "value": getpath($p) }] | from_entries' | awk '{print $1 " " $2}' | grep -e ^\"paths -e ^\"parameters -e ^\"definitions 2>/dev/null)" api_endpts="$(grep ^\ \ / "${LOCAL_SPEC}" | sed -e 's# /#/#g' -e 's#:##' | sort)" for endpt in ${api_endpts} do @@ -155,7 +155,7 @@ function chk_cache_status() { else [[ -z "${GENESIS_JSON}" ]] && GENESIS_JSON="${PARENT}"/../files/shelley-genesis.json epoch_length=$(jq -r .epochLength "${GENESIS_JSON}" 2>/dev/null) - if [[ ${epoch_slot} -ge $(( epoch_length / 10 )) ]]; then + if [[ ${epoch_slot} -ge $(( epoch_length / 8 )) ]]; then if [[ "${last_actvstake_epoch}" != "${epoch}" ]]; then log_err "Active Stake cache for epoch ${epoch} still not populated as of ${epoch_slot} slot, maximum tolerance was $(( epoch_length / 10 )) !!" optexit @@ -194,7 +194,7 @@ function chk_endpt_post() { } function chk_asset_registry() { - ct=$(curl -sfkL -H 'Prefer: count=exact' "${GURL}/asset_registry_cache?select=name&limit=1" -I 2>/dev/null | grep -i "content-range" | cut -d/ -f2 | tr -d '[:space:]') + ct=$(curl -sfkL -H 'Prefer: count=exact' "${GURL}/asset_token_registry?select=asset_name&limit=1" -I 2>/dev/null | grep -i "content-range" | cut -d/ -f2 | tr -d '[:space:]') if [[ "${ct}" == "" ]] || [[ $ct -lt 150 ]]; then log_err "Asset registry cache seems incomplete (<150) assets, try deleting key: asset_registry_commit in control_table and wait for next cron run" optexit diff --git a/scripts/grest-helper-scripts/setup-grest.sh b/scripts/grest-helper-scripts/setup-grest.sh index 3a04a52e3..3a3907cf0 100755 --- a/scripts/grest-helper-scripts/setup-grest.sh +++ b/scripts/grest-helper-scripts/setup-grest.sh @@ -275,7 +275,8 @@ SGVERSION=v1.0.11rc common_update() { # Create skeleton whitelist URL file if one does not already exist using most common option curl -sfkL "https://${KOIOS_SRV}/koiosapi.yaml" -o "${CNODE_HOME}"/files/koiosapi.yaml 2>/dev/null - grep " #RPC" "${CNODE_HOME}"/files/koiosapi.yaml | sed -e 's#^ /#/#' | cut -d: -f1 | sort > "${CNODE_HOME}"/files/grestrpcs 2>/dev/null + grep "^ /" "${CNODE_HOME}"/files/koiosapi.yaml | grep -v -e submittx -e "#RPC" | sed -e 's#^ /#/#' | cut -d: -f1 | sort > "${CNODE_HOME}"/files/grestrpcs 2>/dev/null + echo "/control_table" >> "${CNODE_HOME}"/files/grestrpcs 2>/dev/null checkUpdate grest-poll.sh Y N N grest-helper-scripts >/dev/null sed -i "s# API_STRUCT_DEFINITION=\"https://api.koios.rest/koiosapi.yaml\"# API_STRUCT_DEFINITION=\"https://${KOIOS_SRV}/koiosapi.yaml\"#g" grest-poll.sh checkUpdate checkstatus.sh Y N N grest-helper-scripts >/dev/null @@ -341,9 +342,9 @@ SGVERSION=v1.0.11rc } deploy_haproxy() { - printf "[Re]Installing HAProxy.." + printf "\n[Re]Installing HAProxy.." pushd ~/tmp >/dev/null || err_exit - haproxy_url="http://www.haproxy.org/download/2.6/src/haproxy-2.6.5.tar.gz" + haproxy_url="http://www.haproxy.org/download/2.8/src/haproxy-2.8.3.tar.gz" if curl -sL -f -m ${CURL_TIMEOUT} -o haproxy.tar.gz "${haproxy_url}"; then tar xf haproxy.tar.gz &>/dev/null && rm -f haproxy.tar.gz if command -v apt-get >/dev/null; then @@ -352,7 +353,7 @@ SGVERSION=v1.0.11rc if command -v yum >/dev/null; then sudo yum -y install pcre-devel >/dev/null || err_exit "'sudo yum -y install prce-devel' failed!" fi - cd haproxy-2.6.5 || return + cd haproxy-2.8.3 || return make clean >/dev/null make -j $(nproc) TARGET=linux-glibc USE_ZLIB=1 USE_LIBCRYPT=1 USE_OPENSSL=1 USE_PCRE=1 USE_SYSTEMD=1 USE_PROMEX=1 >/dev/null sudo make install-bin >/dev/null @@ -440,23 +441,27 @@ SGVERSION=v1.0.11rc bind 0.0.0.0:8053 ## If using SSL, comment line above and uncomment line below #bind :8453 ssl crt /etc/ssl/server.pem no-sslv3 + compression direction response + compression algo-res gzip + compression type-res application/json + option http-buffer-request http-request set-log-level silent acl srv_down nbsrv(grest_postgrest) eq 0 acl is_wss hdr(Upgrade) -i websocket http-request use-service prometheus-exporter if { path /metrics } http-request track-sc0 src table flood_lmt_rate - http-request deny deny_status 429 if { sc_http_req_rate(0) gt 250 } - use_backend ogmios if { path_beg /api/v0/ogmios } || { path_beg /dashboard.js } || { path_beg /assets } || { path_beg /health } || is_wss - use_backend submitapi if { path_beg /api/v0/submittx } + http-request deny deny_status 429 if { sc_http_req_rate(0) gt 500 } + use_backend ogmios if { path_beg /api/v1/ogmios } || { path_beg /dashboard.js } || { path_beg /assets } || { path_beg /health } || is_wss + use_backend submitapi if { path_beg /api/v1/submittx } use_backend grest_failover if srv_down default_backend grest_postgrest backend grest_postgrest balance first #option external-check - acl grestrpcs path_beg -f \"\\\$GRESTTOP\"/files/grestrpcs - http-request set-path \"%[path,regsub(^/api/v0/,/)]\" - http-request set-path \"%[path,regsub(^/,/rpc/)]\" if grestrpcs + acl grestviews path_beg -f \"\\\$GRESTTOP\"/files/grestrpcs + http-request set-path \"%[path,regsub(^/api/v1/,/)]\" + http-request set-path \"%[path,regsub(^/,/rpc/)]\" if !grestviews !{ path_beg /rpc } !{ path -i / } #external-check path \"/usr/bin:/bin:/tmp:/sbin:/usr/sbin\" #external-check command \"\\\$GRESTTOP\"/scripts/grest-poll.sh server local 127.0.0.1:8050 check inter 20000 fall 1 rise 2 @@ -468,7 +473,7 @@ SGVERSION=v1.0.11rc backend ogmios balance first - http-request set-path \"%[path,regsub(^/api/v0/ogmios/,/)]\" + http-request set-path \"%[path,regsub(^/api/v1/ogmios/,/)]\" option httpchk GET /health http-check expect status 200 default-server inter 20s fall 1 rise 2 @@ -477,7 +482,7 @@ SGVERSION=v1.0.11rc backend submitapi balance first option httpchk POST /api/submit/tx - http-request set-path \"%[path,regsub(^/api/v0/submittx,/api/submit/tx)]\" + http-request set-path \"%[path,regsub(^/api/v1/submittx,/api/submit/tx)]\" http-check expect status 415 default-server inter 20s fall 1 rise 2 server local 127.0.0.1:8090 check