Commit d7509173 authored by Andrea Sgambelluri's avatar Andrea Sgambelluri
Browse files

Restore deploy/manifest fixes lost when porting the optical controller onto develop

- opticalcontrollerservice: re-add the external NodePort (31060) Service
  used by REST clients and demo scripts outside the cluster.
- deviceservice: re-expose port 10065 (subcarrier_groups API). Without it,
  OpticalController's read_DSC_only() hung on a 10 s connect timeout on
  every compute-p2mp.
- OpticalController: Flask debug mode is now opt-in via
  OPTICAL_CONTROLLER_DEBUG (the Werkzeug debugger must not be reachable via
  the NodePort); read_DSC_only() uses a 2 s connect timeout.
- deploy/component.sh: extract the image tag with cut -f4 (the registry URL
  has a port, so -f3 never matched and upstream :latest images were
  deployed instead of the local build); create tmp/ folders; call
  ./deploy/show.sh instead of the non-existent ./show_deploy.sh.
- deploy/tfs.sh: fall back to Kafka port 9092 when kafka-service isn't
  ready, so the kfk-kpi-data secret never ships an empty port.
- scripts: restore run_tests_locally-telemetry-netconf.sh; make
  show_logs_opticalcontroller.sh follow the logs.

Verified: 4-cycle alarm failover/revert lifecycle test passes (28/28
checks) against device and opticalcontroller rebuilt from this tree.
parent 4a7fffd2
Loading
Loading
Loading
Loading
+9 −7
Changes for deploy/component.sh: 9 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ TMP_FOLDER="./tmp"
# Create a tmp folder for files modified during the deployment
TMP_MANIFESTS_FOLDER="$TMP_FOLDER/manifests"
TMP_LOGS_FOLDER="$TMP_FOLDER/logs"
mkdir -p "$TMP_MANIFESTS_FOLDER"
mkdir -p "$TMP_LOGS_FOLDER"

bash scripts/dockerhub_k8s_secret.sh "$TFS_K8S_NAMESPACE"

@@ -128,30 +130,30 @@ for COMPONENT in $TFS_COMPONENTS; do
    if [ -n "$TFS_REGISTRY_IMAGES" ]; then
        # Registry is set
        if [ "$COMPONENT" == "pathcomp" ]; then
            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-frontend:" "$MANIFEST" | cut -d ":" -f3)
            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-frontend:" "$MANIFEST" | cut -d ":" -f4)
            sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-frontend:${VERSION}#image: $IMAGE_URL-frontend#g" "$MANIFEST"

            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-backend:" "$MANIFEST" | cut -d ":" -f3)
            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-backend:" "$MANIFEST" | cut -d ":" -f4)
            sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-backend:${VERSION}#image: $IMAGE_URL-backend#g" "$MANIFEST"

            sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" "$MANIFEST"
        else
            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3)
            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f4)
            sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_URL#g" "$MANIFEST"
            sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Always#g" "$MANIFEST"
        fi
    else
        # Registry is not set
        if [ "$COMPONENT" == "pathcomp" ]; then
            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-frontend:" "$MANIFEST" | cut -d ":" -f3)
            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-frontend:" "$MANIFEST" | cut -d ":" -f4)
            sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-frontend:${VERSION}#image: $IMAGE_NAME-frontend#g" "$MANIFEST"

            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-backend:" "$MANIFEST" | cut -d ":" -f3)
            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}-backend:" "$MANIFEST" | cut -d ":" -f4)
            sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT-backend:${VERSION}#image: $IMAGE_NAME-backend#g" "$MANIFEST"

            sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Never#g" "$MANIFEST"
        else
            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f3)
            VERSION=$(grep -i "${GITLAB_REPO_URL}/${COMPONENT}:" "$MANIFEST" | cut -d ":" -f4)
            sed -E -i "s#image: $GITLAB_REPO_URL/$COMPONENT:${VERSION}#image: $IMAGE_NAME#g" "$MANIFEST"
            sed -E -i "s#imagePullPolicy: .*#imagePullPolicy: Never#g" "$MANIFEST"
        fi
