Skip to content

Commit 6b04457

Browse files
authored
fix: Fix scheduled task execution exceptions (#8030)
1 parent 9a597ad commit 6b04457

File tree

7 files changed

+27
-17
lines changed

7 files changed

+27
-17
lines changed

agent/app/service/cronjob.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ func (u *CronjobService) Delete(req dto.CronjobBatchDelete) error {
273273
if cronjob.ID == 0 {
274274
return errors.New("find cronjob in db failed")
275275
}
276+
_ = os.RemoveAll(path.Join(global.Dir.DataDir, "task/shell", cronjob.Name))
276277
ids := strings.Split(cronjob.EntryIDs, ",")
277278
for _, id := range ids {
278279
idItem, _ := strconv.Atoi(id)

agent/app/service/cronjob_helper.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ func (u *CronjobService) handleShell(cronjob model.Cronjob, taskID string) error
9797
if len(cronjob.Command) != 0 {
9898
command = cronjob.Command
9999
}
100-
scriptFile, _ := os.ReadFile(cronjob.Script)
101-
return cmd.ExecShellWithTask(taskItem, 24*time.Hour, "docker", "exec", cronjob.ContainerName, command, "-c", strings.ReplaceAll(string(scriptFile), "\"", "\\\""))
100+
return cmd.ExecShellWithTask(taskItem, 24*time.Hour, "docker", "exec", cronjob.ContainerName, command, "-c", strings.ReplaceAll(cronjob.Script, "\"", "\\\""))
102101
}
103102
if len(cronjob.Executor) == 0 {
104103
cronjob.Executor = "bash"

core/constant/common.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,17 @@ var WebUrlMap = map[string]struct{}{
5151
"/ai/model": {},
5252
"/ai/gpu": {},
5353

54-
"/containers": {},
55-
"/containers/container": {},
56-
"/containers/image": {},
57-
"/containers/network": {},
58-
"/containers/volume": {},
59-
"/containers/repo": {},
60-
"/containers/compose": {},
61-
"/containers/template": {},
62-
"/containers/setting": {},
63-
"/containers/dashboard": {},
54+
"/containers": {},
55+
"/containers/container": {},
56+
"containers/container/operate": {},
57+
"/containers/image": {},
58+
"/containers/network": {},
59+
"/containers/volume": {},
60+
"/containers/repo": {},
61+
"/containers/compose": {},
62+
"/containers/template": {},
63+
"/containers/setting": {},
64+
"/containers/dashboard": {},
6465

6566
"/cronjobs": {},
6667

frontend/src/components/complex-table/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
:page-sizes="[5, 10, 20, 50, 100]"
3131
@size-change="sizeChange"
3232
@current-change="currentChange"
33-
:small="mobile"
33+
:small="mobile || paginationConfig.small"
3434
:layout="mobile ? 'total, prev, pager, next' : 'total, sizes, prev, pager, next, jumper'"
3535
/>
3636
</slot>

frontend/src/components/task-list/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const paginationConfig = reactive({
6262
currentPage: 1,
6363
pageSize: 10,
6464
total: 0,
65+
small: true,
6566
});
6667
const taskLogRef = ref();
6768
const req = reactive({

frontend/src/layout/components/Sidebar/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929
<el-button link icon="CircleCheck" type="success" />
3030
{{ $t('terminal.local') }}
3131
</el-dropdown-item>
32-
<el-dropdown-item v-for="item in nodes" :key="item.name" :command="item.name">
32+
<el-dropdown-item
33+
:disabled="item.status !== 'Healthy'"
34+
v-for="item in nodes"
35+
:key="item.name"
36+
:command="item.name"
37+
>
3338
<el-button v-if="item.status === 'Healthy'" link icon="CircleCheck" type="success" />
3439
<el-button v-else link icon="Warning" type="danger" />
3540
{{ item.name }}

frontend/src/views/cronjob/operate/index.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,10 @@
271271
</el-card>
272272

273273
<el-form-item :label="$t('cronjob.shellContent')" prop="script" class="mt-5">
274-
<el-radio-group v-model="dialogData.rowData!.scriptMode">
274+
<el-radio-group
275+
@change="dialogData.rowData!.script = ''"
276+
v-model="dialogData.rowData!.scriptMode"
277+
>
275278
<el-radio value="input">{{ $t('commons.button.edit') }}</el-radio>
276279
<el-radio value="select">{{ $t('container.pathSelect') }}</el-radio>
277280
</el-radio-group>
@@ -280,8 +283,7 @@
280283
v-model="dialogData.rowData!.script"
281284
placeholder="#Define or paste the content of your shell file here"
282285
mode="javascript"
283-
:heightDiff="0"
284-
:min-height="200"
286+
:heightDiff="400"
285287
/>
286288
<el-input
287289
v-if="dialogData.rowData!.scriptMode=== 'select'"
@@ -792,6 +794,7 @@ const rules = reactive({
792794
],
793795
794796
script: [{ validator: verifyScript, trigger: 'blur', required: true }],
797+
containerName: [Rules.requiredSelect],
795798
appID: [Rules.requiredSelect],
796799
website: [Rules.requiredSelect],
797800
dbName: [Rules.requiredSelect],

0 commit comments

Comments
 (0)