diff --git a/common_requirements.in b/common_requirements.in index 12c6c778d107ebf27ad53a25b2da60ad2f65286e..ebd726e415c46a5b350576c25ba1d9bd0a443091 100644 --- a/common_requirements.in +++ b/common_requirements.in @@ -24,4 +24,3 @@ protobuf==3.20.* pytest==6.2.5 pytest-benchmark==3.4.1 python-dateutil==2.8.2 -pytest-depends==1.0.1 diff --git a/common_requirements_py313.in b/common_requirements_py313.in new file mode 100644 index 0000000000000000000000000000000000000000..de1a6ed2003e91172006751f6659842189751fc4 --- /dev/null +++ b/common_requirements_py313.in @@ -0,0 +1,27 @@ +# Copyright 2022-2025 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. + +coverage==7.9.* +grpcio==1.73.* +grpcio-health-checking==1.73.* +grpcio-reflection==1.73.* +grpcio-tools==1.73.* +grpclib==0.4.8 +prettytable==3.16.0 +prometheus-client==0.22.* +protobuf==6.32.* +pytest==8.4.1 +pytest-benchmark==5.1.0 +python-dateutil==2.9.0 +pytest-depends==1.0.1 diff --git a/manifests/contextservice.yaml b/manifests/contextservice.yaml index 5592864d68485086b760ad3bee06353847ca4c56..3ac3323899f782300117085a0a1f2312d647344d 100644 --- a/manifests/contextservice.yaml +++ b/manifests/contextservice.yaml @@ -52,12 +52,17 @@ spec: name: crdb-data - secretRef: name: nats-data + startupProbe: + grpc: + port: 1010 + failureThreshold: 30 + periodSeconds: 1 readinessProbe: - exec: - command: ["/bin/grpc_health_probe", "-addr=:1010"] + grpc: + port: 1010 livenessProbe: - exec: - command: ["/bin/grpc_health_probe", "-addr=:1010"] + grpc: + port: 1010 resources: requests: cpu: 250m diff --git a/manifests/serviceservice.yaml b/manifests/serviceservice.yaml index 8262550efc31ff5c6d8d660cab7206c31c1bc86e..4f65cd1374421d78577fcb8e21554c24f004054f 100644 --- a/manifests/serviceservice.yaml +++ b/manifests/serviceservice.yaml @@ -37,12 +37,17 @@ spec: env: - name: LOG_LEVEL value: "INFO" + startupProbe: + grpc: + port: 3030 + failureThreshold: 30 + periodSeconds: 1 readinessProbe: - exec: - command: ["/bin/grpc_health_probe", "-addr=:3030"] + grpc: + port: 3030 livenessProbe: - exec: - command: ["/bin/grpc_health_probe", "-addr=:3030"] + grpc: + port: 3030 resources: requests: cpu: 250m diff --git a/src/common/method_wrappers/Decorator.py b/src/common/method_wrappers/Decorator.py index 6bd9f8217e425a2c9ce5da656b403d0f8d631370..ef0c6f99e159a03de9de7e417e79119b5b97f1ad 100644 --- a/src/common/method_wrappers/Decorator.py +++ b/src/common/method_wrappers/Decorator.py @@ -128,7 +128,10 @@ class MetricsPool: else: raise Exception('Unsupported metric: {:s}'.format(raw_metric_name)) # pragma: no cover metric_data = method_to_metric_fields.setdefault(method_name, dict()).setdefault(metric_name, dict()) - for field_name,labels,value,_,_ in raw_metric_data._child_samples(): + for values in raw_metric_data._child_samples(): + field_name = values[0] + labels = values[1] + value = values[2] if field_name == '_bucket': bucket_bounds.add(labels['le']) if len(labels) > 0: field_name = '{:s}:{:s}'.format(field_name, json.dumps(labels, sort_keys=True)) metric_data[field_name] = value diff --git a/src/common/tools/grpc/Tools.py b/src/common/tools/grpc/Tools.py index 9a64c48708f85273a143c39e3d5ade3975154636..8184343d673b968c54673cf5f17c3f0797b2775f 100644 --- a/src/common/tools/grpc/Tools.py +++ b/src/common/tools/grpc/Tools.py @@ -13,15 +13,28 @@ # limitations under the License. import json +import warnings +from google import protobuf from google.protobuf.json_format import MessageToDict def grpc_message_to_json( message, including_default_value_fields=True, preserving_proto_field_name=True, use_integers_for_enums=False ): if not hasattr(message, 'DESCRIPTOR'): return json.dumps(str(message), sort_keys=True) # not a gRPC message - return MessageToDict( - message, including_default_value_fields=including_default_value_fields, - preserving_proto_field_name=preserving_proto_field_name, use_integers_for_enums=use_integers_for_enums) + if including_default_value_fields is not True: + warnings.warn( + "The 'including_default_value_fields' argument is deprecated and will have no effect in future versions.", + DeprecationWarning, + stacklevel=2 + ) + if protobuf.__version__ < '4.0.0': + return MessageToDict( + message, including_default_value_fields=including_default_value_fields, + preserving_proto_field_name=preserving_proto_field_name, use_integers_for_enums=use_integers_for_enums) + else: + return MessageToDict( + message, + preserving_proto_field_name=preserving_proto_field_name, use_integers_for_enums=use_integers_for_enums) def grpc_message_list_to_json(message_list): if message_list is None: return None diff --git a/src/context/Dockerfile b/src/context/Dockerfile index a4bf84153898f5fd7946b6ba90a1357aef7d4217..add63fe65aa7656a5d06f9467a087ac1558d1b0b 100644 --- a/src/context/Dockerfile +++ b/src/context/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM python:3.9-slim +FROM python:3.13-slim # Install dependencies RUN apt-get --yes --quiet --quiet update && \ @@ -23,9 +23,9 @@ RUN apt-get --yes --quiet --quiet update && \ ENV PYTHONUNBUFFERED=0 # Download the gRPC health probe -RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ - chmod +x /bin/grpc_health_probe +# RUN GRPC_HEALTH_PROBE_VERSION=v0.4.40 && \ +# wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ +# chmod +x /bin/grpc_health_probe # Get generic Python packages RUN python3 -m pip install --upgrade pip @@ -35,7 +35,7 @@ RUN python3 -m pip install --upgrade pip-tools # Get common Python packages # Note: this step enables sharing the previous Docker build steps among all the Python components WORKDIR /var/teraflow -COPY common_requirements.in common_requirements.in +COPY common_requirements_py313.in common_requirements.in RUN pip-compile --quiet --output-file=common_requirements.txt common_requirements.in RUN python3 -m pip install -r common_requirements.txt @@ -57,7 +57,7 @@ RUN find . -type f -exec sed -i -E 's/^(import\ .*)_pb2/from . \1_pb2/g' {} \; RUN mkdir -p /var/teraflow/context WORKDIR /var/teraflow/context COPY src/context/requirements.in requirements.in -RUN pip-compile --quiet --output-file=requirements.txt requirements.in +RUN pip-compile --quiet --output-file=requirements.txt requirements.in /var/teraflow/common_requirements.in RUN python3 -m pip install -r requirements.txt # Add component files into working directory diff --git a/src/context/requirements.in b/src/context/requirements.in index f5c809461496676a0c8240cec79bebd1bfa41a2e..907cd1ac65116d6622502d972cf6bb9e78d91d2d 100644 --- a/src/context/requirements.in +++ b/src/context/requirements.in @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -nats-py==2.6.* +nats-py==2.10.* psycopg2-binary==2.9.* -SQLAlchemy==1.4.* -sqlalchemy-cockroachdb==1.4.* -SQLAlchemy-Utils==0.38.* +SQLAlchemy==1.4.* # TODO: Update to 2.0 due to deprecated build step +sqlalchemy-cockroachdb==1.4.* # TODO: Update to 2.0 due to deprecated build step +SQLAlchemy-Utils==0.41.* diff --git a/src/service/Dockerfile b/src/service/Dockerfile index 49efe9829d63f1923b3bb271c66a05b02bd8e499..493094769a14969aadca50f7a1b0902fe8ce0750 100644 --- a/src/service/Dockerfile +++ b/src/service/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM python:3.9-slim +FROM python:3.13-slim # Install dependencies RUN apt-get --yes --quiet --quiet update && \ @@ -23,9 +23,9 @@ RUN apt-get --yes --quiet --quiet update && \ ENV PYTHONUNBUFFERED=0 # Download the gRPC health probe -RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \ - wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ - chmod +x /bin/grpc_health_probe +# RUN GRPC_HEALTH_PROBE_VERSION=v0.4.40 && \ +# wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \ +# chmod +x /bin/grpc_health_probe # Get generic Python packages RUN python3 -m pip install --upgrade pip @@ -35,7 +35,7 @@ RUN python3 -m pip install --upgrade pip-tools # Get common Python packages # Note: this step enables sharing the previous Docker build steps among all the Python components WORKDIR /var/teraflow -COPY common_requirements.in common_requirements.in +COPY common_requirements_py313.in common_requirements.in RUN pip-compile --quiet --output-file=common_requirements.txt common_requirements.in RUN python3 -m pip install -r common_requirements.txt @@ -57,7 +57,7 @@ RUN find . -type f -exec sed -i -E 's/^(import\ .*)_pb2/from . \1_pb2/g' {} \; RUN mkdir -p /var/teraflow/service WORKDIR /var/teraflow/service COPY src/service/requirements.in requirements.in -RUN pip-compile --quiet --output-file=requirements.txt requirements.in +RUN pip-compile --quiet --output-file=requirements.txt requirements.in /var/teraflow/common_requirements.in RUN python3 -m pip install -r requirements.txt # Add component files into working directory