Loading deploy/crdb.sh +5 −0 Original line number Diff line number Diff line Loading @@ -167,6 +167,11 @@ function crdb_drop_database_single() { } function crdb_deploy_cluster() { echo "CockroachDB Operator Namespace" echo ">>> Create CockroachDB Operator Namespace (if missing)" kubectl apply -f "${CRDB_MANIFESTS_PATH}/pre_operator.yaml" echo echo "Cockroach Operator CRDs" echo ">>> Apply Cockroach Operator CRDs (if they are missing)" cp "${CRDB_MANIFESTS_PATH}/crds.yaml" "${TMP_MANIFESTS_FOLDER}/crdb_crds.yaml" Loading manifests/cockroachdb/pre_operator.yaml 0 → 100644 +19 −0 Original line number Diff line number Diff line # Copyright 2022 The Cockroach Authors # # 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 # # https://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. apiVersion: v1 kind: Namespace metadata: labels: control-plane: cockroach-operator name: cockroach-operator-system manifests/contextservice.yaml +6 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ spec: #replicas: 1 template: metadata: annotations: config.linkerd.io/skip-outbound-ports: "4222" labels: app: contextservice spec: Loading Loading @@ -52,11 +54,11 @@ spec: command: ["/bin/grpc_health_probe", "-addr=:1010"] resources: requests: cpu: 75m memory: 64Mi limits: cpu: 100m cpu: 250m memory: 128Mi limits: cpu: 1000m memory: 1024Mi --- apiVersion: v1 kind: Service Loading src/common/message_broker/backend/nats/NatsBackendThread.py +8 −1 Original line number Diff line number Diff line Loading @@ -12,10 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. import asyncio, nats, nats.errors, queue, threading import asyncio, logging, nats, nats.errors, queue, threading from typing import List from common.message_broker.Message import Message LOGGER = logging.getLogger(__name__) class NatsBackendThread(threading.Thread): def __init__(self, nats_uri : str) -> None: self._nats_uri = nats_uri Loading @@ -32,7 +34,9 @@ class NatsBackendThread(threading.Thread): self._tasks_terminated.set() async def _run_publisher(self) -> None: LOGGER.info('[_run_publisher] NATS URI: {:s}'.format(str(self._nats_uri))) client = await nats.connect(servers=[self._nats_uri]) LOGGER.info('[_run_publisher] Connected!') while not self._terminate.is_set(): try: message : Message = await self._publish_queue.get() Loading @@ -47,8 +51,11 @@ class NatsBackendThread(threading.Thread): async def _run_subscriber( self, topic_name : str, timeout : float, out_queue : queue.Queue[Message], unsubscribe : threading.Event ) -> None: LOGGER.info('[_run_subscriber] NATS URI: {:s}'.format(str(self._nats_uri))) client = await nats.connect(servers=[self._nats_uri]) LOGGER.info('[_run_subscriber] Connected!') subscription = await client.subscribe(topic_name) LOGGER.info('[_run_subscriber] Subscribed!') while not self._terminate.is_set() and not unsubscribe.is_set(): try: message = await subscription.next_msg(timeout) Loading src/monitoring/service/MetricsDBTools.py +25 −28 Original line number Diff line number Diff line Loading @@ -264,68 +264,65 @@ class MetricsDB(): for kpi in kpi_list: alarm = False kpi_value = kpi[2] kpiMinIsNone = ((kpiMinValue is None) or math.isnan(kpiMinValue)) kpiMaxIsNone = ((kpiMaxValue is None) or math.isnan(kpiMaxValue)) if (kpiMinValue == kpi_value and kpiMaxValue == kpi_value and inRange): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and includeMaxValue): if (kpi_value >= kpiMinValue and kpi_value <= kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and not includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and not includeMaxValue): if (kpi_value >= kpiMinValue and kpi_value < kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and includeMaxValue): if (kpi_value > kpiMinValue and kpi_value <= kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and not includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and not includeMaxValue): if (kpi_value > kpiMinValue and kpi_value < kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and includeMaxValue): if (kpi_value <= kpiMinValue or kpi_value >= kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and not includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and not includeMaxValue): if (kpi_value <= kpiMinValue or kpi_value > kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and includeMaxValue): if (kpi_value < kpiMinValue or kpi_value >= kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and not includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and not includeMaxValue): if (kpi_value < kpiMinValue or kpi_value > kpiMaxValue): alarm = True elif (inRange and kpiMinValue is not None and kpiMaxValue is None and includeMinValue): elif (inRange and not kpiMinIsNone and kpiMaxIsNone and includeMinValue): if (kpi_value >= kpiMinValue): alarm = True elif (inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): elif (inRange and not kpiMinIsNone and kpiMaxIsNone and not includeMinValue): if (kpi_value > kpiMinValue): alarm = True elif (not inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): elif (not inRange and not kpiMinIsNone and kpiMaxIsNone and includeMinValue): if (kpi_value <= kpiMinValue): alarm = True elif (not inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): if (kpi_value <= kpiMinValue): elif (not inRange and not kpiMinIsNone and kpiMaxIsNone and not includeMinValue): if (kpi_value < kpiMinValue): alarm = True elif (inRange and kpiMinValue is None and kpiMaxValue is not None and includeMaxValue): elif (inRange and kpiMinIsNone and not kpiMaxIsNone and includeMaxValue): if (kpi_value <= kpiMaxValue): alarm = True elif (inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): elif (inRange and kpiMinIsNone and not kpiMaxIsNone and not includeMaxValue): if (kpi_value < kpiMaxValue): alarm = True elif (not inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): elif (not inRange and kpiMinIsNone and not kpiMaxIsNone and includeMaxValue): if (kpi_value >= kpiMaxValue): alarm = True elif (not inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): if (kpi_value >= kpiMaxValue): elif (not inRange and kpiMinIsNone and not kpiMaxIsNone and not includeMaxValue): if (kpi_value > kpiMaxValue): alarm = True if alarm: valid_kpi_list.append(kpi) if valid_kpi_list: alarm_queue.put_nowait(valid_kpi_list) LOGGER.debug(f"Alarm of KPI {kpi_id} triggered -> kpi_value:{kpi[2]}, timestamp:{kpi[1]}") else: LOGGER.debug(f"No new alarms triggered for the alarm of KPI {kpi_id}") else: LOGGER.debug(f"No new data for the alarm of KPI {kpi_id}") except (Exception) as e: Loading Loading
deploy/crdb.sh +5 −0 Original line number Diff line number Diff line Loading @@ -167,6 +167,11 @@ function crdb_drop_database_single() { } function crdb_deploy_cluster() { echo "CockroachDB Operator Namespace" echo ">>> Create CockroachDB Operator Namespace (if missing)" kubectl apply -f "${CRDB_MANIFESTS_PATH}/pre_operator.yaml" echo echo "Cockroach Operator CRDs" echo ">>> Apply Cockroach Operator CRDs (if they are missing)" cp "${CRDB_MANIFESTS_PATH}/crds.yaml" "${TMP_MANIFESTS_FOLDER}/crdb_crds.yaml" Loading
manifests/cockroachdb/pre_operator.yaml 0 → 100644 +19 −0 Original line number Diff line number Diff line # Copyright 2022 The Cockroach Authors # # 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 # # https://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. apiVersion: v1 kind: Namespace metadata: labels: control-plane: cockroach-operator name: cockroach-operator-system
manifests/contextservice.yaml +6 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ spec: #replicas: 1 template: metadata: annotations: config.linkerd.io/skip-outbound-ports: "4222" labels: app: contextservice spec: Loading Loading @@ -52,11 +54,11 @@ spec: command: ["/bin/grpc_health_probe", "-addr=:1010"] resources: requests: cpu: 75m memory: 64Mi limits: cpu: 100m cpu: 250m memory: 128Mi limits: cpu: 1000m memory: 1024Mi --- apiVersion: v1 kind: Service Loading
src/common/message_broker/backend/nats/NatsBackendThread.py +8 −1 Original line number Diff line number Diff line Loading @@ -12,10 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. import asyncio, nats, nats.errors, queue, threading import asyncio, logging, nats, nats.errors, queue, threading from typing import List from common.message_broker.Message import Message LOGGER = logging.getLogger(__name__) class NatsBackendThread(threading.Thread): def __init__(self, nats_uri : str) -> None: self._nats_uri = nats_uri Loading @@ -32,7 +34,9 @@ class NatsBackendThread(threading.Thread): self._tasks_terminated.set() async def _run_publisher(self) -> None: LOGGER.info('[_run_publisher] NATS URI: {:s}'.format(str(self._nats_uri))) client = await nats.connect(servers=[self._nats_uri]) LOGGER.info('[_run_publisher] Connected!') while not self._terminate.is_set(): try: message : Message = await self._publish_queue.get() Loading @@ -47,8 +51,11 @@ class NatsBackendThread(threading.Thread): async def _run_subscriber( self, topic_name : str, timeout : float, out_queue : queue.Queue[Message], unsubscribe : threading.Event ) -> None: LOGGER.info('[_run_subscriber] NATS URI: {:s}'.format(str(self._nats_uri))) client = await nats.connect(servers=[self._nats_uri]) LOGGER.info('[_run_subscriber] Connected!') subscription = await client.subscribe(topic_name) LOGGER.info('[_run_subscriber] Subscribed!') while not self._terminate.is_set() and not unsubscribe.is_set(): try: message = await subscription.next_msg(timeout) Loading
src/monitoring/service/MetricsDBTools.py +25 −28 Original line number Diff line number Diff line Loading @@ -264,68 +264,65 @@ class MetricsDB(): for kpi in kpi_list: alarm = False kpi_value = kpi[2] kpiMinIsNone = ((kpiMinValue is None) or math.isnan(kpiMinValue)) kpiMaxIsNone = ((kpiMaxValue is None) or math.isnan(kpiMaxValue)) if (kpiMinValue == kpi_value and kpiMaxValue == kpi_value and inRange): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and includeMaxValue): if (kpi_value >= kpiMinValue and kpi_value <= kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and not includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and not includeMaxValue): if (kpi_value >= kpiMinValue and kpi_value < kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and includeMaxValue): if (kpi_value > kpiMinValue and kpi_value <= kpiMaxValue): alarm = True elif ( inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and not includeMaxValue): elif (inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and not includeMaxValue): if (kpi_value > kpiMinValue and kpi_value < kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and includeMaxValue): if (kpi_value <= kpiMinValue or kpi_value >= kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and includeMinValue and not includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and includeMinValue and not includeMaxValue): if (kpi_value <= kpiMinValue or kpi_value > kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and includeMaxValue): if (kpi_value < kpiMinValue or kpi_value >= kpiMaxValue): alarm = True elif ( not inRange and kpiMinValue is not None and kpiMaxValue is not None and not includeMinValue and not includeMaxValue): elif (not inRange and not kpiMinIsNone and not kpiMaxIsNone and not includeMinValue and not includeMaxValue): if (kpi_value < kpiMinValue or kpi_value > kpiMaxValue): alarm = True elif (inRange and kpiMinValue is not None and kpiMaxValue is None and includeMinValue): elif (inRange and not kpiMinIsNone and kpiMaxIsNone and includeMinValue): if (kpi_value >= kpiMinValue): alarm = True elif (inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): elif (inRange and not kpiMinIsNone and kpiMaxIsNone and not includeMinValue): if (kpi_value > kpiMinValue): alarm = True elif (not inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): elif (not inRange and not kpiMinIsNone and kpiMaxIsNone and includeMinValue): if (kpi_value <= kpiMinValue): alarm = True elif (not inRange and kpiMinValue is not None and kpiMaxValue is None and not includeMinValue): if (kpi_value <= kpiMinValue): elif (not inRange and not kpiMinIsNone and kpiMaxIsNone and not includeMinValue): if (kpi_value < kpiMinValue): alarm = True elif (inRange and kpiMinValue is None and kpiMaxValue is not None and includeMaxValue): elif (inRange and kpiMinIsNone and not kpiMaxIsNone and includeMaxValue): if (kpi_value <= kpiMaxValue): alarm = True elif (inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): elif (inRange and kpiMinIsNone and not kpiMaxIsNone and not includeMaxValue): if (kpi_value < kpiMaxValue): alarm = True elif (not inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): elif (not inRange and kpiMinIsNone and not kpiMaxIsNone and includeMaxValue): if (kpi_value >= kpiMaxValue): alarm = True elif (not inRange and kpiMinValue is None and kpiMaxValue is not None and not includeMaxValue): if (kpi_value >= kpiMaxValue): elif (not inRange and kpiMinIsNone and not kpiMaxIsNone and not includeMaxValue): if (kpi_value > kpiMaxValue): alarm = True if alarm: valid_kpi_list.append(kpi) if valid_kpi_list: alarm_queue.put_nowait(valid_kpi_list) LOGGER.debug(f"Alarm of KPI {kpi_id} triggered -> kpi_value:{kpi[2]}, timestamp:{kpi[1]}") else: LOGGER.debug(f"No new alarms triggered for the alarm of KPI {kpi_id}") else: LOGGER.debug(f"No new data for the alarm of KPI {kpi_id}") except (Exception) as e: Loading