From aae839f921b97c56c4f2d9804870ac0b470d0e06 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Thu, 27 Feb 2025 15:04:25 +0800 Subject: [PATCH] fix: Adjust the container task log (#8025) --- agent/app/service/container.go | 5 +---- frontend/src/views/terminal/host/operate/index.vue | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/agent/app/service/container.go b/agent/app/service/container.go index d65b9ca9d..7d920ca9f 100644 --- a/agent/app/service/container.go +++ b/agent/app/service/container.go @@ -11,7 +11,6 @@ import ( "net/url" "os" "os/exec" - "path" "path/filepath" "sort" "strconv" @@ -343,8 +342,7 @@ func (u *ContainerService) ContainerCreateByCommand(req dto.ContainerCreateByCom } go func() { taskItem.AddSubTask(i18n.GetWithName("ContainerCreate", containerName), func(t *task.Task) error { - logPath := path.Join(global.Dir.LogDir, task.TaskScopeContainer, req.TaskID+".log") - return cmd.ExecShell(logPath, 5*time.Minute, "bash", "-c", req.Command) + return cmd.ExecShellWithTask(taskItem, 5*time.Minute, "bash", "-c", req.Command) }, nil) _ = taskItem.Execute() }() @@ -507,7 +505,6 @@ func (u *ContainerService) ContainerCreate(req dto.ContainerOperate) error { return err } con, err := client.ContainerCreate(ctx, config, hostConf, networkConf, &v1.Platform{}, req.Name) - taskItem.LogWithStatus(i18n.GetMsgByKey("ContainerCreate"), err) if err != nil { taskItem.Log(i18n.GetMsgByKey("ContainerCreateFailed")) _ = client.ContainerRemove(ctx, req.Name, container.RemoveOptions{RemoveVolumes: true, Force: true}) diff --git a/frontend/src/views/terminal/host/operate/index.vue b/frontend/src/views/terminal/host/operate/index.vue index cdaf7ae6c..cb06a9e3b 100644 --- a/frontend/src/views/terminal/host/operate/index.vue +++ b/frontend/src/views/terminal/host/operate/index.vue @@ -129,7 +129,7 @@ const rules = reactive({ name: [{ validator: checkName, trigger: 'blur' }], }); function checkName(rule: any, value: any, callback: any) { - if (value === 'local') { + if (value === 'local' && dialogData.value.title !== 'edit') { return callback(new Error(i18n.global.t('terminal.localHelper'))); } callback();