From 8674a710af7b314fdfce03e68c04e5d8a96f7ed8 Mon Sep 17 00:00:00 2001 From: vitor-aignosi Date: Fri, 25 Apr 2025 16:57:55 -0300 Subject: [PATCH] SIENTIAPDE-1017 Update liveness and readiness probes, enhance Redis connection, and refine OPC tag data structure --- helm/values.yaml | 51 ++++++++++++++++++--------- ingestor/managers/ingestor_manager.py | 1 + simulator/redis-feeder.py | 29 ++------------- 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/helm/values.yaml b/helm/values.yaml index a321bf6..32cc058 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -66,16 +66,23 @@ resources: {} # This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ livenessProbe: - tcpSocket: - port: 4840 - initialDelaySeconds: 150 - periodSeconds: 15 + exec: + command: + - sh + - -c + - pgrep -f "ingestor.app" + initialDelaySeconds: 20 + periodSeconds: 30 readinessProbe: - tcpSocket: - port: 4840 - initialDelaySeconds: 120 - periodSeconds: 10 + exec: + command: + - sh + - -c + - pgrep -f "ingestor.app" + initialDelaySeconds: 10 + periodSeconds: 15 + # This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ autoscaling: @@ -114,25 +121,35 @@ service: env: # Entrypoint variables - name: GITHUB_REPO_URL - value: git@github.com:Aignosi/sientia-dataops-opc-ingestor.git + value: "git@github.com:Aignosi/sientia-dataops-opc-ingestor.git" - name: GITHUB_BRANCH - value: SIENTIAPDE-988-criar-ingestor-opc + value: "SIENTIAPDE-1017-criar-helm-generico-para-os-modulos-do-sientia" - name: PYTHON_APP - value: ingestor.app + value: "ingestor.app" # Application variables - name: KAFKA_SERVERS - value: kafka.kafka.svc.cluster.local:9092 + value: "kafka.kafka.svc.cluster.local:9092" - name: REDIS_HOST - value: redis-master.redis.svc.cluster.local + value: "redis-master.redis.svc.cluster.local" - name: REDIS_PORT value: "6379" + - name: REDIS_USERNAME + valueFrom: + secretKeyRef: + name: redis + key: redis-username + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: redis + key: redis-password - name: LEASE_TTL - value: 10 + value: "10" - name: HEARTBEAT_TTL - value: 20 + value: "20" - name: POLL_INTERVAL - value: 5 + value: "5" ssh: @@ -142,4 +159,4 @@ ssh: knownHostsPath: /mnt/known_hosts # kubectl create secret docker-registry docker-hub-secret --namespace sientia-opc --docker-server=http://aignosi.azurecr.io --docker-username=aignosi --docker-password=5I5zpQ6sRaHqX1hD3dr+2mo647yO3FRc359/wu6gsP+ACRDRz5mp -# helm upgrade --install sientia-dataops-opc-simulator ./sientia-module -n sientia-opc --create-namespace \ No newline at end of file +# helm upgrade --install sientia-dataops-opc-ingestor ./helm -n sientia-opc --create-namespace \ No newline at end of file diff --git a/ingestor/managers/ingestor_manager.py b/ingestor/managers/ingestor_manager.py index dc054fa..ff2a5d9 100644 --- a/ingestor/managers/ingestor_manager.py +++ b/ingestor/managers/ingestor_manager.py @@ -55,6 +55,7 @@ class IngestorManager(): manager.connect() except Exception as e: logger.error(f"Failed to initialize OpcManager: {e}") + traceback.print_exc() return None return manager diff --git a/simulator/redis-feeder.py b/simulator/redis-feeder.py index 06b9884..3f7e36a 100644 --- a/simulator/redis-feeder.py +++ b/simulator/redis-feeder.py @@ -7,7 +7,8 @@ redis_host = "localhost" redis_port = 6379 # Connect to Redis -r = redis.Redis(host=redis_host, port=redis_port, decode_responses=True) +r = redis.Redis(host=redis_host, port=redis_port, + decode_responses=True, username='default', password='bdnZOpcyiL') # Define the key pattern to target pattern = "slot:opc_tags:*" @@ -24,7 +25,7 @@ new_data = { "slot:opc_tags:1": { "server1": { "name": "server1", - "url": "opc.tcp://simulator:4840", + "url": "opc.tcp://sientia-opc-simulator-service.sientia-opc.svc.cluster.local:4840", "server_uri": "http://opcua-server.simulator", "tags": { 'ns=2;i=2': { @@ -44,30 +45,6 @@ new_data = { }, } } - }, - "slot:opc_tags:2": { - "server2": { - "name": "server2", - "url": "opc.tcp://simulator:4840", - "server_uri": "http://opcua-server.simulator", - "tags": { - 'ns=2;i=2': { - 'tag_name': 'Counter', - 'frequency': 1000, - 'topics': ['opcua2', 'counter'], - }, - 'ns=2;i=3': { - 'tag_name': 'Rollout', - 'frequency': 1000, - "topics": ['opcua2', 'rollout'], - }, - 'ns=2;i=4': { - 'tag_name': 'Square', - 'frequency': 1000, - "topics": ['opcua2'], - }, - } - } } }