feat: user config dnode procedure
This commit is contained in:
parent
4e54dc09c5
commit
f99d193335
|
@ -329,7 +329,6 @@ typedef enum ENodeType {
|
|||
QUERY_NODE_RESUME_STREAM_STMT,
|
||||
QUERY_NODE_CREATE_VIEW_STMT,
|
||||
QUERY_NODE_DROP_VIEW_STMT,
|
||||
QUERY_NODE_CREATE_ENCRYPT_KEY_STMT,
|
||||
|
||||
// show statement nodes
|
||||
// see 'sysTableShowAdapter', 'SYSTABLE_SHOW_TYPE_OFFSET'
|
||||
|
|
|
@ -260,11 +260,6 @@ typedef struct SDropUserStmt {
|
|||
char userName[TSDB_USER_LEN];
|
||||
} SDropUserStmt;
|
||||
|
||||
typedef struct SCreateEncryptKeyStmt {
|
||||
ENodeType type;
|
||||
char value[TSDB_ENCRYPT_KEY_LEN + 1];
|
||||
} SCreateEncryptKeyStmt;
|
||||
|
||||
typedef struct SCreateDnodeStmt {
|
||||
ENodeType type;
|
||||
char fqdn[TSDB_FQDN_LEN];
|
||||
|
|
|
@ -474,7 +474,7 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, SDnodeObj *pDnode, const S
|
|||
return DND_REASON_ENCRYPTION_KEY_NOT_MATCH;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return DND_REASON_ONLINE;
|
||||
}
|
||||
|
||||
static bool mndUpdateVnodeState(int32_t vgId, SVnodeGid *pGid, SVnodeLoad *pVload) {
|
||||
|
@ -1405,6 +1405,40 @@ _err:
|
|||
return -1;
|
||||
}
|
||||
|
||||
static int32_t mndSendCreateEncryptKeyReq(SMnode *pMnode, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq) {
|
||||
int32_t code = -1;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
void *pIter = NULL;
|
||||
while (1) {
|
||||
SDnodeObj *pDnode = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
|
||||
if (pIter == NULL) break;
|
||||
if (pDnode->offlineReason != DND_REASON_ONLINE) continue;
|
||||
|
||||
if (pDnode->id == dnodeId || dnodeId == -1 || dnodeId == 0) {
|
||||
|
||||
SEpSet epSet = mndGetDnodeEpset(pDnode);
|
||||
int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, pDcfgReq);
|
||||
void *pBuf = rpcMallocCont(bufLen);
|
||||
|
||||
if (pBuf != NULL) {
|
||||
tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq);
|
||||
mInfo("dnode:%d, send config req to dnode, config:%s value:%s", dnodeId, pDcfgReq->config, pDcfgReq->value);
|
||||
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen};
|
||||
tmsgSendReq(&epSet, &rpcMsg);
|
||||
code = 0;
|
||||
}
|
||||
}
|
||||
|
||||
sdbRelease(pSdb, pDnode);
|
||||
}
|
||||
|
||||
if (code == -1) {
|
||||
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t mndSendCfgDnodeReq(SMnode *pMnode, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq) {
|
||||
int32_t code = -1;
|
||||
SSdb *pSdb = pMnode->pSdb;
|
||||
|
@ -1471,6 +1505,18 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
|
|||
|
||||
strcpy(dcfgReq.config, "s3blocksize");
|
||||
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
|
||||
} else if (strncasecmp(cfgReq.config, "encrypt_key", 12) == 0) {
|
||||
int32_t vlen = strlen(cfgReq.value);
|
||||
if (vlen > TSDB_ENCRYPT_KEY_LEN || vlen < 8) {
|
||||
mError("dnode:%d, failed to create encrypt_key since invalid vlen:%d, valid range:[%d, %d]", cfgReq.dnodeId,
|
||||
vlen, 8, TSDB_ENCRYPT_KEY_LEN);
|
||||
terrno = TSDB_CODE_INVALID_CFG;
|
||||
goto _err_out;
|
||||
}
|
||||
strcpy(dcfgReq.config, cfgReq.config);
|
||||
strcpy(dcfgReq.value, cfgReq.value);
|
||||
tFreeSMCfgDnodeReq(&cfgReq);
|
||||
return mndProcessCreateEncryptKeyReq(pMnode, cfgReq.dnodeId, &dcfgReq);
|
||||
#endif
|
||||
} else {
|
||||
if (mndMCfg2DCfg(&cfgReq, &dcfgReq)) goto _err_out;
|
||||
|
|
|
@ -486,8 +486,6 @@ SNode* nodesMakeNode(ENodeType type) {
|
|||
case QUERY_NODE_RESTORE_MNODE_STMT:
|
||||
case QUERY_NODE_RESTORE_VNODE_STMT:
|
||||
return makeNode(type, sizeof(SRestoreComponentNodeStmt));
|
||||
case QUERY_NODE_CREATE_ENCRYPT_KEY_STMT:
|
||||
return makeNode(type, sizeof(SCreateEncryptKeyStmt));
|
||||
case QUERY_NODE_CREATE_VIEW_STMT:
|
||||
return makeNode(type, sizeof(SCreateViewStmt));
|
||||
case QUERY_NODE_DROP_VIEW_STMT:
|
||||
|
|
|
@ -210,10 +210,10 @@ SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const ST
|
|||
SNode* addCreateUserStmtWhiteList(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pIpRangesNodeList);
|
||||
SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, void* pAlterInfo);
|
||||
SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
|
||||
SNode* createEncryptKeyStmt(SAstCreateContext* pCxt, const SToken* pValue);
|
||||
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort);
|
||||
SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, bool force, bool unsafe);
|
||||
SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue);
|
||||
SNode* createEncryptKeyStmt(SAstCreateContext* pCxt, const SToken* pValue);
|
||||
SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName);
|
||||
SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SNode* pIndexName,
|
||||
SNode* pRealTable, SNodeList* pCols, SNode* pOptions);
|
||||
|
|
|
@ -2096,16 +2096,6 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName) {
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createEncryptKeyStmt(SAstCreateContext* pCxt, const SToken* pValue) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SCreateEncryptKeyStmt* pStmt = (SCreateEncryptKeyStmt*)nodesMakeNode(QUERY_NODE_CREATE_ENCRYPT_KEY_STMT);
|
||||
CHECK_OUT_OF_MEM(pStmt);
|
||||
if (NULL != pValue) {
|
||||
trimString(pValue->z, pValue->n, pStmt->value, sizeof(pStmt->value));
|
||||
}
|
||||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
SCreateDnodeStmt* pStmt = (SCreateDnodeStmt*)nodesMakeNode(QUERY_NODE_CREATE_DNODE_STMT);
|
||||
|
@ -2151,6 +2141,14 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createEncryptKeyStmt(SAstCreateContext* pCxt, const SToken* pValue) {
|
||||
SToken config;
|
||||
config.type = TK_NK_STRING;
|
||||
config.z = "\"encrypt_key\"";
|
||||
config.n = strlen(config.z);
|
||||
return createAlterDnodeStmt(pCxt, NULL, &config, pValue);
|
||||
}
|
||||
|
||||
SNode* createRealTableNodeForIndexName(SAstCreateContext* pCxt, SToken* pDbName, SToken* pIndexName) {
|
||||
if (!checkIndexName(pCxt, pIndexName)) {
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue