Compare commits

..

1 Commits

Author SHA1 Message Date
390f5d8d3b Use laconic-so without registry mutex 2024-10-28 16:01:36 +05:30
6 changed files with 24 additions and 80 deletions

View File

@ -9,5 +9,4 @@ CLEAN_CONTAINERS=false
SYSTEM_PRUNE=false
WEBAPP_IMAGE_PRUNE=true
CHECK_INTERVAL=5
FQDN_POLICY="allow"
DEPLOYMENT_IP="k8s.cluster.ip.address"
FQDN_POLICY="allow"

View File

@ -11,7 +11,7 @@ RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg -
apt update && apt install -y nodejs
# laconic-so
RUN curl -LO https://git.vdb.to/cerc-io/stack-orchestrator/releases/download/latest/laconic-so && \
RUN curl -LO https://git.vdb.to/cerc-io/stack-orchestrator/releases/download/v1.1.0-0c47da4-202410210702/laconic-so && \
chmod +x ./laconic-so && \
mv ./laconic-so /usr/bin/laconic-so
@ -44,5 +44,5 @@ COPY . /app/
WORKDIR /app/
RUN rm -rf node_modules && yarn && yarn clean && yarn build:release
COPY scripts .
CMD ["./scripts/run.sh"]
COPY run.sh .
CMD ["./run.sh"]

View File

