fix(reliability): 采集器并发去重 + 备份恢复即时重载 + context 贯穿请求链
- CollectorService 安装/卸载按采集器互斥去重(重复触发不再并发 docker rm/run 互踩);删除后卸载失败留日志 - ApplyStagedBackup 替换文件后立即 Reload 内存态,消除「重启前旧内存落盘覆盖恢复文件」竞态;暂存文件名升级 lokistack.json(兼容旧名) - GetUsage/Validate 全链路 context 贯穿:请求取消即中止 SSH/k8s 查询(异步调用点显式 Background)
This commit is contained in:
1 parent
9daaf7f403
commit
572efc89a4
9 files changed
+180
-29
No files matched your search
@@ -88,7 +88,7 @@ func (s *HostService) Create(name, hostIP string, port int, user, authType, pass
|
||||
db.Unlock()
|
||||
db.RequestSave()
|
||||
|
||||
go s.Validate(host.ID)
|
||||
go s.Validate(context.Background(), host.ID)
|
||||
return &host, nil
|
||||
}
|
||||
|
||||
@@ -194,12 +194,12 @@ func (s *HostService) Delete(id uint) error {
|
||||
return utils.ErrNotFound
|
||||
}
|
||||
|
||||
func (s *HostService) Validate(id uint) {
|
||||
func (s *HostService) Validate(ctx context.Context, id uint) {
|
||||
host, err := s.Get(id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||
ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
|
||||
defer cancel()
|
||||
|
||||
client, err := NewSSHClientWithAuth(HostSSHAuth(host))
|
||||
|
||||
Reference in new issue
Block a user