Commit 9bfa4036 authored by Andrea Sgambelluri's avatar Andrea Sgambelluri
Browse files

minor corrections on the alarm trigger from the optical controller

parent 18e17669
Loading
Loading
Loading
Loading

redeploy.sh

0 → 100755
+69 −0
Changes for redeploy.sh: 69 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/bin/bash
# Rebuild, push, and redeploy one or more TFS components to the running
# microk8s cluster -- a thin wrapper around deploy/component.sh that can be
# called from any directory and prints a quick post-deploy pod/log check.
#
# Usage:
#   ./redeploy.sh <component> [<component> ...]
#
# Examples:
#   ./redeploy.sh opticalcontroller
#   ./redeploy.sh service webui
#   ./redeploy.sh policy
#
# Run with no arguments to see the component names this demo normally uses
# (see src/tests/ecoc26_pluggables/ecoc26_deploy.sh).

set -eu

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$REPO_ROOT"

KNOWN_COMPONENTS="context device pathcomp opticalcontroller service nbi webui policy kpi_manager telemetry analytics automation pluggables"

if [[ $# -eq 0 ]]; then
    echo "Usage: $0 <component> [<component> ...]"
    echo
    echo "Components normally used by this demo:"
    echo "  ${KNOWN_COMPONENTS}"
    exit 1
fi

echo "Sourcing my_deploy.sh for registry/tag/namespace defaults..."
if ! source my_deploy.sh >/tmp/redeploy_my_deploy.log 2>&1; then
    echo "Failed to source my_deploy.sh -- see /tmp/redeploy_my_deploy.log"
    exit 1
fi

echo "Redeploying: $*"
./deploy/component.sh "$*"

echo
echo "── Post-deploy pod check ──────────────────────────────────────────────"
# Best-effort only from here on -- a transient microk8s API hiccup here must
# never be reported as a redeploy failure, since deploy/component.sh above
# already succeeded (set -e would have stopped this script otherwise).
set +e
sleep 3
for COMPONENT in "$@"; do
    # TFS deployment/pod names are "<component>service" with underscores
    # flattened to hyphens (e.g. kpi_manager -> kpi-managerservice) -- this
    # is a best-effort match, not authoritative. Excludes any pod with a
    # deletionTimestamp set: right after a redeploy the old pod is often
    # still Terminating alongside the new one, and its .status.phase still
    # reads "Running" even while kubectl's own STATUS column shows
    # "Terminating" (that column is derived from deletionTimestamp, not
    # phase) -- so filtering on phase alone would still risk picking it.
    PATTERN="$(echo "$COMPONENT" | tr '_' '-')"
    POD=$(kubectl -n tfs get pods -o custom-columns=NAME:.metadata.name,DELETED:.metadata.deletionTimestamp --no-headers 2>/dev/null \
          | awk -v pat="$PATTERN" 'tolower($1) ~ tolower(pat) && $2 == "<none>" {print $1}' | tail -1)
    if [[ -z "$POD" ]]; then
        echo "[$COMPONENT] could not find a matching pod -- check manually with: kubectl -n tfs get pods | grep -i $PATTERN"
        continue
    fi
    echo "[$COMPONENT] pod: $POD"
    kubectl -n tfs get pod "$POD"
    echo "  -- last 15 log lines --"
    kubectl -n tfs logs "$POD" --timestamps --tail=15 2>&1 | sed 's/^/  /'
    echo
done
+244 −69

File changed.

Preview size limit exceeded, changes collapsed.

+1033 −0

File added.

Preview size limit exceeded, changes collapsed.