diff --git a/frontend/providers/cronjob/deploy/Kubefile b/frontend/providers/cronjob/deploy/Kubefile index d1537f2f426..3dca0d3f3f4 100644 --- a/frontend/providers/cronjob/deploy/Kubefile +++ b/frontend/providers/cronjob/deploy/Kubefile @@ -9,4 +9,7 @@ ENV cloudDomain="127.0.0.1.nip.io" ENV cloudPort="" ENV certSecretName="wildcard-cert" +ENV SUCCESSFUL_JOBS_HISTORY_LIMIT="3" +ENV FAILED_JOBS_HISTORY_LIMIT="3" + CMD ["kubectl apply -f manifests"] diff --git a/frontend/providers/cronjob/deploy/manifests/deploy.yaml.tmpl b/frontend/providers/cronjob/deploy/manifests/deploy.yaml.tmpl index 2c00f4930d6..6b1cb420ece 100644 --- a/frontend/providers/cronjob/deploy/manifests/deploy.yaml.tmpl +++ b/frontend/providers/cronjob/deploy/manifests/deploy.yaml.tmpl @@ -41,6 +41,10 @@ spec: value: {{ .cloudDomain }} - name: APPLAUNCHPAD_URL value: applaunchpad.{{ .cloudDomain }} + - name: SUCCESSFUL_JOBS_HISTORY_LIMIT + value: "{{ .SUCCESSFUL_JOBS_HISTORY_LIMIT }}" + - name: FAILED_JOBS_HISTORY_LIMIT + value: "{{ .FAILED_JOBS_HISTORY_LIMIT }}" securityContext: runAsNonRoot: true runAsUser: 1001 diff --git a/frontend/providers/cronjob/src/pages/api/platform/getEnv.ts b/frontend/providers/cronjob/src/pages/api/platform/getEnv.ts index 7ca46baf7d5..2e8044e0795 100644 --- a/frontend/providers/cronjob/src/pages/api/platform/getEnv.ts +++ b/frontend/providers/cronjob/src/pages/api/platform/getEnv.ts @@ -6,13 +6,17 @@ import type { NextApiRequest, NextApiResponse } from 'next'; export type EnvResponse = { domain: string; applaunchpadUrl: string; + successfulJobsHistoryLimit: number; + failedJobsHistoryLimit: number; }; export default async function handler(req: NextApiRequest, res: NextApiResponse) { jsonRes(res, { data: { domain: process.env.SEALOS_DOMAIN || defaultDomain, - applaunchpadUrl: process.env.APPLAUNCHPAD_URL || `applaunchpad.${process.env.SEALOS_DOMAIN}` + applaunchpadUrl: process.env.APPLAUNCHPAD_URL || `applaunchpad.${process.env.SEALOS_DOMAIN}`, + successfulJobsHistoryLimit: Number(process.env.SUCCESSFUL_JOBS_HISTORY_LIMIT) || 3, + failedJobsHistoryLimit: Number(process.env.FAILED_JOBS_HISTORY_LIMIT) || 3 } }); } diff --git a/frontend/providers/cronjob/src/store/env.ts b/frontend/providers/cronjob/src/store/env.ts index 79197e489b1..82db7872dad 100644 --- a/frontend/providers/cronjob/src/store/env.ts +++ b/frontend/providers/cronjob/src/store/env.ts @@ -13,7 +13,9 @@ const useEnvStore = create()( immer((set, get) => ({ SystemEnv: { domain: '', - applaunchpadUrl: '' + applaunchpadUrl: '', + successfulJobsHistoryLimit: 3, + failedJobsHistoryLimit: 3 }, initSystemEnv: async () => { const data = await getPlatformEnv(); diff --git a/frontend/providers/cronjob/src/utils/json2Yaml.ts b/frontend/providers/cronjob/src/utils/json2Yaml.ts index 982ea8ce2de..191c8b4c400 100644 --- a/frontend/providers/cronjob/src/utils/json2Yaml.ts +++ b/frontend/providers/cronjob/src/utils/json2Yaml.ts @@ -8,7 +8,8 @@ import useEnvStore from '@/store/env'; export const json2CronJob = (data: CronJobEditType) => { const timeZone = getUserTimeZone(); const kcHeader = encodeURIComponent(getUserKubeConfig()); - const { applaunchpadUrl } = useEnvStore.getState().SystemEnv; + const { applaunchpadUrl, successfulJobsHistoryLimit, failedJobsHistoryLimit } = + useEnvStore.getState().SystemEnv; const metadata = { name: data.jobName, @@ -111,8 +112,8 @@ export const json2CronJob = (data: CronJobEditType) => { schedule: data.schedule, concurrencyPolicy: 'Replace', startingDeadlineSeconds: 60, - successfulJobsHistoryLimit: 3, - failedJobsHistoryLimit: 3, + successfulJobsHistoryLimit, + failedJobsHistoryLimit, timeZone: timeZone, jobTemplate: { activeDeadlineSeconds: 600,