diff --git a/changelog.d/5-internal/remove-sftd-disco b/changelog.d/5-internal/remove-sftd-disco new file mode 100644 index 00000000000..0cbcfdde66a --- /dev/null +++ b/changelog.d/5-internal/remove-sftd-disco @@ -0,0 +1 @@ +remove sftd_disco (now lives in wireapp/wire-avs-service) diff --git a/tools/sftd_disco/Dockerfile b/tools/sftd_disco/Dockerfile deleted file mode 100644 index 011aac9c6a1..00000000000 --- a/tools/sftd_disco/Dockerfile +++ /dev/null @@ -1,7 +0,0 @@ -FROM alpine:3.21.3 - -RUN apk add --no-cache curl bash openssl bind-tools jq - -COPY sftd_disco.sh /usr/bin/sftd_disco.sh - -ENTRYPOINT ["/usr/bin/sftd_disco.sh"] diff --git a/tools/sftd_disco/Makefile b/tools/sftd_disco/Makefile deleted file mode 100644 index 45e71e806c7..00000000000 --- a/tools/sftd_disco/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -.PHONY: docker - -DOCKER_TAG = 1.1.1 - -docker: - docker build -t quay.io/wire/sftd_disco:$(DOCKER_TAG) -f Dockerfile . diff --git a/tools/sftd_disco/README.md b/tools/sftd_disco/README.md deleted file mode 100644 index e78f7679ebe..00000000000 --- a/tools/sftd_disco/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# sftd-disco - -This DISCOvery docker image/bash script converts the result from an SRV DNS lookup of a kubernetes service to a file which can be served by nginx or similar. - -This is useful as a sidecar container to the sftd chart in kubernetes to expose the full list of running sftd servers in cases where sftd runs independently from other backend services. See also [the sftd helm chart](https://github.com/wireapp/wire-server/tree/develop/charts/sftd/) diff --git a/tools/sftd_disco/sftd_disco.sh b/tools/sftd_disco/sftd_disco.sh deleted file mode 100755 index 28e0f5a7ca2..00000000000 --- a/tools/sftd_disco/sftd_disco.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env bash - -set -eo pipefail -exec 2>&1 - -# Assumes /etc/wire/sftd-disco/ directory exists. - -USAGE="example usage: $0 _sft._tcp.wire-server-sftd.wire.svc.cluster.local" -srv_name=${1?$USAGE} - -old="/etc/wire/sftd-disco/sft_servers_all.json" -new="${old}.new" - -function valid_entry() { - # TODO sanity check that this is real dig output - return 0 -} - -function valid_url() { - #TODO basic sanity check - return 0 -} - -# for a given SRV record -# 1. lookup the record -# 2. for each entry: extract host and port and call 'curl host:port/sft/url' -# 4. save the resulting URLs as a json array to a file -# this file can then be served from nginx running besides sft -function upstream() { - name=$1 - entries=$(dig +short +retries=3 +search SRV "${name}" | sort) - unset servers - comma="" - IFS=$'\t\n' - for entry in $entries; do - if valid_entry "$entry"; then - sft_host_port=$(echo "$entry" | awk '{print $4":"$3}') - sft_url=$(curl -s http://"$sft_host_port"/sft/url | xargs) - if valid_url "$sft_url"; then - servers+=("$comma"'"'"$sft_url"'"') - comma="," - fi - fi - done - # shellcheck disable=SC2128 - if [ -n "$servers" ]; then - echo '{"sft_servers_all": ['"${servers[*]}"']}' | jq >${new} - else - printf "" >>${new} - fi -} - -function routing_disco() { - srv_name=$1 - ivl=$(echo | awk '{ srand(); printf("%f", 2.5 + rand() * 1.5) }') - - [[ -f $old ]] || touch -d "1970-01-01" $old - - echo "" >${new} - upstream "$srv_name" - - diff -q $old $new || { - echo upstream change found, replacing $old with $new - mv $new $old - } - - rm -f $new - - echo done, sleeping "$ivl" - sleep "$ivl" -} - -while true; do - routing_disco "$srv_name" -done