support update enableWhiteList dynamicly

This commit is contained in:
Yihao Deng 2024-06-11 07:16:23 +00:00
parent 539543b011
commit 8a6d58d339
2 changed files with 113 additions and 112 deletions

View File

@ -776,7 +776,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
// min free disk space used to check if the disk is full [50MB, 1GB] // min free disk space used to check if the disk is full [50MB, 1GB]
if (cfgAddInt64(pCfg, "minDiskFreeSize", tsMinDiskFreeSize, TFS_MIN_DISK_FREE_SIZE, 1024 * 1024 * 1024, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; if (cfgAddInt64(pCfg, "minDiskFreeSize", tsMinDiskFreeSize, TFS_MIN_DISK_FREE_SIZE, 1024 * 1024 * 1024, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1;
if (cfgAddBool(pCfg, "enableWhiteList", tsEnableWhiteList, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; if (cfgAddBool(pCfg, "enableWhiteList", tsEnableWhiteList, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1;
// clang-format on // clang-format on
@ -1299,8 +1299,8 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi
return 0; return 0;
} }
int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, int32_t taosReadDataFolder(const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl,
const char *envFile, char *apolloUrl, SArray *pArgs) { SArray *pArgs) {
if (tsCfg == NULL) osDefaultInit(); if (tsCfg == NULL) osDefaultInit();
SConfig *pCfg = cfgInit(); SConfig *pCfg = cfgInit();

View File

@ -14,9 +14,8 @@
*/ */
#define _DEFAULT_SOURCE #define _DEFAULT_SOURCE
#include <stdio.h>
#include "tjson.h"
#include "mndDnode.h" #include "mndDnode.h"
#include <stdio.h>
#include "audit.h" #include "audit.h"
#include "mndCluster.h" #include "mndCluster.h"
#include "mndDb.h" #include "mndDb.h"
@ -28,9 +27,10 @@
#include "mndTrans.h" #include "mndTrans.h"
#include "mndUser.h" #include "mndUser.h"
#include "mndVgroup.h" #include "mndVgroup.h"
#include "taos_monitor.h"
#include "tjson.h"
#include "tmisce.h" #include "tmisce.h"
#include "tunit.h" #include "tunit.h"
#include "taos_monitor.h"
#define TSDB_DNODE_VER_NUMBER 2 #define TSDB_DNODE_VER_NUMBER 2
#define TSDB_DNODE_RESERVE_SIZE 40 #define TSDB_DNODE_RESERVE_SIZE 40
@ -536,49 +536,49 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
int32_t code = -1; int32_t code = -1;
char strClusterId[TSDB_CLUSTER_ID_LEN] = {0}; char strClusterId[TSDB_CLUSTER_ID_LEN] = {0};
sprintf(strClusterId, "%"PRId64, pMnode->clusterId); sprintf(strClusterId, "%" PRId64, pMnode->clusterId);
if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) { if (tDeserializeSStatisReq(pReq->pCont, pReq->contLen, &statisReq) != 0) {
terrno = TSDB_CODE_INVALID_MSG; terrno = TSDB_CODE_INVALID_MSG;
return code; return code;
} }
if(tsMonitorLogProtocol){ if (tsMonitorLogProtocol) {
mInfo("process statis req,\n %s", statisReq.pCont); mInfo("process statis req,\n %s", statisReq.pCont);
} }
SJson* pJson = tjsonParse(statisReq.pCont); SJson *pJson = tjsonParse(statisReq.pCont);
int32_t ts_size = tjsonGetArraySize(pJson); int32_t ts_size = tjsonGetArraySize(pJson);
for(int32_t i = 0; i < ts_size; i++){ for (int32_t i = 0; i < ts_size; i++) {
SJson* item = tjsonGetArrayItem(pJson, i); SJson *item = tjsonGetArrayItem(pJson, i);
SJson* tables = tjsonGetObjectItem(item, "tables"); SJson *tables = tjsonGetObjectItem(item, "tables");
int32_t tableSize = tjsonGetArraySize(tables); int32_t tableSize = tjsonGetArraySize(tables);
for(int32_t i = 0; i < tableSize; i++){ for (int32_t i = 0; i < tableSize; i++) {
SJson* table = tjsonGetArrayItem(tables, i); SJson *table = tjsonGetArrayItem(tables, i);
char tableName[MONITOR_TABLENAME_LEN] = {0}; char tableName[MONITOR_TABLENAME_LEN] = {0};
tjsonGetStringValue(table, "name", tableName); tjsonGetStringValue(table, "name", tableName);
SJson* metricGroups = tjsonGetObjectItem(table, "metric_groups"); SJson *metricGroups = tjsonGetObjectItem(table, "metric_groups");
int32_t size = tjsonGetArraySize(metricGroups); int32_t size = tjsonGetArraySize(metricGroups);
for(int32_t i = 0; i < size; i++){ for (int32_t i = 0; i < size; i++) {
SJson* item = tjsonGetArrayItem(metricGroups, i); SJson *item = tjsonGetArrayItem(metricGroups, i);
SJson* arrayTag = tjsonGetObjectItem(item, "tags"); SJson *arrayTag = tjsonGetObjectItem(item, "tags");
int32_t tagSize = tjsonGetArraySize(arrayTag); int32_t tagSize = tjsonGetArraySize(arrayTag);
for(int32_t j = 0; j < tagSize; j++){ for (int32_t j = 0; j < tagSize; j++) {
SJson* item = tjsonGetArrayItem(arrayTag, j); SJson *item = tjsonGetArrayItem(arrayTag, j);
char tagName[MONITOR_TAG_NAME_LEN] = {0}; char tagName[MONITOR_TAG_NAME_LEN] = {0};
tjsonGetStringValue(item, "name", tagName); tjsonGetStringValue(item, "name", tagName);
if(strncmp(tagName, "cluster_id", MONITOR_TAG_NAME_LEN) == 0) { if (strncmp(tagName, "cluster_id", MONITOR_TAG_NAME_LEN) == 0) {
tjsonDeleteItemFromObject(item, "value"); tjsonDeleteItemFromObject(item, "value");
tjsonAddStringToObject(item, "value", strClusterId); tjsonAddStringToObject(item, "value", strClusterId);
} }
@ -590,12 +590,12 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
char *pCont = tjsonToString(pJson); char *pCont = tjsonToString(pJson);
monSendContent(pCont); monSendContent(pCont);
if(pJson != NULL){ if (pJson != NULL) {
tjsonDelete(pJson); tjsonDelete(pJson);
pJson = NULL; pJson = NULL;
} }
if(pCont != NULL){ if (pCont != NULL) {
taosMemoryFree(pCont); taosMemoryFree(pCont);
pCont = NULL; pCont = NULL;
} }
@ -603,7 +603,7 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
tFreeSStatisReq(&statisReq); tFreeSStatisReq(&statisReq);
return 0; return 0;
/* /*
SJson* pJson = tjsonParse(statisReq.pCont); SJson* pJson = tjsonParse(statisReq.pCont);
int32_t ts_size = tjsonGetArraySize(pJson); int32_t ts_size = tjsonGetArraySize(pJson);
@ -720,7 +720,7 @@ static int32_t mndProcessStatisReq(SRpcMsg *pReq) {
code = 0; code = 0;
_OVER: _OVER:
if(pJson != NULL){ if(pJson != NULL){
tjsonDelete(pJson); tjsonDelete(pJson);
pJson = NULL; pJson = NULL;
@ -816,8 +816,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
bool reboot = (pDnode->rebootTime != statusReq.rebootTime); bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes; bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
bool encryptKeyChanged = pDnode->encryptionKeyChksum != statusReq.clusterCfg.encryptionKeyChksum; bool encryptKeyChanged = pDnode->encryptionKeyChksum != statusReq.clusterCfg.encryptionKeyChksum;
bool enableWhiteListChanged = statusReq.clusterCfg.enableWhiteList != (tsEnableWhiteList ? 1 : 0);
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged || bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged ||
pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged; pMnode->ipWhiteVer != statusReq.ipWhiteVer || encryptKeyChanged || enableWhiteListChanged;
const STraceId *trace = &pReq->info.traceId; const STraceId *trace = &pReq->info.traceId;
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id, mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,