Skip to content

Commit

Permalink
fix job
Browse files Browse the repository at this point in the history
  • Loading branch information
zjy365 committed Oct 18, 2024
1 parent 115ab86 commit d471bc7
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions frontend/providers/template/src/pages/api/resource/delJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { jsonRes } from '@/services/backend/response';
export default async function handler(req: NextApiRequest, res: NextApiResponse<ApiResp>) {
try {
const { instanceName } = req.query as { instanceName: string };

if (!instanceName) {
throw new Error('Job name is empty');
}
Expand All @@ -15,10 +16,22 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
kubeconfig: await authSession(req.headers)
});

// 删除 Job
const result = await k8sBatch.deleteNamespacedJob(instanceName, namespace);
const deleteOptions = {
propagationPolicy: 'Foreground'
};

const result = await k8sBatch.deleteNamespacedJob(
instanceName,
namespace,
undefined,
undefined,
undefined,
undefined,
deleteOptions.propagationPolicy,
deleteOptions
);

jsonRes(res, { data: result });
jsonRes(res, { data: 'success' });
} catch (err: any) {
jsonRes(res, {
code: 500,
Expand Down

0 comments on commit d471bc7

Please sign in to comment.