Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

feat(helm): add seaweedfs volume limits, expire unsent uploads

Hampusd846d4bb9a10
diff --git a/deploy/helm/fluxer/files/seaweedfs-init.sh b/deploy/helm/fluxer/files/seaweedfs-init.sh
index 4551a91ee..189f69064 100644
--- a/deploy/helm/fluxer/files/seaweedfs-init.sh
+++ b/deploy/helm/fluxer/files/seaweedfs-init.sh
@@ -1,32 +1,46 @@
trap 'exit 0' TERM INT
buckets="$FLUXER_S3_BUCKET_CDN $FLUXER_S3_BUCKET_UPLOADS $FLUXER_S3_BUCKET_REPORTS $FLUXER_S3_BUCKET_HARVESTS"
missing="$buckets"
-for attempt in $(seq 1 "$FLUXER_SEAWEEDFS_INIT_ATTEMPTS"); do
+for _attempt in $(seq 1 "$FLUXER_SEAWEEDFS_INIT_ATTEMPTS"); do
if ! nc -z 127.0.0.1 9333 2>/dev/null; then
sleep 2
continue
fi
listed=$(echo "s3.bucket.list" | timeout 10 weed shell -master=127.0.0.1:9333 2>&1)
missing=""
+ failure=""
for b in $buckets; do
- echo "$listed" | grep -q "^[[:space:]]*$b[[:space:]]" || missing="${missing:+$missing }$b"
+ echo "$listed" | grep -q "^[[:space:]]*${b}[[:space:]]" || missing="${missing:+$missing }$b"
done
if [ -z "$missing" ]; then
- if ! echo "s3.configure -user=fluxer -access_key=$FLUXER_S3_ACCESS_KEY -secret_key=$FLUXER_S3_SECRET_KEY -actions=Admin,Read,Write,List,Tagging -apply" | timeout 10 weed shell -master=127.0.0.1:9333 >/dev/null 2>&1; then
- echo "seaweedfs-init could not configure the S3 identity" >&2
- exit 1
+ if [ "$FLUXER_SEAWEEDFS_UPLOADS_TTL" = off ]; then
+ ttl_rule="fs.configure -locationPrefix=/buckets/$FLUXER_S3_BUCKET_UPLOADS/ -delete -apply"
+ else
+ ttl_rule="fs.configure -locationPrefix=/buckets/$FLUXER_S3_BUCKET_UPLOADS/ -ttl=$FLUXER_SEAWEEDFS_UPLOADS_TTL -apply"
fi
- echo "buckets ready"
- touch /tmp/fluxer-buckets-ready
- while :; do
- sleep 86400 &
- wait $!
- done
+ failure="could not configure the S3 identity"
+ if echo "s3.configure -user=fluxer -access_key=$FLUXER_S3_ACCESS_KEY -secret_key=$FLUXER_S3_SECRET_KEY -actions=Admin,Read,Write,List,Tagging -apply" | timeout 10 weed shell -master=127.0.0.1:9333 >/dev/null 2>&1; then
+ failure="could not set the expiry of $FLUXER_S3_BUCKET_UPLOADS"
+ if echo "$ttl_rule" | timeout 10 weed shell -master=127.0.0.1:9333 >/dev/null 2>&1; then
+ echo "buckets ready"
+ touch /tmp/fluxer-buckets-ready
+ while :; do
+ sleep 86400 &
+ wait $!
+ done
+ fi
+ fi
+ sleep 2
+ continue
fi
for b in $missing; do
echo "s3.bucket.create -name $b" | timeout 10 weed shell -master=127.0.0.1:9333 >/dev/null 2>&1
done
sleep 2
done
-echo "seaweedfs-init could not verify buckets: $missing" >&2
+if [ -n "$failure" ]; then
+ echo "seaweedfs-init $failure" >&2
+else
+ echo "seaweedfs-init could not verify buckets: $missing" >&2
+fi
exit 1
diff --git a/deploy/helm/fluxer/templates/seaweedfs.yaml b/deploy/helm/fluxer/templates/seaweedfs.yaml
index 20d54011b..e9e3d0fbf 100644
--- a/deploy/helm/fluxer/templates/seaweedfs.yaml
+++ b/deploy/helm/fluxer/templates/seaweedfs.yaml
@@ -4,7 +4,7 @@
{{- $ctx := dict "root" $ "name" "seaweedfs" "component" "storage" "w" . }}
{{- $healthz := dict "path" "/healthz" "port" "s3" }}
{{- $secrets := include "fluxer.secretData" $ | fromJson }}
-{{- $init := $.Files.Get "files/seaweedfs-init.sh" }}
+{{- $init := $.Files.Get "files/seaweedfs-init.sh" | replace "\r" "" }}
---
apiVersion: v1
kind: Service
@@ -62,6 +62,8 @@ spec:
- -s3
- -dir=/data
- -master.telemetry=false
+ - -master.volumeSizeLimitMB={{ include "fluxer.string" .volumeSizeLimitMB }}
+ - -volume.max={{ include "fluxer.string" .volumeMax }}
- -ip=127.0.0.1
- -ip.bind=127.0.0.1
- -s3.ip.bind=0.0.0.0
@@ -117,6 +119,8 @@ spec:
value: {{ $.Values.s3.buckets.harvests | quote }}
- name: FLUXER_SEAWEEDFS_INIT_ATTEMPTS
value: {{ include "fluxer.string" .initAttempts | quote }}
+ - name: FLUXER_SEAWEEDFS_UPLOADS_TTL
+ value: {{ ternary "off" .uploadsTtl (kindIs "bool" .uploadsTtl) | quote }}
readinessProbe:
exec:
command: ["test", "-f", "/tmp/fluxer-buckets-ready"]
diff --git a/deploy/helm/fluxer/values.schema.json b/deploy/helm/fluxer/values.schema.json
index c929229f5..8ed6b3a97 100644
--- a/deploy/helm/fluxer/values.schema.json
+++ b/deploy/helm/fluxer/values.schema.json
@@ -554,6 +554,25 @@
"type": "integer",
"minimum": 1
},
+ "volumeSizeLimitMB": {
+ "type": "integer",
+ "minimum": 1
+ },
+ "volumeMax": {
+ "type": "integer",
+ "minimum": 0
+ },
+ "uploadsTtl": {
+ "anyOf": [
+ {
+ "type": "string",
+ "pattern": "^(off|([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])[mhdwMy])$"
+ },
+ {
+ "const": false
+ }
+ ]
+ },
"gomemlimit": {
"type": "string"
},
diff --git a/deploy/helm/fluxer/values.yaml b/deploy/helm/fluxer/values.yaml
index 0c03c66e9..1037138c3 100644
--- a/deploy/helm/fluxer/values.yaml
+++ b/deploy/helm/fluxer/values.yaml
@@ -318,6 +318,15 @@ seaweedfs:
pullPolicy: IfNotPresent
# Volumes grown per bucket. 1 keeps the store usable on small disks.
volumeGrowth: 1
+ # Size in MB at which SeaweedFS stops writing to a volume and opens another.
+ volumeSizeLimitMB: 1024
+ # Most volumes SeaweedFS may hold. It creates one only when a bucket needs
+ # room, so a high count reserves no disk. 0 derives the count from the free
+ # disk, which leaves a small volume with fewer than the four buckets need.
+ volumeMax: 10000
+ # How long a file stays in the uploads bucket. A file moves out when its
+ # message is sent, so this removes uploads nobody sent. off removes the rule.
+ uploadsTtl: 1d
gomemlimit: 1536MiB
# Tries, 2 seconds apart, the bucket setup makes before it starts over.
initAttempts: 60