Commit 8b6f5edd authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Forecaster:

- Improved tests/data/README.md
- Added log messages to TopologyTools.py
parent f53c39f5
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
# Manual Forecaster test:

- Edit `my_deploy.sh` and enable the `monitoring` and the `forecaster` components.
- Move to root folder:
```bash
cd ~/tfs-ctrl
```

- Edit `my_deploy.sh` and enable the `monitoring` and the `forecaster` components:
```bash
export TFS_COMPONENTS="context device monitoring forecaster pathcomp service slice compute webui load_generator"
```

- Edit `deploy/tfs.sh` and disable linkerd injection to capture unencrypted traffic.
```bash
cp ./manifests/"${COMPONENT}"service.yaml "$MANIFEST"
#cat ./manifests/"${COMPONENT}"service.yaml | linkerd inject - --proxy-cpu-request "10m" --proxy-cpu-limit "1" --proxy-memory-request "64Mi" --proxy-memory-limit "256Mi" > "$MANIFEST"
```

- Deploy TeraFlowSDN controller:
```bash
@@ -16,4 +30,14 @@ source tfs_runtime_env_vars.sh
python src/forecaster/tests/data/inject_samples.py
```

- Start wireshark capture:
```bash
tshark -i any -f "tcp port not 22 and tcp port not 16443" -w capture.pcap
```

- Onboard the service descriptor `service.json` through the WebUI.

- Wireshark display filter:
```
(ip.addr==10.152.183.0/24 or ip.addr==10.0.2.10) and tcp.port!=443 and tcp.port!=26257 and tcp.port!=3000 and tcp.port!=9990 and tcp.port!=8089 and tcp.port!=16443 and tcp.port!=10250 and tcp.port!=10254 and tcp.port!=4191 and tcp.port!=9090 and tcp.port!=9994 and tcp.port!=9995 and tcp.port!=9996 and tcp.port!=9997 and tcp.port!=9998 and tcp.port!=4443 and tcp.port!=8181
```
+12 −10
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import math
import logging, math
from typing import Dict, Optional
from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME, ServiceNameEnum
from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, find_environment_variables, get_env_var_name
@@ -25,6 +25,8 @@ from common.tools.grpc.Tools import grpc_message_to_json_string
from context.client.ContextClient import ContextClient
from forecaster.client.ForecasterClient import ForecasterClient

LOGGER = logging.getLogger(__name__)

def get_service_schedule(service : Service) -> Optional[Constraint_Schedule]:
    for constraint in service.service_constraints:
        if constraint.WhichOneof('constraint') != 'schedule': continue
@@ -40,12 +42,8 @@ def get_pathcomp_topology_details(request : PathCompRequest, allow_forecasting :
    if len(request.services) == 0:
        raise InvalidArgumentException('services', grpc_message_to_json_string(request), 'must not be empty')

    if len(request.services) > 1:
        # Forecaster does not support multiple services
        return topology_details

    if not allow_forecasting:
        # Forecaster explicitly disabled
        LOGGER.warning('Forecaster is explicitly disabled')
        return topology_details

    env_vars = find_environment_variables([
@@ -53,19 +51,23 @@ def get_pathcomp_topology_details(request : PathCompRequest, allow_forecasting :
        get_env_var_name(ServiceNameEnum.FORECASTER, ENVVAR_SUFIX_SERVICE_PORT_GRPC),
    ])
    if len(env_vars) != 2:
        # Forecaster not available
        LOGGER.warning('Forecaster is not deployed')
        return topology_details

    if len(request.services) > 1:
        LOGGER.warning('Forecaster does not support multiple services')
        return topology_details

    service = request.services[0]
    service_schedule = get_service_schedule(service)
    if service_schedule is None:
        # Service provides no schedule constraint, so forecast cannot be computed
        LOGGER.warning('Service provides no schedule constraint; forecast cannot be used')
        return topology_details

    #start_timestamp = service_schedule.start_timestamp
    duration_days = service_schedule.duration_days
    if float(duration_days) > 0.0:
        # Service provides no scheduled duration, so forecast cannot be computed
    if float(duration_days) <= 1.e-12:
        LOGGER.warning('Service schedule constraint does not define a duration; forecast cannot be used')
        return topology_details

    forecaster_client = ForecasterClient()