fix: use panel Python common catalog and track install jobs

This commit is contained in:
canglan committed 2026-10-30 15:20:49 +08:00
1 parent 248badd33e
commit d7c007adc4
12 files changed
+202 -22

No files matched your search

@@ -57,9 +57,14 @@ func (s *Projects) InstallRuntimeEnvironment(ctx context.Context, name, version
if s.store == nil {
return s.installRuntimeEnvironmentLegacy(ctx, name, version)
}
_, err := s.SubmitRuntimeInstallation(ctx, name, version)
return err
}
func (s *Projects) SubmitRuntimeInstallation(ctx context.Context, name, version string) (uint64, error) {
items, err := s.panel.RuntimeEnvironments(ctx)
if err != nil {
return err
return 0, err
}
allowed := false
for _, item := range items {
@@ -68,10 +73,9 @@ func (s *Projects) InstallRuntimeEnvironment(ctx context.Context, name, version
}
}
if !allowed {
return errors.New("请选择清单中尚未安装的运行环境版本")
return 0, errors.New("请选择清单中尚未安装的运行环境版本")
}
_, err = s.store.CreateRuntimeJob(ctx, store.RuntimeJob{Action: "install", Runtime: name, TargetVersion: version})
return err
return s.store.CreateRuntimeJob(ctx, store.RuntimeJob{Action: "install", Runtime: name, TargetVersion: version})
}
func (s *Projects) SubmitPHPPatch(ctx context.Context, branch, target string) (uint64, error) {
items, err := s.panel.RuntimeEnvironments(ctx)
@@ -232,6 +236,7 @@ func (s *Projects) executeRuntimeJob(parent context.Context, job store.RuntimeJo
}
if err == nil && !installed && !installing {
if job.Runtime == "Python" {
slog.Info("installing Python from verified source", "job_id", job.ID, "node_id", job.NodeID, "version", job.TargetVersion)
err = s.isolation.InstallPythonRuntime(ctx, job.TargetVersion)
} else {
err = s.panel.InstallRuntimeEnvironment(ctx, job.Runtime, job.TargetVersion)
@@ -268,7 +273,11 @@ func (s *Projects) executeRuntimeJob(parent context.Context, job store.RuntimeJo
_ = s.store.EnqueueAdminNotification(finishCtx, "critical", "runtime", "运行环境维护失败", fmt.Sprintf("任务 #%d %s %s:%v", job.ID, job.Runtime, job.TargetVersion, err))
return
}
_ = s.store.UpdateRuntimeJob(finishCtx, job.ID, "completed", "verified", "目标版本已核验;原本停止的站点保持停止,待启动后核验进程")
message := "目标版本已核验;原本停止的站点保持停止,待启动后核验进程"
if job.Action == "install" {
message = job.Runtime + " " + job.TargetVersion + " 已安装并核验"
}
_ = s.store.UpdateRuntimeJob(finishCtx, job.ID, "completed", "verified", message)
}
// Coordinate with host identity changes and unfinished site switches, not