Skip to content

Commit 39a045f

Browse files
authored
Merge pull request #459 from chaitin/feat/vm-idle-refresh-simplify
简化 VM 空闲刷新机制:统一由 control 流触发
2 parents 3fb23b9 + 936e6a5 commit 39a045f

File tree

10 files changed

+399
-325
lines changed

10 files changed

+399
-325
lines changed

backend/biz/host/handler/v1/internal.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ func NewInternalHostHandler(i *do.Injector) (*InternalHostHandler, error) {
7373
g.POST("/coding-config", web.BindHandler(h.GetCodingConfig))
7474
g.POST("/git-credential", web.BindHandler(h.GitCredential))
7575
g.GET("/vm/list", web.BaseHandler(h.VMList))
76-
g.POST("/vm/activity", web.BindHandler(h.VMActivity))
7776
g.POST("/task-stream-ips", web.BindHandler(h.GetTaskStreamIPs))
7877

7978
return h, nil
@@ -358,14 +357,6 @@ func (h *InternalHostHandler) VmReady(c *web.Context, req taskflow.VirtualMachin
358357
}
359358
}
360359

361-
go func() {
362-
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
363-
defer cancel()
364-
if err := h.hostUsecase.RefreshIdleTimers(ctx, vm.ID); err != nil {
365-
h.logger.With("error", err).ErrorContext(ctx, "failed to refresh idel timers")
366-
}
367-
}()
368-
369360
}
370361

371362
return c.Success(nil)
@@ -474,26 +465,6 @@ func (h *InternalHostHandler) GitCredential(c *web.Context, req taskflow.GitCred
474465
})
475466
}
476467

477-
// VMActivityReq VM 活动上报请求
478-
type VMActivityReq struct {
479-
VMID string `json:"vm_id"`
480-
LastActiveAt int64 `json:"last_active_at"`
481-
}
482-
483-
// VMActivity VM 活动回调,用于刷新空闲计时器
484-
func (h *InternalHostHandler) VMActivity(c *web.Context, req VMActivityReq) error {
485-
h.logger.With("req", req).DebugContext(c.Request().Context(), "vm activity req")
486-
487-
go func() {
488-
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
489-
defer cancel()
490-
if err := h.hostUsecase.RefreshIdleTimers(ctx, req.VMID); err != nil {
491-
h.logger.With("error", err).ErrorContext(ctx, "failed to refresh idel timers")
492-
}
493-
}()
494-
return c.Success(nil)
495-
}
496-
497468
// GetTaskStreamIPs 获取任务 WebSocket 连接的客户端 IP
498469
func (h *InternalHostHandler) GetTaskStreamIPs(c *web.Context, req taskflow.GetTaskStreamIPsReq) error {
499470
var ips []string

0 commit comments

Comments
 (0)