From ca9c0ad282e0b5d9ad7441906e2abf10442f94c1 Mon Sep 17 00:00:00 2001 From: Bomin Zhang Date: Mon, 3 Aug 2020 11:31:14 +0800 Subject: [PATCH] TD-1033: enable telemetry reporting by default disable telemetry reporting in test. fix other telemetry related bugs. --- src/common/src/tglobal.c | 2 +- src/dnode/src/dnodeTelemetry.c | 10 +++++----- src/os/src/detail/osSysinfo.c | 6 +++++- tests/pytest/util/dnodes.py | 1 + tests/script/sh/deploy.sh | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 9528d3705c..c3dc078428 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -40,7 +40,7 @@ uint16_t tsSyncPort = 6040; int32_t tsStatusInterval = 1; // second int32_t tsNumOfMnodes = 3; int32_t tsEnableVnodeBak = 1; -int32_t tsEnableTelemetryReporting = 0; +int32_t tsEnableTelemetryReporting = 1; // common int32_t tsRpcTimer = 1000; diff --git a/src/dnode/src/dnodeTelemetry.c b/src/dnode/src/dnodeTelemetry.c index 356aebd654..60277a275a 100644 --- a/src/dnode/src/dnodeTelemetry.c +++ b/src/dnode/src/dnodeTelemetry.c @@ -174,7 +174,6 @@ static void addVersionInfo(SBufferWriter* bw) { } static void addRuntimeInfo(SBufferWriter* bw) { - addStringField(bw, "clusterId", mnodeGetClusterId()); // addIntField(&bw, "numOfDnode", 1); // addIntField(&bw, "numOfVnode", 1); // addIntField(&bw, "numOfStable", 1); @@ -189,17 +188,18 @@ static void sendTelemetryReport() { char buf[128]; uint32_t ip = taosGetIpFromFqdn(TELEMETRY_SERVER); if (ip == 0xffffffff) { - dError("failed to get IP address of " TELEMETRY_SERVER ", reason:%s", strerror(errno)); + dTrace("failed to get IP address of " TELEMETRY_SERVER ", reason:%s", strerror(errno)); return; } int fd = taosOpenTcpClientSocket(ip, TELEMETRY_PORT, 0); if (fd < 0) { - dError("failed to create socket for telemetry, reason:%s", strerror(errno)); + dTrace("failed to create socket for telemetry, reason:%s", strerror(errno)); return; } SBufferWriter bw = tbufInitWriter(NULL, false); beginObject(&bw); + addStringField(&bw, "instanceId", mnodeGetClusterId()); addIntField(&bw, "reportVersion", 1); addOsInfo(&bw); addCpuInfo(&bw); @@ -254,7 +254,7 @@ int32_t dnodeInitTelemetry() { if (sem_init(&tsExitSem, 0, 0) == -1) { // just log the error, it is ok for telemetry to fail - dError("failed to create semaphore for telemetry, reason:%s", strerror(errno)); + dTrace("failed to create semaphore for telemetry, reason:%s", strerror(errno)); return 0; } @@ -265,7 +265,7 @@ int32_t dnodeInitTelemetry() { int32_t code = pthread_create(&tsTelemetryThread, &attr, telemetryThread, NULL); pthread_attr_destroy(&attr); if (code != 0) { - dError("failed to create telemetry thread, reason:%s", strerror(errno)); + dTrace("failed to create telemetry thread, reason:%s", strerror(errno)); } return 0; diff --git a/src/os/src/detail/osSysinfo.c b/src/os/src/detail/osSysinfo.c index 9703d26ec4..7c01239490 100644 --- a/src/os/src/detail/osSysinfo.c +++ b/src/os/src/detail/osSysinfo.c @@ -651,7 +651,11 @@ bool taosGetSystemUid(char *uid) { close(fd); } - return len > 0; + if (len >= 36) { + uid[36] = 0; + return true; + } + return false; } #endif \ No newline at end of file diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 2e7732ea4f..1ac492bb3a 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -39,6 +39,7 @@ class TDSimClient: "udebugFlag": "135", "jnidebugFlag": "135", "qdebugFlag": "135", + "telemetryReporting": "0", } def init(self, path): self.__init__() diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 1a0d667f88..841dfcce95 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -147,6 +147,6 @@ echo "asyncLog 0" >> $TAOS_CFG echo "numOfMnodes 1" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG echo "fsync 0" >> $TAOS_CFG -echo "tsEnableTelemetryReporting 0" >> $TAOS_CFG +echo "telemetryReporting 0" >> $TAOS_CFG echo " " >> $TAOS_CFG -- GitLab