Author SHA1 Message Date
prathamesh 390f5d8d3b Use laconic-so without registry mutex 2024-10-28 16:01:36 +05:30
3 changed files with 82 additions and 111 deletions
+1 -1
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 apt update && apt install -y nodejs
# laconic-so # 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 && \ chmod +x ./laconic-so && \
mv ./laconic-so /usr/bin/laconic-so mv ./laconic-so /usr/bin/laconic-so
+74 -74
View File
@@ -123,82 +123,82 @@ while true; do
yarn start & yarn start &
fi fi
# echo "########### UNDEPLOY ############" echo "########### UNDEPLOY ############"
# laconic-so undeploy-webapp-from-registry \ laconic-so undeploy-webapp-from-registry \
# --laconic-config /etc/config/laconic.yml \ --laconic-config /etc/config/laconic.yml \
# --deployment-parent-dir "${DEPLOYMENTS_DIR}" \ --deployment-parent-dir "${DEPLOYMENTS_DIR}" \
# --delete-names \ --delete-names \
# --delete-volumes \ --delete-volumes \
# --state-file "${DEPLOYMENTS_DIR}/autoremove.state" \ --state-file "${DEPLOYMENTS_DIR}/autoremove.state" \
# --include-tags "$INCLUDE_TAGS" \ --include-tags "$INCLUDE_TAGS" \
# --exclude-tags "$EXCLUDE_TAGS" \ --exclude-tags "$EXCLUDE_TAGS" \
# --lrn "$LRN" \ --lrn "$LRN" \
# --min-required-payment ${MIN_REQUIRED_PAYMENT:-0} \ --min-required-payment ${MIN_REQUIRED_PAYMENT:-0} \
# $EXTRA_UNDEPLOY_OPTS \ $EXTRA_UNDEPLOY_OPTS \
# $UPDATE_OPTS \ $UPDATE_OPTS \
# --discover --discover
# rc=$? rc=$?
# if [ $rc -eq 0 ]; then if [ $rc -eq 0 ]; then
# echo "############ UNDEPLOY SUCCESS #############" echo "############ UNDEPLOY SUCCESS #############"
# else else
# echo "############ UNDEPLOY FAILURE STATUS $rc #############" echo "############ UNDEPLOY FAILURE STATUS $rc #############"
# fi fi
# echo "############ DEPLOY #############" echo "############ DEPLOY #############"
# laconic-so deploy-webapp-from-registry \ laconic-so deploy-webapp-from-registry \
# --kube-config /etc/config/kube.yml \ --kube-config /etc/config/kube.yml \
# --laconic-config /etc/config/laconic.yml \ --laconic-config /etc/config/laconic.yml \
# --image-registry ${IMAGE_REGISTRY} \ --image-registry ${IMAGE_REGISTRY} \
# --deployment-parent-dir "${DEPLOYMENTS_DIR}" \ --deployment-parent-dir "${DEPLOYMENTS_DIR}" \
# --dns-suffix ${DEPLOYMENT_DNS_SUFFIX} \ --dns-suffix ${DEPLOYMENT_DNS_SUFFIX} \
# --record-namespace-dns lrn://${DEPLOYMENT_RECORD_NAMESPACE}/dns \ --record-namespace-dns lrn://${DEPLOYMENT_RECORD_NAMESPACE}/dns \
# --record-namespace-deployments lrn://${DEPLOYMENT_RECORD_NAMESPACE}/deployments \ --record-namespace-deployments lrn://${DEPLOYMENT_RECORD_NAMESPACE}/deployments \
# --state-file "${DEPLOYMENTS_DIR}/autodeploy.state" \ --state-file "${DEPLOYMENTS_DIR}/autodeploy.state" \
# --include-tags "$INCLUDE_TAGS" \ --include-tags "$INCLUDE_TAGS" \
# --exclude-tags "$EXCLUDE_TAGS" \ --exclude-tags "$EXCLUDE_TAGS" \
# --fqdn-policy "${FQDN_POLICY:-prohibit}" \ --fqdn-policy "${FQDN_POLICY:-prohibit}" \
# --lrn "$LRN" \ --lrn "$LRN" \
# --min-required-payment ${MIN_REQUIRED_PAYMENT:-0} \ --min-required-payment ${MIN_REQUIRED_PAYMENT:-0} \
# --config-upload-dir "$UPLOAD_DIRECTORY" \ --config-upload-dir "$UPLOAD_DIRECTORY" \
# --private-key-file "$OPENPGP_PRIVATE_KEY_FILE" \ --private-key-file "$OPENPGP_PRIVATE_KEY_FILE" \
# --private-key-passphrase "$OPENPGP_PASSPHRASE" \ --private-key-passphrase "$OPENPGP_PASSPHRASE" \
# $AUCTION_OPTS \ $AUCTION_OPTS \
# $LOG_OPTS \ $LOG_OPTS \
# $EXTRA_DEPLOY_OPTS \ $EXTRA_DEPLOY_OPTS \
# $UPDATE_OPTS \ $UPDATE_OPTS \
# --discover --discover
# rc=$? rc=$?
# if [ $rc -eq 0 ]; then if [ $rc -eq 0 ]; then
# echo "############ DEPLOY SUCCESS #############" echo "############ DEPLOY SUCCESS #############"
# else else
# echo "############ DEPLOY FAILURE STATUS $rc #############" echo "############ DEPLOY FAILURE STATUS $rc #############"
# fi fi
# if [ "$HANDLE_AUCTION_REQUESTS" = "true" ]; then if [ "$HANDLE_AUCTION_REQUESTS" = "true" ]; then
# echo "############ DEPLOYMENT AUCTION #############" echo "############ DEPLOYMENT AUCTION #############"
# laconic-so handle-deployment-auction \ laconic-so handle-deployment-auction \
# --laconic-config /etc/config/laconic.yml \ --laconic-config /etc/config/laconic.yml \
# --state-file "${DEPLOYMENTS_DIR}/autoauction.state" \ --state-file "${DEPLOYMENTS_DIR}/autoauction.state" \
# --bid-amount ${AUCTION_BID_AMOUNT} --bid-amount ${AUCTION_BID_AMOUNT}
# rc=$? rc=$?
# if [ $rc -eq 0 ]; then if [ $rc -eq 0 ]; then
# echo "############ DEPLOYMENT AUCTION SUCCESS #############" echo "############ DEPLOYMENT AUCTION SUCCESS #############"
# else else
# echo "############ DEPLOYMENT AUCTION FAILURE STATUS $rc #############" echo "############ DEPLOYMENT AUCTION FAILURE STATUS $rc #############"
# fi fi
# fi fi
# # Cleanup any build leftovers # Cleanup any build leftovers
# if [[ "${SYSTEM_PRUNE:-false}" == "true" ]]; then if [[ "${SYSTEM_PRUNE:-false}" == "true" ]]; then
# docker system prune --all --force docker system prune --all --force
# fi fi
# if [[ "${WEBAPP_IMAGE_PRUNE:-true}" == "true" ]]; then if [[ "${WEBAPP_IMAGE_PRUNE:-true}" == "true" ]]; then
# APP_IMAGES="$(docker image ls --quiet --filter 'reference=laconic-webapp')" APP_IMAGES="$(docker image ls --quiet --filter 'reference=laconic-webapp')"
# DANGLING_IMAGES="$(docker image ls --quiet --filter 'dangling=true')" DANGLING_IMAGES="$(docker image ls --quiet --filter 'dangling=true')"
# if [[ -n "$APP_IMAGES" ]] || [[ -n "$DANGLING_IMAGES" ]]; then if [[ -n "$APP_IMAGES" ]] || [[ -n "$DANGLING_IMAGES" ]]; then
# echo "Pruning images: $APP_IMAGES $DANGLING_IMAGES" echo "Pruning images: $APP_IMAGES $DANGLING_IMAGES"
# docker image rm -f $APP_IMAGES $DANGLING_IMAGES docker image rm -f $APP_IMAGES $DANGLING_IMAGES
# fi fi
# fi fi
sleep ${CHECK_INTERVAL:-15} sleep ${CHECK_INTERVAL:-15}
done done
+7 -36
View File
@@ -108,12 +108,8 @@ export class RegHelper {
} }
async deploymentRequestStatus(requestId?: string) { async deploymentRequestStatus(requestId?: string) {
console.log('Starting deploymentRequestStatus with requestId:', requestId);
const requests: any[] = []; const requests: any[] = [];
const deployments: any[] = []; const deployments: any[] = [];
// Querying for removal requests
const removalRequests = await this.queryRecords({ const removalRequests = await this.queryRecords({
type: 'ApplicationDeploymentRemovalRequest', type: 'ApplicationDeploymentRemovalRequest',
}); });
@@ -122,75 +118,53 @@ export class RegHelper {
const request = await this.getRecordById(requestId); const request = await this.getRecordById(requestId);
if (request) { if (request) {
requests.push(request); requests.push(request);
console.log('Found request:', request);
} else {
console.log('Request not found for requestId:', requestId);
} }
deployments.push(...await this.queryRecords({
const foundDeployments = await this.queryRecords({ type: 'ApplicationDeploymentRecord', request: requestId
type: 'ApplicationDeploymentRecord', }));
request: requestId
});
deployments.push(...foundDeployments);
} else { } else {
console.log('Fetching all ApplicationDeploymentRequests'); requests.push(...await this.queryRecords({
const allRequests = await this.queryRecords({
type: 'ApplicationDeploymentRequest', type: 'ApplicationDeploymentRequest',
}); }));
requests.push(...allRequests); deployments.push(...await this.queryRecords({
console.log('All requests:', allRequests);
console.log('Fetching all ApplicationDeploymentRecords');
const allDeployments = await this.queryRecords({
type: 'ApplicationDeploymentRecord', type: 'ApplicationDeploymentRecord',
}); }));
deployments.push(...allDeployments);
console.log('All deployments:', allDeployments);
} }
console.log('Sorting requests by createTime');
requests.sort((a, b) => a.createTime === b.createTime ? 0 : a.createTime > b.createTime ? 1 : -1,); requests.sort((a, b) => a.createTime === b.createTime ? 0 : a.createTime > b.createTime ? 1 : -1,);
requests.reverse(); requests.reverse();
console.log('Sorted requests:', requests);
const deploymentsByRequest = new Map<string, any>(); const deploymentsByRequest = new Map<string, any>();
for (const d of deployments) { for (const d of deployments) {
deploymentsByRequest.set(d.attributes.request, d); deploymentsByRequest.set(d.attributes.request, d);
} }
console.log('Deployments by request:', deploymentsByRequest);
const removalsByRequest = new Map<string, any>(); const removalsByRequest = new Map<string, any>();
for (const rr of removalRequests) { for (const rr of removalRequests) {
if (rr.attributes.request) { if (rr.attributes.request) {
removalsByRequest.set(rr.attributes.request, rr); removalsByRequest.set(rr.attributes.request, rr);
} }
} }
console.log('Removals by request:', removalsByRequest);
const latestByHostname = new Map<string, any>(); const latestByHostname = new Map<string, any>();
const ret = []; const ret = [];
for (const r of requests) { for (const r of requests) {
console.log('Processing request:', r.id);
const status = new RequestStatus(r.id, r.createTime); const status = new RequestStatus(r.id, r.createTime);
ret.push(status); ret.push(status);
const app = await this.getRecord(r.attributes.application); const app = await this.getRecord(r.attributes.application);
if (!app) { if (!app) {
console.log('Error: Application not found for request:', r.id);
status.lastState = 'ERROR'; status.lastState = 'ERROR';
continue; continue;
} }
status.app = r.attributes.application; status.app = r.attributes.application;
const hostname = r.attributes.dns ?? generateHostnameForApp(app); const hostname = r.attributes.dns ?? generateHostnameForApp(app);
console.log('Hostname for app:', hostname);
if (deploymentsByRequest.has(r.id)) { if (deploymentsByRequest.has(r.id)) {
const deployment = deploymentsByRequest.get(r.id); const deployment = deploymentsByRequest.get(r.id);
status.url = deployment.attributes.url; status.url = deployment.attributes.url;
status.lastUpdate = deployment.createTime; status.lastUpdate = deployment.createTime;
console.log('Deployment found for request:', r.id, 'with deployment:', deployment);
if (!latestByHostname.has(hostname)) { if (!latestByHostname.has(hostname)) {
latestByHostname.set(hostname, status); latestByHostname.set(hostname, status);
@@ -205,13 +179,11 @@ export class RegHelper {
} }
if (removalsByRequest.has(r.id)) { if (removalsByRequest.has(r.id)) {
console.log('Removal request found for request:', r.id);
status.lastState = 'CANCELLED'; status.lastState = 'CANCELLED';
continue; continue;
} }
if (latestByHostname.has(hostname)) { if (latestByHostname.has(hostname)) {
console.log('Cancellation found for hostname:', hostname);
status.lastState = 'CANCELLED'; status.lastState = 'CANCELLED';
continue; continue;
} }
@@ -219,7 +191,6 @@ export class RegHelper {
latestByHostname.set(hostname, status); latestByHostname.set(hostname, status);
} }
console.log('Final status array:', ret);
return ret; return ret;
} }