enh: support display unlimited for expiration time

This commit is contained in:
kailixu 2024-06-19 09:38:55 +08:00
parent 1cdb726f2d
commit c3abd9d554
5 changed files with 24 additions and 7 deletions

View File

@ -29,6 +29,7 @@ extern "C" {
#endif
#define GRANT_HEART_BEAT_MIN 2
#define GRANT_UNIQ_UNLIMITED (-1)
#define GRANT_ACTIVE_CODE "activeCode"
#define GRANT_FLAG_ALL (0x01)
#define GRANT_FLAG_AUDIT (0x02)

View File

@ -85,7 +85,7 @@ static const SSysDbTableSchema clusterSchema[] = {
{.name = "uptime", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
{.name = "version", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
{.name = "expire_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
{.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
};
static const SSysDbTableSchema userDBSchema[] = {

View File

@ -100,7 +100,7 @@ typedef struct {
} SSyncMgmt;
typedef struct {
int64_t expireTimeMS;
int64_t expireTimeSec;
int64_t timeseriesAllowed;
} SGrantInfo;

View File

@ -310,11 +310,25 @@ static int32_t mndRetrieveClusters(SRpcMsg *pMsg, SShowObj *pShow, SSDataBlock *
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataSetVal(pColInfo, numOfRows, (const char *)ver, false);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
char expireTime[25] = {0};
pColInfo = taosArrayGet(pBlock->pDataBlock, cols);
if (tsExpireTime <= 0) {
colDataSetNULL(pColInfo, numOfRows);
if (tsExpireTime == GRANT_UNIQ_UNLIMITED) {
STR_WITH_MAXSIZE_TO_VARSTR(expireTime, "unlimited", pShow->pMeta->pSchemas[cols].bytes);
colDataSetVal(pColInfo, numOfRows, expireTime, false);
} else {
colDataSetVal(pColInfo, numOfRows, (const char *)&tsExpireTime, false);
colDataSetNULL(pColInfo, numOfRows);
}
} else {
char ts[20] = {0};
struct tm ptm;
if (taosLocalTime(&tsExpireTime, &ptm, ts) != NULL) {
strftime(ts, 20, "%Y-%m-%d %H:%M:%S", &ptm);
} else {
ts[0] = 0;
}
STR_WITH_MAXSIZE_TO_VARSTR(expireTime, ts, pShow->pMeta->pSchemas[cols].bytes);
colDataSetVal(pColInfo, numOfRows, expireTime, false);
}
sdbRelease(pSdb, pCluster);

View File

@ -1028,9 +1028,11 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
}
// grant info
pGrantInfo->expire_time = (pMnode->grant.expireTimeMS - ms) / 1000;
pGrantInfo->expire_time = pMnode->grant.expireTimeSec == GRANT_UNIQ_UNLIMITED
? GRANT_UNIQ_UNLIMITED
: (pMnode->grant.expireTimeSec - ms / 1000);
pGrantInfo->timeseries_total = pMnode->grant.timeseriesAllowed;
if (pMnode->grant.expireTimeMS == 0) {
if (pMnode->grant.expireTimeSec == 0) {
pGrantInfo->expire_time = 0;
pGrantInfo->timeseries_total = 0;
}