mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-30 02:02:36 +00:00
[WIFI-3162] Add: readiness_check script that is using cli to check if system is ready
This commit is contained in:
@@ -64,7 +64,7 @@ RUN addgroup -S "$OWPROV_USER" && \
|
|||||||
RUN mkdir /openwifi
|
RUN mkdir /openwifi
|
||||||
RUN mkdir -p "$OWPROV_ROOT" "$OWPROV_CONFIG" && \
|
RUN mkdir -p "$OWPROV_ROOT" "$OWPROV_CONFIG" && \
|
||||||
chown "$OWPROV_USER": "$OWPROV_ROOT" "$OWPROV_CONFIG"
|
chown "$OWPROV_USER": "$OWPROV_ROOT" "$OWPROV_CONFIG"
|
||||||
RUN apk add --update --no-cache librdkafka curl-dev mariadb-connector-c libpq su-exec gettext ca-certificates
|
RUN apk add --update --no-cache librdkafka curl-dev mariadb-connector-c libpq su-exec gettext ca-certificates bash jq curl
|
||||||
|
|
||||||
COPY --from=builder /owprov/cmake-build/owprov /openwifi/owprov
|
COPY --from=builder /owprov/cmake-build/owprov /openwifi/owprov
|
||||||
COPY --from=builder /cppkafka/cmake-build/src/lib/* /lib/
|
COPY --from=builder /cppkafka/cmake-build/src/lib/* /lib/
|
||||||
@@ -77,6 +77,8 @@ COPY docker-entrypoint.sh /
|
|||||||
RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \
|
RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \
|
||||||
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.pem
|
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.pem
|
||||||
|
|
||||||
|
COPY readiness_check /readiness_check
|
||||||
|
|
||||||
EXPOSE 16005 17005 16105
|
EXPOSE 16005 17005 16105
|
||||||
|
|
||||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ checks:
|
|||||||
path: /
|
path: /
|
||||||
port: 16105
|
port: 16105
|
||||||
readiness:
|
readiness:
|
||||||
httpGet:
|
exec:
|
||||||
path: /
|
command:
|
||||||
port: 16105
|
- /readiness_check
|
||||||
|
failureThreshold: 1
|
||||||
|
|
||||||
ingresses:
|
ingresses:
|
||||||
restapi:
|
restapi:
|
||||||
@@ -103,8 +104,16 @@ persistence:
|
|||||||
public_env_variables:
|
public_env_variables:
|
||||||
OWPROV_ROOT: /owprov-data
|
OWPROV_ROOT: /owprov-data
|
||||||
OWPROV_CONFIG: /owprov-data
|
OWPROV_CONFIG: /owprov-data
|
||||||
|
# Environment variables required for the readiness checks using script
|
||||||
|
FLAGS: "-s --connect-timeout 3"
|
||||||
|
# NOTE in order for readiness check to use system info you need to set READINESS_METHOD to "systeminfo" and set OWSEC to the OWSEC's REST API endpoint
|
||||||
|
#READINESS_METHOD: systeminfo
|
||||||
|
#OWSEC: gw-qa01.cicd.lab.wlan.tip.build:16001
|
||||||
|
|
||||||
secret_env_variables: {}
|
secret_env_variables:
|
||||||
|
# NOTE in order for readiness check to use system info method you need to override these values to the real OWSEC credentials
|
||||||
|
OWSEC_USERNAME: tip@ucentral.com
|
||||||
|
OWSEC_PASSWORD: openwifi
|
||||||
|
|
||||||
configProperties:
|
configProperties:
|
||||||
# -> Public part
|
# -> Public part
|
||||||
|
|||||||
65
readiness_check
Executable file
65
readiness_check
Executable file
@@ -0,0 +1,65 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [[ "$(which jq)" == "" ]]
|
||||||
|
then
|
||||||
|
echo "You need the package jq installed to use this script."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$(which curl)" == "" ]]
|
||||||
|
then
|
||||||
|
echo "You need the package curl installed to use this script."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${OWSEC}" == "" ]]
|
||||||
|
then
|
||||||
|
echo "You must set the variable OWSEC in order to use this script. Something like"
|
||||||
|
echo "OWSEC=security.isp.com:16001"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${OWSEC_USERNAME}" == "" ]]
|
||||||
|
then
|
||||||
|
echo "You must set the variable OWSEC_USERNAME in order to use this script. Something like"
|
||||||
|
echo "OWSEC_USERNAME=tip@ucentral.com"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${OWSEC_PASSWORD}" == "" ]]
|
||||||
|
then
|
||||||
|
echo "You must set the variable OWSEC_PASSWORD in order to use this script. Something like"
|
||||||
|
echo "OWSEC_PASSWORD=openwifi"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${READINESS_METHOD}" == "systeminfo" ]]
|
||||||
|
then
|
||||||
|
# Get OAuth token from OWSEC and cache it or use cached one
|
||||||
|
payload="{ \"userId\" : \"$OWSEC_USERNAME\" , \"password\" : \"$OWSEC_PASSWORD\" }"
|
||||||
|
if [[ -f "/tmp/token" ]]
|
||||||
|
then
|
||||||
|
token=$(cat /tmp/token)
|
||||||
|
else
|
||||||
|
token=$(curl ${FLAGS} -X POST -H "Content-Type: application/json" -d "$payload" "https://${OWSEC}/api/v1/oauth2" | jq -r '.access_token')
|
||||||
|
fi
|
||||||
|
if [[ "${token}" == "" ]]
|
||||||
|
then
|
||||||
|
echo "Could not login. Please verify the host and username/password."
|
||||||
|
exit 13
|
||||||
|
fi
|
||||||
|
echo -n $token > /tmp/token
|
||||||
|
|
||||||
|
# Make systeminfo request to the local owprov instance
|
||||||
|
export RESTAPI_PORT=$(grep 'openwifi.restapi.host.0.port' $OWPROV_CONFIG/owprov.properties | awk -F '=' '{print $2}' | xargs | envsubst)
|
||||||
|
curl ${FLAGS} -k -X GET "https://localhost:$RESTAPI_PORT/api/v1/system?command=info" \
|
||||||
|
-H "accept: application/json" \
|
||||||
|
-H "Authorization: Bearer ${token}" > /tmp/result.json
|
||||||
|
exit_code=$?
|
||||||
|
jq < /tmp/result.json
|
||||||
|
exit $exit_code
|
||||||
|
else
|
||||||
|
export ALB_PORT=$(grep 'alb.port' $OWPROV_CONFIG/owprov.properties | awk -F '=' '{print $2}' | xargs | envsubst)
|
||||||
|
curl localhost:$ALB_PORT
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user