diff --git a/src/opticalattackmanager/service/__main__.py b/src/opticalattackmanager/service/__main__.py index 85b1039fcb5a8594f70e054d683be31e6c585110..6ea636f42eb4b992bb7d722188ccbc945a6a153d 100644 --- a/src/opticalattackmanager/service/__main__.py +++ b/src/opticalattackmanager/service/__main__.py @@ -333,22 +333,6 @@ async def monitor_services(terminate, service_list=None, cache=None): ) ) - # start standard implementation - # tasks = [] - # for service in current_list: - # aw = detect_attack( - # host, - # port, - # service["context"], - # service["service"], - # service["kpi"], - # # allow at most 90% of the monitoring interval to succeed - # monitoring_interval * 0.9, - # ) - # tasks.append(aw) - # [await aw for aw in tasks] - # end standard implementation - # start pool implementation if len(current_list) == 0: # guard clause to re-check if services still there LOGGER.info( @@ -434,22 +418,22 @@ def main(): logging.getLogger("hpack").setLevel(logging.CRITICAL) - # wait_for_environment_variables( - # [ - # get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST), - # get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), - # get_env_var_name(ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_HOST), - # get_env_var_name( - # ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_PORT_GRPC - # ), - # get_env_var_name( - # ServiceNameEnum.OPTICALATTACKDETECTOR, ENVVAR_SUFIX_SERVICE_HOST - # ), - # get_env_var_name( - # ServiceNameEnum.OPTICALATTACKDETECTOR, ENVVAR_SUFIX_SERVICE_PORT_GRPC - # ), - # ] - # ) + wait_for_environment_variables( + [ + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST), + get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), + get_env_var_name(ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_HOST), + get_env_var_name( + ServiceNameEnum.MONITORING, ENVVAR_SUFIX_SERVICE_PORT_GRPC + ), + get_env_var_name( + ServiceNameEnum.OPTICALATTACKDETECTOR, ENVVAR_SUFIX_SERVICE_HOST + ), + get_env_var_name( + ServiceNameEnum.OPTICALATTACKDETECTOR, ENVVAR_SUFIX_SERVICE_PORT_GRPC + ), + ] + ) signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) @@ -479,7 +463,7 @@ def main(): LOGGER.info(f"Connecting to Redis: host={redis_host}, port={redis_port}, password={redis_password}") # clean the existing list that will be populated later on in this function - # cache.delete(SERVICE_LIST_KEY) + cache.delete(SERVICE_LIST_KEY) elif SERVICE_LIST_MODE == LIST_SHARED_MODE: # creating a thread-safe list to be shared among threads service_list = Manager().list() diff --git a/src/tests/scenario3/optical/scaphandre.yaml b/src/tests/scenario3/optical/scaphandre.yaml deleted file mode 100644 index 3b348cb8a91ee257eaa9aa73e96108d20931e2a2..0000000000000000000000000000000000000000 --- a/src/tests/scenario3/optical/scaphandre.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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. - -# this file deploys a tool that enables the monitoring of energy consumption -# per component. -# More info: https://github.com/hubblo-org/scaphandre - ---- -apiVersion: monitoring.coreos.com/v1 -kind: ServiceMonitor -metadata: - namespace: monitoring # namespace where prometheus is running - name: tfs-scaph-metric - labels: - app.kubernetes.io/name: scaphandre - #release: prometheus - #release: prom # name of the release - # ( VERY IMPORTANT: You need to know the correct release name by viewing - # the servicemonitor of Prometheus itself: Without the correct name, - # Prometheus cannot identify the metrics of the Flask app as the target.) -spec: - selector: - matchLabels: - # Target app service - #namespace: tfs - app.kubernetes.io/name: scaphandre - #release: prometheus # same as above - endpoints: - - port: metrics # named port in target app - scheme: http - path: /metrics # path to scrape - interval: 5s # scrape interval - namespaceSelector: - any: false - matchNames: - - tfs # namespace where the app is running \ No newline at end of file diff --git a/src/tests/scenario3/optical/test_prom_timestamp.py b/src/tests/scenario3/optical/test_prom_timestamp.py deleted file mode 100644 index 452e633ac22898e6c325b00c160eed795b46496d..0000000000000000000000000000000000000000 --- a/src/tests/scenario3/optical/test_prom_timestamp.py +++ /dev/null @@ -1,15 +0,0 @@ -import requests - -from kubernetes import client, config - -config.load_kube_config() -v1 = client.CoreV1Api() - -ret = v1.list_namespaced_endpoints(namespace=namespace, watch=False) -for item in ret.items: - if "caching" in item.metadata.name: - for subset in item.subsets: - for port in subset.ports: - if "redis" in port.name: # endpoint is ready for being scraped - CACHING_HOST = subset.addresses[0].ip - CACHING_PORT = port.port