Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cronjob history limit from env #5249

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/providers/cronjob/deploy/Kubefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 4 additions & 0 deletions frontend/providers/cronjob/deploy/manifests/deploy.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion frontend/providers/cronjob/src/pages/api/platform/getEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApiResp>) {
jsonRes<EnvResponse>(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
}
});
}
4 changes: 3 additions & 1 deletion frontend/providers/cronjob/src/store/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const useEnvStore = create<EnvState>()(
immer((set, get) => ({
SystemEnv: {
domain: '',
applaunchpadUrl: ''
applaunchpadUrl: '',
successfulJobsHistoryLimit: 3,
failedJobsHistoryLimit: 3
},
initSystemEnv: async () => {
const data = await getPlatformEnv();
Expand Down
7 changes: 4 additions & 3 deletions frontend/providers/cronjob/src/utils/json2Yaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading