diff --git a/src/monitoring/.gitlab-ci.yml b/src/monitoring/.gitlab-ci.yml index 6041291fa8fa6da8c076b6454651cded93286d6f..3723db4311aa09b523a096bf457489ad1a7db01a 100644 --- a/src/monitoring/.gitlab-ci.yml +++ b/src/monitoring/.gitlab-ci.yml @@ -1,37 +1,41 @@ -# # build, tag and push the Docker image to the gitlab registry -# build monitoring: -# variables: -# IMAGE_NAME: 'monitoring' # name of the microservice -# IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) -# stage: build -# before_script: -# - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY -# script: -# - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/ -# - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" -# - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" -# after_script: -# - docker rmi $(docker images --quiet --filter=dangling=true) -# rules: -# - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' -# - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' -# - changes: -# - src/$IMAGE_NAME/**/*.{py,in,yml} -# - src/$IMAGE_NAME/Dockerfile -# - src/$IMAGE_NAME/tests/*.py -# - src/$IMAGE_NAME/tests/Dockerfile -# - manifests/$IMAGE_NAME.yaml -# - .gitlab-ci.yml +# build, tag and push the Docker image to the gitlab registry +build monitoring: + variables: + IMAGE_NAME: 'monitoring' # name of the microservice + IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) + stage: build + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + script: + - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/Dockerfile ./src/ + - docker tag "$IMAGE_NAME:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" + - docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" + after_script: + - docker rmi $(docker images --quiet --filter=dangling=true) + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' + - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' + - changes: + - src/$IMAGE_NAME/**/*.{py,in,yml} + - src/$IMAGE_NAME/Dockerfile + - src/$IMAGE_NAME/tests/*.py + - src/$IMAGE_NAME/tests/Dockerfile + - manifests/$IMAGE_NAME.yaml + - .gitlab-ci.yml test kubernetes: stage: test script: - # - kubectl get all - # - kubectl apply -f "manifests/monitoring.yaml" - kubectl get all - - kubectl --namespace gitlab-ci describe pod monitoring-dbd57fb5f-4rz92 - - kubectl --namespace gitlab-ci logs monitoring-dbd57fb5f-4rz92 influxdb - - kubectl --namespace gitlab-ci logs monitoring-dbd57fb5f-4rz92 server + - kubectl delete -f "manifests/monitoring.yaml" + - sleep 15 + - kubectl get all + - kubectl apply -f "manifests/monitoring.yaml" + - sleep 60 + - kubectl get all + # - kubectl --namespace gitlab-ci describe pod monitoring-dbd57fb5f-4rz92 + # - kubectl --namespace gitlab-ci logs monitoring-dbd57fb5f-4rz92 influxdb + # - kubectl --namespace gitlab-ci logs monitoring-dbd57fb5f-4rz92 server # # test if the Docker image can be pulled from the gitlab registry # test monitoring pull: diff --git a/src/monitoring/service/MonitoringServiceServicerImpl.py b/src/monitoring/service/MonitoringServiceServicerImpl.py index daa9e4289fe2866178ff6541e36baf1996a13303..1747e3a2b819442e2d221fdfca493d609ced70f4 100644 --- a/src/monitoring/service/MonitoringServiceServicerImpl.py +++ b/src/monitoring/service/MonitoringServiceServicerImpl.py @@ -30,11 +30,6 @@ class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceService # Create influx_db client self.influx_db = influx_tools.Influx(INFLUXDB_HOSTNAME,"8086",INFLUXDB_USER,INFLUXDB_PASSWORD,INFLUXDB_DATABASE) - LOGGER.info(INFLUXDB_HOSTNAME) - LOGGER.info(INFLUXDB_USER) - LOGGER.info(INFLUXDB_PASSWORD) - LOGGER.info(INFLUXDB_DATABASE) - self.influx_db.read_KPI_points() # CreateKpi (CreateKpiRequest) returns (KpiId) {} def CreateKpi(self, request : monitoring_pb2.CreateKpiRequest, context) -> monitoring_pb2.KpiId :