refactor(lcnode): hybrid cloud admin lcnode auditlog #22675357 #22680253

Signed-off-by: zhaochenyang <zhaochenyang@oppo.com>
This commit is contained in:
zhaochenyang 2024-10-12 10:31:42 +08:00 committed by AmazingChi
parent 18cbae3922
commit 0eb8f4127d
4 changed files with 18 additions and 16 deletions

View File

@ -123,7 +123,7 @@ func (l *LcNode) parseConfig(cfg *config.Config) (err error) {
return
}
l.listen = listen
log.LogInfof("loadConfig: setup config: %v(%v)", configListen, listen)
log.LogWarnf("loadConfig: setup config: %v(%v)", configListen, listen)
var listenInt int
if listenInt, err = strconv.Atoi(listen); err != nil {
@ -131,14 +131,14 @@ func (l *LcNode) parseConfig(cfg *config.Config) (err error) {
return
}
l.httpListen = strconv.Itoa(listenInt + 1)
log.LogInfof("loadConfig: setup config: httpListen(%v)", l.httpListen)
log.LogWarnf("loadConfig: setup config: httpListen(%v)", l.httpListen)
// parse master config
masters := cfg.GetStringSlice(configMasterAddr)
if len(masters) == 0 {
return config.NewIllegalConfigError(configMasterAddr)
}
log.LogInfof("loadConfig: setup config: %v(%v)", configMasterAddr, strings.Join(masters, ","))
log.LogWarnf("loadConfig: setup config: %v(%v)", configMasterAddr, strings.Join(masters, ","))
l.masters = masters
l.mc = master.NewMasterClient(masters, false)
@ -147,28 +147,28 @@ func (l *LcNode) parseConfig(cfg *config.Config) (err error) {
if scanCheckInterval <= 0 {
scanCheckInterval = defaultScanCheckInterval
}
log.LogInfof("loadConfig: setup config: %v(%v)", configScanCheckIntervalStr, scanCheckInterval)
log.LogWarnf("loadConfig: setup config: %v(%v)", configScanCheckIntervalStr, scanCheckInterval)
// parse lcScanRoutineNumPerTask
lcScanRoutineNumPerTask = cfg.GetInt(configLcScanRoutineNumPerTaskStr)
if lcScanRoutineNumPerTask <= 0 || lcScanRoutineNumPerTask > maxLcScanRoutineNumPerTask {
lcScanRoutineNumPerTask = defaultLcScanRoutineNumPerTask
}
log.LogInfof("loadConfig: setup config: %v(%v)", configLcScanRoutineNumPerTaskStr, lcScanRoutineNumPerTask)
log.LogWarnf("loadConfig: setup config: %v(%v)", configLcScanRoutineNumPerTaskStr, lcScanRoutineNumPerTask)
// parse simpleQueueInitCapacity
simpleQueueInitCapacity = cfg.GetInt(configSimpleQueueInitCapacityStr)
if simpleQueueInitCapacity <= lcScanRoutineNumPerTask*1000 {
simpleQueueInitCapacity = defaultSimpleQueueInitCapacity
}
log.LogInfof("loadConfig: setup config: %v(%v)", configSimpleQueueInitCapacityStr, simpleQueueInitCapacity)
log.LogWarnf("loadConfig: setup config: %v(%v)", configSimpleQueueInitCapacityStr, simpleQueueInitCapacity)
// parse snapshotRoutineNumPerTask
snapshotRoutineNumPerTask = cfg.GetInt(configSnapshotRoutineNumPerTaskStr)
if snapshotRoutineNumPerTask <= 0 || snapshotRoutineNumPerTask > maxLcScanRoutineNumPerTask {
snapshotRoutineNumPerTask = defaultLcScanRoutineNumPerTask
}
log.LogInfof("loadConfig: setup config: %v(%v)", configSnapshotRoutineNumPerTaskStr, snapshotRoutineNumPerTask)
log.LogWarnf("loadConfig: setup config: %v(%v)", configSnapshotRoutineNumPerTaskStr, snapshotRoutineNumPerTask)
// parse lcScanLimitPerSecond
limitNum := cfg.GetInt64(configLcScanLimitPerSecondStr)
@ -177,7 +177,7 @@ func (l *LcNode) parseConfig(cfg *config.Config) (err error) {
} else {
lcScanLimitPerSecond = rate.Limit(limitNum)
}
log.LogInfof("loadConfig: setup config: %v(%v)", configLcScanLimitPerSecondStr, lcScanLimitPerSecond)
log.LogWarnf("loadConfig: setup config: %v(%v)", configLcScanLimitPerSecondStr, lcScanLimitPerSecond)
// parse lcNodeTaskCount
count := cfg.GetInt(configLcNodeTaskCountLimit)
@ -186,7 +186,7 @@ func (l *LcNode) parseConfig(cfg *config.Config) (err error) {
} else {
lcNodeTaskCountLimit = count
}
log.LogInfof("loadConfig: setup config: %v(%v)", configLcNodeTaskCountLimit, lcNodeTaskCountLimit)
log.LogWarnf("loadConfig: setup config: %v(%v)", configLcNodeTaskCountLimit, lcNodeTaskCountLimit)
// parse delayDelMinute
delay := cfg.GetInt64(configDelayDelMinute)
@ -195,11 +195,11 @@ func (l *LcNode) parseConfig(cfg *config.Config) (err error) {
} else {
delayDelMinute = uint64(delay)
}
log.LogInfof("loadConfig: setup config: %v(%v)", configDelayDelMinute, delayDelMinute)
log.LogWarnf("loadConfig: setup config: %v(%v)", configDelayDelMinute, delayDelMinute)
// parse useCreateTime
useCreateTime = cfg.GetBool(configUseCreateTime)
log.LogInfof("loadConfig: setup config: %v(%v)", configUseCreateTime, useCreateTime)
log.LogWarnf("loadConfig: setup config: %v(%v)", configUseCreateTime, useCreateTime)
stream.SetExentRetryArgs(defaultAllocRetryInterval, defaultWriteRetryInterval, defaultExtenthandlerMaxRetryMin, true)

View File

@ -7158,7 +7158,9 @@ func (m *Server) adminLcNode(w http.ResponseWriter, r *http.Request) {
vol := r.FormValue("vol")
rid := r.FormValue("ruleid")
done := r.FormValue("done")
if rsp, err := m.cluster.getAllLcNodeInfo(vol, rid, done); err != nil {
rsp, err := m.cluster.getAllLcNodeInfo(vol, rid, done)
auditlog.LogMasterOp("AdminLcNode", fmt.Sprintf("op(info), vol(%v), ruleid(%v), done(%v)", vol, rid, done), err)
if err != nil {
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: err.Error()})
} else {
sendOkReply(w, r, newSuccessHTTPReply(rsp))
@ -7171,6 +7173,7 @@ func (m *Server) adminLcNode(w http.ResponseWriter, r *http.Request) {
vol := r.FormValue("vol")
rid := r.FormValue("ruleid")
success, msg := m.cluster.lcMgr.startLcScan(vol, rid)
auditlog.LogMasterOp("AdminLcNode", fmt.Sprintf("op(start), vol(%v), ruleid(%v), msg: %v", vol, rid, msg), nil)
if !success {
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: msg})
} else {
@ -7184,6 +7187,7 @@ func (m *Server) adminLcNode(w http.ResponseWriter, r *http.Request) {
vol := r.FormValue("vol")
rid := r.FormValue("ruleid")
success, msg := m.cluster.lcMgr.stopLcScan(vol, rid)
auditlog.LogMasterOp("AdminLcNode", fmt.Sprintf("op(stop), vol(%v), ruleid(%v), msg: %v", vol, rid, msg), nil)
if !success {
sendErrReply(w, r, &proto.HTTPReply{Code: proto.ErrCodeParamError, Msg: msg})
} else {

View File

@ -197,8 +197,6 @@ func (lcMgr *lifecycleManager) startLcScan(vol, rid string) (success bool, msg s
success = true
msg = fmt.Sprintf("startLcScan success: no lifecycle task to start, task(%v) now todo or doing", taskSkip)
log.LogInfo(msg)
end := time.Now()
lcMgr.lcRuleTaskStatus.EndTime = &end
return
}

View File

@ -153,7 +153,7 @@ func (c *Cluster) handleLcNodeLcScanResp(nodeAddr string, resp *proto.LcNodeRule
log.LogWarnf("action[handleLcNodeLcScanResp] syncAddLcResult %v err(%v)", resp, e)
}
msg := fmt.Sprintf("scanning failed: %+v", resp)
auditlog.LogMasterOp("handleLcNodeLcScanResp", msg, nil)
auditlog.LogMasterOp("HandleLcNodeLcScanResp", msg, nil)
return
case proto.TaskSucceeds:
c.lcMgr.lcRuleTaskStatus.AddResult(resp)
@ -162,7 +162,7 @@ func (c *Cluster) handleLcNodeLcScanResp(nodeAddr string, resp *proto.LcNodeRule
log.LogWarnf("action[handleLcNodeLcScanResp] syncAddLcResult %v err(%v)", resp, e)
}
msg := fmt.Sprintf("scanning completed: %+v", resp)
auditlog.LogMasterOp("handleLcNodeLcScanResp", msg, nil)
auditlog.LogMasterOp("HandleLcNodeLcScanResp", msg, nil)
return
default:
log.LogInfof("action[handleLcNodeLcScanResp] scanning received, resp(%v)", resp)