|
37 | 37 | # preloaded, or use existing imagePullSecrets. |
38 | 38 | # REGISTRY_PULL_USERNAME Username for generated pull secrets. |
39 | 39 | # Default: $oauthtoken |
40 | | -# NICO_SITE_UUID Stable REST site UUID. Used only when REST is |
41 | | -# deployed. Default is a dev placeholder. |
| 40 | +# NICO_SITE_UUID REST site UUID. Used only when REST is deployed. |
| 41 | +# If unset, setup generates a random UUID each run. |
42 | 42 | # NICO_MANAGE_DEFAULT_STORAGE_CLASS |
43 | 43 | # Whether setup annotates local-path as the default |
44 | 44 | # StorageClass. Default: true. |
@@ -629,13 +629,82 @@ _TEMPORAL_TLS="--tls-cert-path /var/secrets/temporal/certs/server-interservice/t |
629 | 629 | --tls-key-path /var/secrets/temporal/certs/server-interservice/tls.key \ |
630 | 630 | --tls-ca-path /var/secrets/temporal/certs/server-interservice/ca.crt \ |
631 | 631 | --tls-server-name interservice.server.temporal.local" |
632 | | -kubectl exec -n temporal deploy/temporal-admintools -- \ |
633 | | - sh -c "temporal operator namespace create -n cloud --address ${_TEMPORAL_ADDR} ${_TEMPORAL_TLS}" 2>/dev/null || true |
634 | | -kubectl exec -n temporal deploy/temporal-admintools -- \ |
635 | | - sh -c "temporal operator namespace create -n site --address ${_TEMPORAL_ADDR} ${_TEMPORAL_TLS}" 2>/dev/null || true |
| 632 | +_wait_for_temporal() { |
| 633 | + local _output="" |
| 634 | + |
| 635 | + echo "Waiting for Temporal frontend and admin tools..." |
| 636 | + kubectl rollout status deploy/temporal-frontend -n temporal --timeout=120s |
| 637 | + kubectl rollout status deploy/temporal-admintools -n temporal --timeout=120s |
| 638 | + |
| 639 | + for _i in $(seq 1 24); do |
| 640 | + if _output="$(kubectl exec -n temporal deploy/temporal-admintools -- \ |
| 641 | + sh -c "temporal operator namespace list --address ${_TEMPORAL_ADDR} ${_TEMPORAL_TLS}" 2>&1)"; then |
| 642 | + echo "Temporal frontend ready" |
| 643 | + return |
| 644 | + fi |
| 645 | + echo " Waiting for Temporal API (${_i}/24)..." |
| 646 | + sleep 5 |
| 647 | + done |
| 648 | + |
| 649 | + echo "ERROR: Temporal frontend is not ready for namespace operations" >&2 |
| 650 | + echo "${_output}" >&2 |
| 651 | + exit 1 |
| 652 | +} |
| 653 | + |
| 654 | +_create_temporal_namespace() { |
| 655 | + local _namespace="$1" |
| 656 | + local _output |
| 657 | + |
| 658 | + if _output="$(kubectl exec -n temporal deploy/temporal-admintools -- \ |
| 659 | + sh -c "temporal operator namespace create -n \"\$1\" --address ${_TEMPORAL_ADDR} ${_TEMPORAL_TLS}" \ |
| 660 | + sh "${_namespace}" 2>&1)"; then |
| 661 | + echo "Temporal namespace ${_namespace} ready" |
| 662 | + return |
| 663 | + fi |
| 664 | + |
| 665 | + if printf "%s" "${_output}" | grep -qi "already exists"; then |
| 666 | + echo "Temporal namespace ${_namespace} already exists" |
| 667 | + return |
| 668 | + fi |
| 669 | + |
| 670 | + echo "ERROR: failed to create Temporal namespace ${_namespace}" >&2 |
| 671 | + echo "${_output}" >&2 |
| 672 | + exit 1 |
| 673 | +} |
| 674 | + |
| 675 | +_verify_temporal_namespaces() { |
| 676 | + local _output |
| 677 | + local _missing=() |
| 678 | + local _namespace |
| 679 | + |
| 680 | + if ! _output="$(kubectl exec -n temporal deploy/temporal-admintools -- \ |
| 681 | + sh -c "temporal operator namespace list --address ${_TEMPORAL_ADDR} ${_TEMPORAL_TLS}" 2>&1)"; then |
| 682 | + echo "ERROR: failed to list Temporal namespaces" >&2 |
| 683 | + echo "${_output}" >&2 |
| 684 | + exit 1 |
| 685 | + fi |
| 686 | + |
| 687 | + for _namespace in "$@"; do |
| 688 | + if ! printf "%s" "${_output}" | grep -Eq "(^|[^[:alnum:]_-])${_namespace}([^[:alnum:]_-]|$)"; then |
| 689 | + _missing+=("${_namespace}") |
| 690 | + fi |
| 691 | + done |
| 692 | + |
| 693 | + if [[ ${#_missing[@]} -gt 0 ]]; then |
| 694 | + echo "ERROR: missing Temporal namespace(s): ${_missing[*]}" >&2 |
| 695 | + echo "${_output}" >&2 |
| 696 | + exit 1 |
| 697 | + fi |
| 698 | + |
| 699 | + echo "Verified Temporal namespaces: $*" |
| 700 | +} |
| 701 | + |
| 702 | +_wait_for_temporal |
| 703 | +_create_temporal_namespace cloud |
| 704 | +_create_temporal_namespace site |
636 | 705 | # flow Temporal namespace — required by NICo Flow workers; pod panics on startup if absent. |
637 | | -kubectl exec -n temporal deploy/temporal-admintools -- \ |
638 | | - sh -c "temporal operator namespace create -n flow --address ${_TEMPORAL_ADDR} ${_TEMPORAL_TLS}" 2>/dev/null || true |
| 706 | +_create_temporal_namespace flow |
| 707 | +_verify_temporal_namespaces cloud site flow |
639 | 708 | echo "Temporal namespaces ready" |
640 | 709 |
|
641 | 710 | _SETUP_PHASE="[7g/7] NICo REST helm chart" |
|
710 | 779 | # All of this is wired via --set flags so nico-rest.yaml stays registry-agnostic. |
711 | 780 | NICO_SITE_AGENT_CHART="${NICO_REST_HELM_DIR}/nico-rest-site-agent" |
712 | 781 |
|
713 | | -# Stable placeholder UUID for this site (must be a valid UUID). |
714 | | -NICO_SITE_UUID="${NICO_SITE_UUID:-a1b2c3d4-e5f6-4000-8000-000000000001}" |
| 782 | +if [[ -z "${NICO_SITE_UUID:-}" ]]; then |
| 783 | + if ! command -v python3 &>/dev/null; then |
| 784 | + echo "ERROR: NICO_SITE_UUID is unset and python3 is not available" >&2 |
| 785 | + exit 1 |
| 786 | + fi |
| 787 | + NICO_SITE_UUID="$(python3 -c 'import uuid; print(uuid.uuid4())')" |
| 788 | +fi |
715 | 789 |
|
716 | 790 | NICO_SITE_AGENT_ARGS=( |
717 | 791 | --namespace nico-rest |
@@ -762,8 +836,8 @@ _TEMPORAL_TLS="--tls-cert-path /var/secrets/temporal/certs/server-interservice/t |
762 | 836 | --tls-key-path /var/secrets/temporal/certs/server-interservice/tls.key \ |
763 | 837 | --tls-ca-path /var/secrets/temporal/certs/server-interservice/ca.crt \ |
764 | 838 | --tls-server-name interservice.server.temporal.local" |
765 | | -kubectl exec -n temporal deploy/temporal-admintools -- \ |
766 | | - sh -c "temporal operator namespace create -n '${NICO_SITE_UUID}' --address ${_TEMPORAL_ADDR} ${_TEMPORAL_TLS}" 2>/dev/null || true |
| 839 | +_create_temporal_namespace "${NICO_SITE_UUID}" |
| 840 | +_verify_temporal_namespaces "${NICO_SITE_UUID}" |
767 | 841 | echo "Temporal namespace ready" |
768 | 842 |
|
769 | 843 | # FLOW_GRPC_ENABLED toggles the site-agent's Flow gRPC client (see |
|
0 commit comments