Files
Yiling-J 176b7f0eab feat(workflow): migrate workflow engine from temporal to dbos (#481)
* feat(workflow): migrate workflow engine from temporal to dbos

Replace Temporal and LocalExecutor with DBOS Transact (@dbos-inc/dbos-sdk) as the unified workflow engine. Background tasks, media transcoding, and AI agent workflows now execute with durable steps and task queues directly against PostgreSQL, eliminating the need for an external Temporal cluster and separate polling executors.

* fix(workflow): submit tasks via DBOSClient to allow enqueueing from steps

Enqueuing workflows using DBOS.enqueueWorkflowWithOptions threw a
DBOSInvalidWorkflowTransitionError when triggered from within a running
step or activity (e.g. creating embedding or autofill tasks during
video transcoding).

Use DBOSClient to submit and cancel workflow tasks directly against the
system database, detaching execution from the ambient workflow/step
context.

* feat(web): support SHUMAI_WORKERS environment variable

* fix(workflow): ensure CLI tasks are enqueued to DBOS and run DBOS migrations in global setup

- Initialize workflows and wait for pending DBOS submissions in shumai regenerate-embeddings CLI
- Remove no-op submit bypass and enqueue tasks via DBOSClient in producer and CLI contexts
- Add DBOS migration runner in test global setup to avoid concurrent migration deadlocks across test forks
- Update changelog and add regression tests

* fix(workflow): ensure unique per-instance executor identity for worker replicas

- Derive unique per-instance DBOS executor IDs across worker replicas

- Support SHUMAI_WORKER_ID, DBOS__VMID, and POD_NAME (Kubernetes Downward API)

- Disambiguate multi-replica bare metal/container deployments with host, PID, and instance suffix

- Prevent startup recovery from re-enqueueing workflows actively executed by other live workers

- Add multi-instance startup recovery tests and update deployment documentation

* fix(workflow): only register listened queues and update concurrency on change

- Only register queues that the executor instance actively listens to

- Use always_update conflict resolution so environment variable changes take effect on restart

- Prevent dedicated workers from overwriting unmanaged queue concurrency configurations

- Add tests verifying concurrency updates and queue isolation across worker roles

* refactor(workflow): simplify activities to use defineStep and direct calls (#482)

* refactor(workflow): simplify activities to use defineStep and direct calls

- Wrap activities using defineStep from @shumai/workflow-core
- Remove obsolete getActivities, registerActivities, dynamic activity proxies, and workerQueue arguments
- Remove executor.ts and registry.ts, consolidating workflow registration into workflow.ts
- Call activities directly across transcode and agent workflows
- Update all corresponding workflow tests and developer guide documentation

* fix(workflow): properly detect DBOSWorkflowCancelledError in runOnCancel fallback

- DBOSWorkflowCancelledError in DBOS SDK does not set name, inheriting 'Error'
- Implement isDbosWorkflowCancelledError checking instanceof, constructor.name, and dbosErrorCode
- Update unit tests to verify real DBOS SDK cancellation error instances

* docs(workflow): update documentation and readme for dbos migration

- Rename docs/configuration/temporal.mdx to docs/configuration/distributed.mdx
- Document DBOS-based distributed worker architecture and task queues
- Remove obsolete docker-compose/temporal/
- Update environment variables documentation in docs/configuration/env-variables.mdx
- Update references in README.md, README_CN.md, docs/docs.json, and related guides

* feat(deploy): implement KEDA ScaledJob and scale-to-zero On-Demand transcoding (#483)

* feat(deploy): add shumai-transcode docker image and k8s autoscaling example with garage s3

* docs(k8s): document port-forwarding and in-cluster s3 domain mapping

* feat(storage): support public s3 endpoint for browser uploads and update k8s example

* fix(k8s): configure s3 bucket cors rules in garage initialization

* fix(k8s): increase transcode worker memory limit to 4Gi for 4K video encoding

* feat(deploy): add AWS EKS deployment with Graviton3 Spot nodegroups and autoscaling

* docs(deploy): redesign EKS documentation, rename k8s to eks, and add scalable deployment feature

* docs: rephrase DBOS feature bullet to Durable Workflows via DBOS

* docs(eks): upgrade default instances to Graviton5 c9g.large and c9g.xlarge

* feat(eks): use On-Demand for general nodegroup and add spot capacity diversification

* docs(eks): fix Architecture diagram to locate all transcode worker pods in Transcode Compute Pool

* feat(deploy): implement KEDA ScaledJob and scale-to-zero On-Demand transcoding

* feat(transcode): support idle-timeout auto-drain for KEDA scaled jobs

* fix(deploy): fix EKS deployment manifests and documentation based on cluster verification
2026-10-19 15:35:08 +08:00

239 lines
7.7 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: garage-config
namespace: shumai
data:
garage.toml: |
metadata_dir = "/var/lib/garage/meta"
data_dir = "/var/lib/garage/data"
db_engine = "sqlite"
replication_factor = 1
rpc_bind_addr = "0.0.0.0:3901"
rpc_secret = "c7d7e35b7501a91e5cfb3874026315579930f367fa3b7e4a1e94cf67484a86cf"
[s3_api]
s3_region = "garage"
api_bind_addr = "0.0.0.0:3900"
root_domain = ".s3.garage"
[admin]
api_bind_addr = "0.0.0.0:3903"
admin_token = "admin-secret-token"
---
apiVersion: v1
kind: Service
metadata:
name: garage
namespace: shumai
labels:
app: garage
spec:
ports:
- port: 3900
name: s3-api
- port: 3901
name: rpc
- port: 3903
name: admin
selector:
app: garage
---
apiVersion: v1
kind: Service
metadata:
name: garage-public
namespace: shumai
labels:
app: garage
spec:
type: LoadBalancer
ports:
- port: 3900
targetPort: 3900
name: s3-api
selector:
app: garage
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: garage
namespace: shumai
spec:
serviceName: garage
replicas: 1
selector:
matchLabels:
app: garage
template:
metadata:
labels:
app: garage
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: eks.amazonaws.com/nodegroup
operator: In
values:
- shumai-general
- shumai-general-spot
- matchExpressions:
- key: workload
operator: In
values:
- general
containers:
- name: garage
image: dxflrs/garage:v2.4.1
imagePullPolicy: IfNotPresent
command: ['/garage', 'server']
ports:
- containerPort: 3900
name: s3-api
- containerPort: 3901
name: rpc
- containerPort: 3903
name: admin
volumeMounts:
- name: config
mountPath: /etc/garage.toml
subPath: garage.toml
- name: garage-meta
mountPath: /var/lib/garage/meta
- name: garage-data
mountPath: /var/lib/garage/data
volumes:
- name: config
configMap:
name: garage-config
volumeClaimTemplates:
- metadata:
name: garage-meta
spec:
accessModes: ['ReadWriteOnce']
resources:
requests:
storage: 1Gi
- metadata:
name: garage-data
spec:
accessModes: ['ReadWriteOnce']
resources:
requests:
storage: 10Gi
---
apiVersion: batch/v1
kind: Job
metadata:
name: garage-init
namespace: shumai
spec:
backoffLimit: 10
template:
metadata:
labels:
app: garage-init
spec:
restartPolicy: OnFailure
containers:
- name: init
image: alpine:3.20
env:
- name: S3_BUCKET
valueFrom:
configMapKeyRef:
name: shumai-config
key: S3_BUCKET
- name: S3_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: shumai-secret
key: S3_ACCESS_KEY_ID
- name: S3_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: shumai-secret
key: S3_SECRET_ACCESS_KEY
- name: GARAGE_ADMIN_TOKEN
valueFrom:
secretKeyRef:
name: shumai-secret
key: GARAGE_ADMIN_TOKEN
command:
- /bin/sh
- -c
- |
set -e
apk add --no-cache curl jq aws-cli >/dev/null 2>&1
echo "Waiting for Garage Admin API to respond..."
until curl -s -f -H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" http://garage:3903/v2/GetClusterStatus >/dev/null 2>&1; do
sleep 2
done
echo "Garage Admin API is online. Retrieving cluster status..."
STATUS=$(curl -s -H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" http://garage:3903/v2/GetClusterStatus)
NODE_ID=$(echo "$STATUS" | jq -r '.nodes[0].id // empty')
if [ -z "$NODE_ID" ]; then
echo "Error: Node ID not found"
exit 1
fi
echo "Discovered Node ID: $NODE_ID"
ROLE=$(echo "$STATUS" | jq -r '.nodes[0].role // empty')
if [ -z "$ROLE" ] || [ "$ROLE" = "null" ]; then
echo "Assigning layout role to node..."
curl -s -f -X POST http://garage:3903/v2/UpdateClusterLayout \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"roles\": [{\"id\": \"$NODE_ID\", \"zone\": \"dc1\", \"capacity\": 10737418240, \"tags\": []}]}" >/dev/null
echo "Applying cluster layout (version 1)..."
curl -s -f -X POST http://garage:3903/v2/ApplyClusterLayout \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"version": 1}' >/dev/null || true
fi
echo "Importing S3 Access Key..."
curl -s -f -X POST http://garage:3903/v2/ImportKey \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"name\": \"shumai-key\", \"accessKeyId\": \"${S3_ACCESS_KEY_ID}\", \"secretAccessKey\": \"${S3_SECRET_ACCESS_KEY}\"}" >/dev/null || true
echo "Creating S3 bucket '${S3_BUCKET}'..."
BUCKET_RESP=$(curl -s -X POST http://garage:3903/v2/CreateBucket \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"globalAlias\": \"${S3_BUCKET}\"}")
echo "$BUCKET_RESP"
BUCKET_ID=$(echo "$BUCKET_RESP" | jq -r '.id // empty')
if [ -z "$BUCKET_ID" ]; then
# Fetch existing bucket ID if already created
BUCKET_ID=$(curl -s -H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" "http://garage:3903/v2/GetBucketInfo?globalAlias=${S3_BUCKET}" | jq -r '.id // empty')
fi
if [ -n "$BUCKET_ID" ]; then
echo "Granting bucket permissions for key on bucket ID $BUCKET_ID..."
curl -s -f -X POST http://garage:3903/v2/AllowBucketKey \
-H "Authorization: Bearer ${GARAGE_ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"bucketId\": \"${BUCKET_ID}\", \"accessKeyId\": \"${S3_ACCESS_KEY_ID}\", \"permissions\": {\"read\": true, \"write\": true, \"owner\": true}}" >/dev/null || true
fi
echo "Configuring S3 bucket CORS for web uploads..."
AWS_ACCESS_KEY_ID=${S3_ACCESS_KEY_ID} \
AWS_SECRET_ACCESS_KEY=${S3_SECRET_ACCESS_KEY} \
AWS_DEFAULT_REGION=garage \
aws --endpoint-url http://garage:3900 s3api put-bucket-cors \
--bucket "${S3_BUCKET}" \
--cors-configuration '{"CORSRules":[{"AllowedHeaders":["*"],"AllowedMethods":["GET","PUT","POST","DELETE","HEAD"],"AllowedOrigins":["*"],"ExposeHeaders":["ETag"],"MaxAgeSeconds":3000}]}' || true
echo "✅ Garage S3 storage cluster initialized successfully!"