@@ -212,6 +214,6 @@ for COMPONENT in $TFS_COMPONENTS; do
    printf "\n"
done

./show_deploy.sh
./deploy/show.sh

echo "Done!"
+7 −0
Changes for deploy/tfs.sh: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -142,6 +142,13 @@ printf "\n"

echo ">>> Create Secret with Apache Kafka..."
KFK_SERVER_PORT=$(kubectl --namespace ${KFK_NAMESPACE} get service kafka-service -o 'jsonpath={.spec.ports[0].port}')
if [ -z "$KFK_SERVER_PORT" ]; then
    # kafka-service not found/ready yet when queried; fall back to the default
    # port so the secret never ships an empty value (which breaks every
    # consumer's Kafka client with "invalid literal for int() with base 10").
    echo "WARNING: could not read kafka-service port, defaulting KFK_SERVER_PORT to 9092"
    KFK_SERVER_PORT="9092"
fi
kubectl create secret generic kfk-kpi-data --namespace ${TFS_K8S_NAMESPACE} --type='Opaque' \
    --from-literal=KFK_NAMESPACE=${KFK_NAMESPACE} \
    --from-literal=KFK_SERVER_PORT=${KFK_SERVER_PORT}
+9 −0
Changes for manifests/deviceservice.yaml: 9 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -37,6 +37,11 @@ spec:
          ports:
            - containerPort: 2020
            - containerPort: 9192
            # subcarrier_groups HTTP API (oc_driver/readSupport.py), read by
            # OpticalController's read_DSC_only()
            - name: flask-api
              containerPort: 10065
              protocol: TCP
          env:
            - name: LOG_LEVEL
              value: "INFO"
@@ -78,3 +83,7 @@ spec:
      protocol: TCP
      port: 9192
      targetPort: 9192
    - name: flask-api
      protocol: TCP
      port: 10065
      targetPort: 10065
+20 −0
Changes for manifests/opticalcontrollerservice.yaml: 20 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -74,3 +74,23 @@ spec:
      protocol: TCP
      port: 9192
      targetPort: 9192
---
# External NodePort access for clients outside the cluster (REST clients,
# demo scripts). In-cluster callers such as PathComp use the ClusterIP
# service above.
apiVersion: v1
kind: Service
metadata:
  name: opticalcontrollerservice-external
  labels:
    app: opticalcontrollerservice
spec:
  type: NodePort
  selector:
    app: opticalcontrollerservice
  ports:
    - name: http-external
      protocol: TCP
      port: 10060
      targetPort: 10060
      nodePort: 31060
+42 −0
Changes for scripts/run_tests_locally-telemetry-netconf.sh: 42 added lines, 0 removed lines.
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2026 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PROJECTDIR=`pwd`
cd $PROJECTDIR/src
RCFILE=$PROJECTDIR/coverage/.coveragerc

# Collector folders to exclude from measurement and reporting
OMIT_COLLECTORS="telemetry/backend/service/collectors/emulated/*"
OMIT_COLLECTORS="${OMIT_COLLECTORS},telemetry/backend/service/collectors/gnmi_oc/*"
OMIT_COLLECTORS="${OMIT_COLLECTORS},telemetry/backend/service/collectors/int_collector/*"

# Files to include in the HTML report:
#   - netconf_oc collector (the code under test)
#   - telemetry backend service layer (*.py directly in service/)
INCLUDE_REPORT="telemetry/backend/service/collectors/netconf_oc/*"
INCLUDE_REPORT="${INCLUDE_REPORT},telemetry/backend/service/*.py"

# This is unit test (should be tested with container-lab running)
python3 -m coverage run \
    --source=telemetry/backend/service \
    --omit="${OMIT_COLLECTORS}" \
    -m pytest --log-level=info --log-cli-level=info --verbose \
    telemetry/backend/tests/netconf_oc/test_unit_NetconfOCcollector.py

python3 -m coverage html \
    --directory=../coverage/ecoc26_netconf_oc_unit \
    --include="${INCLUDE_REPORT}"

echo "Bye!"
Loading