@ -133,9 +133,6 @@ OPENPGP_PASSPHRASE="SECRET"
OPENPGP_PRIVATE_KEY_FILE="/etc/config/webapp-deployer-api.my.domain.com.pgp.key"
LACONIC_CONFIG="/etc/config/registry.yml"
LRN=lrn://laconic/deployers/webapp-deployer-api.my.domain.com
CHECK_INTERVAL=15
AUCTION_CHECK_INTERVAL=10
HANDLE_AUCTION_REQUESTS=true
AUCTION_BID_AMOUNT=50000
```

View File

@ -8,15 +8,6 @@ services:
ports:
- 9555
cerc-webapp-auction-handler:
image: cerc/webapp-deployer-backend:local
restart: always
environment:
RUN_AUCTIONS_HANDLER: "true"
volumes:
- srv:/srv
- config:/etc/config:ro
volumes:
config:
srv:

View File

@ -1,10 +1,5 @@
#!/bin/bash
if [ "$RUN_AUCTIONS_HANDLER" = "true" ]; then
exec "./scripts/handle-auctions.sh"
exit
fi
function is_privileged {
ip link add dummy0 type dummy >/dev/null
if [[ $? -eq 0 ]]; then
@ -25,11 +20,6 @@ if [ -z "$DEPLOYMENT_RECORD_NAMESPACE" ]; then
exit 2
fi
if [ "$FQDN_POLICY" = "allow" ] && [ -z "$DEPLOYMENT_IP" ]; then
echo "DEPLOYMENT_IP is required with 'allow' FQDN_POLICY"
exit 2
fi
if [ -z "$IMAGE_REGISTRY" ]; then
echo "IMAGE_REGISTRY is required."
exit 2
@ -47,6 +37,11 @@ fi
AUCTION_OPTS=""
if [ "$HANDLE_AUCTION_REQUESTS" = "true" ]; then
if [ -z "$AUCTION_BID_AMOUNT" ]; then
echo "AUCTION_BID_AMOUNT is required when handling auction requsts."
exit 2
fi
AUCTION_OPTS="--auction-requests"
fi
@ -54,7 +49,6 @@ STORAGE_ROOT="${STORAGE_ROOT:-/srv}"
DEPLOYMENTS_DIR="${DEPLOYMENTS_DIR:-$STORAGE_ROOT/deployments}"
LOG_DIR="${LOG_DIR:-$STORAGE_ROOT/logs}"
CONTAINERS_DIR="${CONTAINER_DIR:-$STORAGE_ROOT/containers}"
REGISTRY_LOCK_FILE="${REGISTRY_LOCK_FILE:-/srv/registry_mutex_lock_file}"
if [[ ! -d "${DEPLOYMENTS_DIR}" ]]; then
mkdir -p "${DEPLOYMENTS_DIR}"
@ -132,7 +126,6 @@ while true; do
echo "########### UNDEPLOY ############"
laconic-so undeploy-webapp-from-registry \
--laconic-config /etc/config/laconic.yml \
--registry-lock-file "${REGISTRY_LOCK_FILE}" \
--deployment-parent-dir "${DEPLOYMENTS_DIR}" \
--delete-names \
--delete-volumes \
@ -140,7 +133,7 @@ while true; do
--include-tags "$INCLUDE_TAGS" \
--exclude-tags "$EXCLUDE_TAGS" \
--lrn "$LRN" \
--min-required-payment 0 \
--min-required-payment ${MIN_REQUIRED_PAYMENT:-0} \
$EXTRA_UNDEPLOY_OPTS \
$UPDATE_OPTS \
--discover
@ -155,7 +148,6 @@ while true; do
laconic-so deploy-webapp-from-registry \
--kube-config /etc/config/kube.yml \
--laconic-config /etc/config/laconic.yml \
--registry-lock-file "${REGISTRY_LOCK_FILE}" \
--image-registry ${IMAGE_REGISTRY} \
--deployment-parent-dir "${DEPLOYMENTS_DIR}" \
--dns-suffix ${DEPLOYMENT_DNS_SUFFIX} \
@ -165,13 +157,11 @@ while true; do
--include-tags "$INCLUDE_TAGS" \
--exclude-tags "$EXCLUDE_TAGS" \
--fqdn-policy "${FQDN_POLICY:-prohibit}" \
--ip "${DEPLOYMENT_IP}" \
--lrn "$LRN" \
--min-required-payment ${MIN_REQUIRED_PAYMENT:-0} \
--config-upload-dir "$UPLOAD_DIRECTORY" \
--private-key-file "$OPENPGP_PRIVATE_KEY_FILE" \
--private-key-passphrase "$OPENPGP_PASSPHRASE" \
--recreate-on-deploy \
$AUCTION_OPTS \
$LOG_OPTS \
$EXTRA_DEPLOY_OPTS \
@ -184,6 +174,20 @@ while true; do
echo "############ DEPLOY FAILURE STATUS $rc #############"
fi
if [ "$HANDLE_AUCTION_REQUESTS" = "true" ]; then
echo "############ DEPLOYMENT AUCTION #############"
laconic-so handle-deployment-auction \
--laconic-config /etc/config/laconic.yml \
--state-file "${DEPLOYMENTS_DIR}/autoauction.state" \
--bid-amount ${AUCTION_BID_AMOUNT}
rc=$?
if [ $rc -eq 0 ]; then
echo "############ DEPLOYMENT AUCTION SUCCESS #############"
else
echo "############ DEPLOYMENT AUCTION FAILURE STATUS $rc #############"
fi
fi
# Cleanup any build leftovers
if [[ "${SYSTEM_PRUNE:-false}" == "true" ]]; then
docker system prune --all --force

View File

@ -1,47 +0,0 @@
#!/bin/bash
if [ ! -f "/etc/config/laconic.yml" ]; then
echo "/etc/config/laconic.yml is required."
exit 2
fi
if [ "$HANDLE_AUCTION_REQUESTS" = "true" ]; then
if [ -z "$AUCTION_BID_AMOUNT" ]; then
echo "AUCTION_BID_AMOUNT is required when handling auction requsts."
exit 2
fi
else
echo "Not handling auction requests"
# k8s integration only supports "always" restart policy, so wait indefinitely
# TODO: Exit container once restart policy is supported
tail -f /dev/null
fi
STORAGE_ROOT="${STORAGE_ROOT:-/srv}"
DEPLOYMENTS_DIR="${DEPLOYMENTS_DIR:-$STORAGE_ROOT/deployments}"
REGISTRY_LOCK_FILE="${REGISTRY_LOCK_FILE:-/srv/registry_mutex_lock_file}"
if [[ ! -d "${DEPLOYMENTS_DIR}" ]]; then
mkdir -p "${DEPLOYMENTS_DIR}"
fi
cd /app/
while true; do
echo "=============================================================="
echo "############ DEPLOYMENT AUCTION #############"
laconic-so handle-deployment-auction \
--laconic-config /etc/config/laconic.yml \
--registry-lock-file "${REGISTRY_LOCK_FILE}" \
--state-file "${DEPLOYMENTS_DIR}/autoauction.state" \
--bid-amount ${AUCTION_BID_AMOUNT}
rc=$?
if [ $rc -eq 0 ]; then
echo "############ DEPLOYMENT AUCTION SUCCESS #############"
else
echo "############ DEPLOYMENT AUCTION FAILURE STATUS $rc #############"
fi
sleep ${AUCTION_CHECK_INTERVAL:-10}
done