forked from longtao.wu/droboticflow
🐛 Fix POC external workflow acceptance
This commit is contained in:
parent
50228948ef
commit
caba43a964
@ -333,6 +333,7 @@ func configurePocOperatorHyperparams(operator domain.OperatorRecord, fixtures po
|
||||
items = setHyperparam(items, "INCLUDE_PARQUET", "false")
|
||||
items = setHyperparam(items, "INCLUDE_STATISTICS", "false")
|
||||
case "builtin_bos_incremental_scan":
|
||||
items = setHyperparam(items, "DATA_SOURCE", "BOS")
|
||||
items = setHyperparam(items, "SCAN_MODE", "INCREMENTAL")
|
||||
items = setHyperparam(items, "INCREMENTAL_UNIT", "DIRECTORY")
|
||||
case "builtin_graspnet_dataset_validate":
|
||||
@ -995,7 +996,10 @@ func (server *server) firstPocOperatorAcceptanceStorageConnection(ctx context.Co
|
||||
}
|
||||
for index := range connections {
|
||||
item := connections[index]
|
||||
if item.Provider == domain.StorageProviderBOS && strings.TrimSpace(item.AccessKeyID) != "" && strings.TrimSpace(item.SecretAccessKey) != "" {
|
||||
if item.Provider == domain.StorageProviderBOS &&
|
||||
strings.TrimSpace(item.Bucket) != "" &&
|
||||
strings.TrimSpace(item.AccessKeyID) != "" &&
|
||||
strings.TrimSpace(item.SecretAccessKey) != "" {
|
||||
return &item, nil
|
||||
}
|
||||
}
|
||||
@ -1073,6 +1077,13 @@ func (server *server) handlePocOperatorWorkflowAcceptance(writer http.ResponseWr
|
||||
return
|
||||
}
|
||||
grouped := groupPocOperatorAcceptanceBatches(operators)
|
||||
if len(grouped["外部存储与审计链路"]) > 0 && storageConnection == nil {
|
||||
renderValidationError(writer, validationIssue{
|
||||
Field: "storageConnection",
|
||||
Message: "external storage acceptance requires a BOS storage connection with endpoint, bucket, access key, and secret key",
|
||||
})
|
||||
return
|
||||
}
|
||||
batchNames := make([]string, 0, len(grouped))
|
||||
for name := range grouped {
|
||||
batchNames = append(batchNames, name)
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"droboticflow/internal/domain"
|
||||
"droboticflow/internal/store"
|
||||
)
|
||||
|
||||
func TestConfigurePocOperatorHyperparamsRoutesSegmentationFixture(t *testing.T) {
|
||||
@ -365,6 +367,43 @@ func TestWorkflowNodeFromOperatorScopesBOSScanToAcceptancePrefix(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFirstPocOperatorAcceptanceStorageConnectionRequiresBucket(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
dataStore := store.NewMemoryStore()
|
||||
server := &server{store: dataStore}
|
||||
|
||||
if _, err := dataStore.CreateStorageConnection(ctx, domain.CreateStorageConnectionInput{
|
||||
OrganizationID: "org-1",
|
||||
Name: "bucketless",
|
||||
Provider: domain.StorageProviderBOS,
|
||||
Endpoint: "https://bj.bcebos.com",
|
||||
AccessKeyID: "ak-bucketless",
|
||||
SecretAccessKey: "sk-bucketless",
|
||||
}); err != nil {
|
||||
t.Fatalf("create bucketless storage connection: %v", err)
|
||||
}
|
||||
expected, err := dataStore.CreateStorageConnection(ctx, domain.CreateStorageConnectionInput{
|
||||
OrganizationID: "org-1",
|
||||
Name: "workspace",
|
||||
Provider: domain.StorageProviderBOS,
|
||||
Endpoint: "https://bj.bcebos.com",
|
||||
Bucket: "testxyz",
|
||||
AccessKeyID: "ak-workspace",
|
||||
SecretAccessKey: "sk-workspace",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("create workspace storage connection: %v", err)
|
||||
}
|
||||
|
||||
connection, err := server.firstPocOperatorAcceptanceStorageConnection(ctx, "org-1")
|
||||
if err != nil {
|
||||
t.Fatalf("firstPocOperatorAcceptanceStorageConnection: %v", err)
|
||||
}
|
||||
if connection == nil || connection.ID != expected.ID {
|
||||
t.Fatalf("connection = %#v, want %#v", connection, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWorkflowNodeFromOperatorCopiesDefaultGPUResources(t *testing.T) {
|
||||
fixtures := pocOperatorAcceptanceFixturePathsFromManifest("/workspace/fixtures/poc-operator-acceptance/poc-operator-acceptance.json")
|
||||
node := workflowNodeFromOperator(domain.OperatorRecord{
|
||||
|
||||
@ -131,15 +131,6 @@ worker_curl() {
|
||||
curl --retry 3 --retry-delay 1 --retry-connrefused --retry-all-errors -fsS "$@"
|
||||
}
|
||||
|
||||
trigger_worker_process_once() {
|
||||
local output
|
||||
if output="$(worker_curl --max-time 60 -X POST "$WORKER_LOCAL_BASE_URL/worker-api/process-once" 2>&1)"; then
|
||||
return 0
|
||||
fi
|
||||
printf 'warning: worker process-once did not return cleanly; continuing with run-state polling: %s\n' "$output" >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
free_local_port() {
|
||||
python3 - <<'PY'
|
||||
import socket
|
||||
@ -153,17 +144,27 @@ PORT_FORWARD_PID=""
|
||||
PORT_FORWARD_LOG="$(mktemp)"
|
||||
RUNS_JSON_FILE="$(mktemp)"
|
||||
COOKIE_JAR="$(mktemp)"
|
||||
cleanup() {
|
||||
WORKER_LOCAL_BASE_URL=""
|
||||
|
||||
stop_worker_port_forward() {
|
||||
if [[ -n "$PORT_FORWARD_PID" ]] && kill -0 "$PORT_FORWARD_PID" >/dev/null 2>&1; then
|
||||
kill "$PORT_FORWARD_PID" >/dev/null 2>&1 || true
|
||||
wait "$PORT_FORWARD_PID" >/dev/null 2>&1 || true
|
||||
fi
|
||||
PORT_FORWARD_PID=""
|
||||
WORKER_LOCAL_BASE_URL=""
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
stop_worker_port_forward
|
||||
rm -f "$PORT_FORWARD_LOG" "$RUNS_JSON_FILE" "$COOKIE_JAR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
start_worker_port_forward() {
|
||||
local local_port
|
||||
stop_worker_port_forward
|
||||
: >"$PORT_FORWARD_LOG"
|
||||
local_port="$(free_local_port)"
|
||||
kubectl -n "$K8S_NAMESPACE" port-forward "service/${WORKER_SERVICE_NAME}" "${local_port}:${WORKER_SERVICE_PORT}" >"$PORT_FORWARD_LOG" 2>&1 &
|
||||
PORT_FORWARD_PID="$!"
|
||||
@ -186,6 +187,31 @@ start_worker_port_forward() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
ensure_worker_port_forward() {
|
||||
if [[ -n "$PORT_FORWARD_PID" && -n "$WORKER_LOCAL_BASE_URL" ]] && kill -0 "$PORT_FORWARD_PID" >/dev/null 2>&1; then
|
||||
if worker_curl --max-time 5 "$WORKER_LOCAL_BASE_URL/worker-api/health" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
printf 'warning: worker port-forward health check failed; restarting port-forward.\n' >&2
|
||||
fi
|
||||
start_worker_port_forward
|
||||
}
|
||||
|
||||
trigger_worker_process_once() {
|
||||
local output
|
||||
ensure_worker_port_forward
|
||||
if output="$(worker_curl --max-time 60 -X POST "$WORKER_LOCAL_BASE_URL/worker-api/process-once" 2>&1)"; then
|
||||
return 0
|
||||
fi
|
||||
printf 'warning: worker process-once did not return cleanly; restarting port-forward and retrying once: %s\n' "$output" >&2
|
||||
start_worker_port_forward
|
||||
if output="$(worker_curl --max-time 60 -X POST "$WORKER_LOCAL_BASE_URL/worker-api/process-once" 2>&1)"; then
|
||||
return 0
|
||||
fi
|
||||
printf 'warning: worker process-once retry did not return cleanly; continuing with run-state polling: %s\n' "$output" >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
api_health="$(api_curl "$API_BASE_URL/api/health")"
|
||||
printf 'api health: %s\n' "$api_health"
|
||||
printf '%s' "$api_health" | grep -q '"status":"ok"'
|
||||
|
||||
@ -7,6 +7,7 @@ source "$ROOT_DIR/scripts/lib/service-endpoints.sh"
|
||||
API_BASE_URL="$(droboticflow_first_service_url "${1:-}" "${API_BASE_URL:-}" "${BASE_URL:-}" "$(droboticflow_default_api_base_url)")"
|
||||
K8S_ENDPOINT="${K8S_ENDPOINT:-}"
|
||||
K8S_NAMESPACE="${K8S_NAMESPACE:-droboticflow}"
|
||||
WORKSPACE_PVC_NAME="${WORKSPACE_PVC_NAME:-droboticflow-workspace}"
|
||||
OPERATOR_RUNNER_IMAGE="${OPERATOR_RUNNER_IMAGE:-}"
|
||||
K8S_IMAGE_PULL_SECRET_NAME="${K8S_IMAGE_PULL_SECRET_NAME:-droboticflow-registry}"
|
||||
REGISTRY_AUTH_TEMP_FILE=""
|
||||
@ -38,8 +39,29 @@ secret_value() {
|
||||
fi
|
||||
}
|
||||
|
||||
infer_workspace_bucket() {
|
||||
if [[ -n "${POC_ACCEPTANCE_BOS_BUCKET:-}" ]]; then
|
||||
printf '%s\n' "$POC_ACCEPTANCE_BOS_BUCKET"
|
||||
return 0
|
||||
fi
|
||||
if [[ -n "${BOS_BUCKET:-}" ]]; then
|
||||
printf '%s\n' "$BOS_BUCKET"
|
||||
return 0
|
||||
fi
|
||||
if [[ -n "${WORKSPACE_BOS_BUCKET:-}" ]]; then
|
||||
printf '%s\n' "$WORKSPACE_BOS_BUCKET"
|
||||
return 0
|
||||
fi
|
||||
local pv_name
|
||||
pv_name="$(kubectl -n "$K8S_NAMESPACE" get pvc "$WORKSPACE_PVC_NAME" -o jsonpath='{.spec.volumeName}' 2>/dev/null || true)"
|
||||
if [[ -z "$pv_name" ]]; then
|
||||
return 0
|
||||
fi
|
||||
kubectl get pv "$pv_name" -o jsonpath='{.spec.csi.volumeHandle}' 2>/dev/null || true
|
||||
}
|
||||
|
||||
export RECONCILE_BOS_ENDPOINT="${RECONCILE_BOS_ENDPOINT:-$(config_value BOS_ENDPOINT)}"
|
||||
export RECONCILE_BOS_BUCKET="${RECONCILE_BOS_BUCKET:-${POC_ACCEPTANCE_BOS_BUCKET:-${BOS_BUCKET:-}}}"
|
||||
export RECONCILE_BOS_BUCKET="${RECONCILE_BOS_BUCKET:-$(infer_workspace_bucket)}"
|
||||
export RECONCILE_BOS_ACCESS_KEY_ID="${RECONCILE_BOS_ACCESS_KEY_ID:-$(secret_value droboticflow-bos-workspace accessKeyId)}"
|
||||
if [[ -z "$RECONCILE_BOS_ACCESS_KEY_ID" ]]; then
|
||||
export RECONCILE_BOS_ACCESS_KEY_ID="$(secret_value droboticflow-bos-workspace ak)"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user