File tree Expand file tree Collapse file tree
x-pack/plugins/ml/server/saved_objects Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,24 +58,23 @@ export function jobSavedObjectServiceFactory(
5858
5959 async function _createJob ( jobType : JobType , jobId : string , datafeedId ?: string ) {
6060 await isMlReady ( ) ;
61- try {
62- await _deleteJob ( jobType , jobId ) ;
63- } catch ( error ) {
64- // fail silently
65- // the job object may or may not already exist, we'll overwrite it anyway.
66- }
67- await savedObjectsClient . create < JobObject > ( ML_SAVED_OBJECT_TYPE , {
68- job_id : jobId ,
69- datafeed_id : datafeedId ?? null ,
70- type : jobType ,
71- } ) ;
61+ await savedObjectsClient . create < JobObject > (
62+ ML_SAVED_OBJECT_TYPE ,
63+ {
64+ job_id : jobId ,
65+ datafeed_id : datafeedId ?? null ,
66+ type : jobType ,
67+ } ,
68+ { id : jobId , overwrite : true }
69+ ) ;
7270 }
7371
7472 async function _bulkCreateJobs ( jobs : JobObject [ ] , namespaces ?: string [ ] ) {
7573 await isMlReady ( ) ;
7674 return await savedObjectsClient . bulkCreate < JobObject > (
7775 jobs . map ( ( j ) => ( {
7876 type : ML_SAVED_OBJECT_TYPE ,
77+ id : j . job_id ,
7978 attributes : j ,
8079 initialNamespaces : namespaces ,
8180 } ) )
You can’t perform that action at this time.
0 commit comments