@@ -167,7 +167,7 @@ func (impl *WorkflowServiceImpl) createWorkflowTemplateAndAuditTrigger(workflowR
167
167
}
168
168
err = impl .auditTrigger (workflowRequest )
169
169
if err != nil {
170
- impl .Logger .Errorw ("error occurred while auditing trigger" , "err" , err )
170
+ impl .Logger .Errorw ("error occurred while auditing trigger" , "workflowRunnerId" , workflowRequest . WorkflowRunnerId , "ciWorkflowId" , workflowRequest . WorkflowId , " err" , err )
171
171
return bean3.WorkflowTemplate {}, err
172
172
}
173
173
workflowTemplate := workflowRequest .GetWorkflowTemplate (workflowJson , impl .ciCdConfig )
@@ -263,9 +263,9 @@ func (impl *WorkflowServiceImpl) createWorkflowTemplateAndAuditTrigger(workflowR
263
263
264
264
if workflowRequest .IsCiTypeWorkflowRequest () && workflowRequest .IsCiRetriggerType () {
265
265
// here we need to update the workflow template with cpu request and limit, memory limit and request and Build timeout (in oss this is applicable on all ci builds i.e. applied globally)
266
- err = impl .updateWorkflowTemplateWithInfraConfigFromHistory (workflowRequest , & workflowTemplate )
266
+ err = impl .populateReTriggerWorkflowTemplateWithInfraConfig (workflowRequest , & workflowTemplate )
267
267
if err != nil {
268
- impl .Logger .Errorw ("error occurred while updating workflow template with infra config from history" , "err" , err )
268
+ impl .Logger .Errorw ("error occurred while updating workflow template with infra config from history" , "ciWorkflowId" , workflowRequest . WorkflowId , " err" , err )
269
269
return bean3.WorkflowTemplate {}, err
270
270
}
271
271
@@ -524,9 +524,9 @@ func (impl *WorkflowServiceImpl) getWfClient(environment *repository2.Environmen
524
524
return wfClient , nil
525
525
}
526
526
527
- // updateWorkflowTemplateWithInfraConfigFromHistory updates the workflow template with CPU, memory limits/requests and timeout
527
+ // populateReTriggerWorkflowTemplateWithInfraConfig updates the workflow template with CPU, memory limits/requests and timeout
528
528
// from the infra_config_trigger_history table based on previous workflow ID.
529
- func (impl * WorkflowServiceImpl ) updateWorkflowTemplateWithInfraConfigFromHistory (workflowRequest * types.WorkflowRequest , workflowTemplate * bean3.WorkflowTemplate ) error {
529
+ func (impl * WorkflowServiceImpl ) populateReTriggerWorkflowTemplateWithInfraConfig (workflowRequest * types.WorkflowRequest , workflowTemplate * bean3.WorkflowTemplate ) error {
530
530
// Skip if no previous workflow ID is available or if this is not a CI/Job workflow
531
531
if workflowRequest .ReferenceCiWorkflowId == 0 {
532
532
impl .Logger .Debugw ("skipping infra config history update" , "referenceWorkflowId" , workflowRequest .ReferenceCiWorkflowId , "workflowType" , workflowRequest .Type )
@@ -536,7 +536,7 @@ func (impl *WorkflowServiceImpl) updateWorkflowTemplateWithInfraConfigFromHistor
536
536
// Get infra config from history based on previous workflow ID
537
537
historicalInfraConfig , err := impl .infraConfigAuditService .GetInfraConfigByWorkflowId (workflowRequest .ReferenceCiWorkflowId , bean .CI_WORKFLOW_TYPE .String ())
538
538
if err != nil {
539
- impl .Logger .Warnw ("could not retrieve infra config from history, using current config" , "referenceWorkflowId" , workflowRequest .ReferenceCiWorkflowId , "err" , err )
539
+ impl .Logger .Errorw ("could not retrieve infra config from history, using current config" , "referenceWorkflowId" , workflowRequest .ReferenceCiWorkflowId , "err" , err )
540
540
return nil // Don't fail the workflow, just use current config
541
541
}
542
542
@@ -545,17 +545,21 @@ func (impl *WorkflowServiceImpl) updateWorkflowTemplateWithInfraConfigFromHistor
545
545
return nil
546
546
}
547
547
548
- impl .Logger .Infow ("applying historical infra config to workflow template" , "referenceWorkflowId" , workflowRequest .ReferenceCiWorkflowId , "historicalConfig" , historicalInfraConfig )
548
+ impl .Logger .Infow ("applying historical infra config to workflow template" , "referenceWorkflowId" , workflowRequest .ReferenceCiWorkflowId )
549
549
550
550
// apply historical infra configurations to a workflow template
551
- impl .applyInfraConfigToWorkflowTemplate (workflowRequest , workflowTemplate , historicalInfraConfig )
551
+ err = impl .applyInfraConfigToWorkflowTemplate (workflowRequest , workflowTemplate , historicalInfraConfig )
552
+ if err != nil {
553
+ impl .Logger .Errorw ("error in applying infra config to workflow template" , "referenceWorkflowId" , workflowRequest .ReferenceCiWorkflowId , "err" , err )
554
+ return err
555
+ }
552
556
553
557
return nil
554
558
}
555
559
556
560
// applyInfraConfigToWorkflowTemplate applies the historical infra configuration to the workflow template.
557
561
// This function handles the core OSS functionality and can be extended in enterprise for additional fields.
558
- func (impl * WorkflowServiceImpl ) applyInfraConfigToWorkflowTemplate (workflowRequest * types.WorkflowRequest , workflowTemplate * bean3.WorkflowTemplate , infraConfig * v1.InfraConfig ) {
562
+ func (impl * WorkflowServiceImpl ) applyInfraConfigToWorkflowTemplate (workflowRequest * types.WorkflowRequest , workflowTemplate * bean3.WorkflowTemplate , infraConfig * v1.InfraConfig ) error {
559
563
// Apply timeout configuration
560
564
if infraConfig .GetCiDefaultTimeout () > 0 {
561
565
timeout := infraConfig .GetCiTimeoutInt ()
@@ -581,15 +585,17 @@ func (impl *WorkflowServiceImpl) applyInfraConfigToWorkflowTemplate(workflowRequ
581
585
container .Resources .Limits [v12 .ResourceCPU ] = cpuLimit
582
586
impl .Logger .Debugw ("applied historical CPU limit to workflow template" , "cpuLimit" , infraConfig .GetCiLimitCpu (), "workflowId" , workflowRequest .WorkflowId )
583
587
} else {
584
- impl .Logger .Warnw ("failed to parse CPU limit from historical config" , "cpuLimit" , infraConfig .GetCiLimitCpu (), "err" , err )
588
+ impl .Logger .Errorw ("failed to parse CPU limit from historical config" , "cpuLimit" , infraConfig .GetCiLimitCpu (), "err" , err )
589
+ return err
585
590
}
586
591
}
587
592
if infraConfig .GetCiReqCpu () != "" {
588
593
if cpuRequest , err := resource .ParseQuantity (infraConfig .GetCiReqCpu ()); err == nil {
589
594
container .Resources .Requests [v12 .ResourceCPU ] = cpuRequest
590
595
impl .Logger .Debugw ("applied historical CPU request to workflow template" , "cpuRequest" , infraConfig .GetCiReqCpu (), "workflowId" , workflowRequest .WorkflowId )
591
596
} else {
592
- impl .Logger .Warnw ("failed to parse CPU request from historical config" , "cpuRequest" , infraConfig .GetCiReqCpu (), "err" , err )
597
+ impl .Logger .Errorw ("failed to parse CPU request from historical config" , "cpuRequest" , infraConfig .GetCiReqCpu (), "err" , err )
598
+ return err
593
599
}
594
600
}
595
601
@@ -599,23 +605,26 @@ func (impl *WorkflowServiceImpl) applyInfraConfigToWorkflowTemplate(workflowRequ
599
605
container .Resources .Limits [v12 .ResourceMemory ] = memoryLimit
600
606
impl .Logger .Debugw ("applied historical memory limit to workflow template" , "memoryLimit" , infraConfig .GetCiLimitMem (), "workflowId" , workflowRequest .WorkflowId )
601
607
} else {
602
- impl .Logger .Warnw ("failed to parse memory limit from historical config" , "memoryLimit" , infraConfig .GetCiLimitMem (), "err" , err )
608
+ impl .Logger .Errorw ("failed to parse memory limit from historical config" , "memoryLimit" , infraConfig .GetCiLimitMem (), "err" , err )
609
+ return err
603
610
}
604
611
}
605
612
if infraConfig .GetCiReqMem () != "" {
606
613
if memoryRequest , err := resource .ParseQuantity (infraConfig .GetCiReqMem ()); err == nil {
607
614
container .Resources .Requests [v12 .ResourceMemory ] = memoryRequest
608
615
impl .Logger .Debugw ("applied historical memory request to workflow template" , "memoryRequest" , infraConfig .GetCiReqMem (), "workflowId" , workflowRequest .WorkflowId )
609
616
} else {
610
- impl .Logger .Warnw ("failed to parse memory request from historical config" , "memoryRequest" , infraConfig .GetCiReqMem (), "err" , err )
617
+ impl .Logger .Errorw ("failed to parse memory request from historical config" , "memoryRequest" , infraConfig .GetCiReqMem (), "err" , err )
618
+ return err
611
619
}
612
620
}
613
621
}
614
622
615
- impl .applyEnterpriseInfraConfigToWorkflowTemplate (workflowRequest , workflowTemplate , infraConfig )
623
+ return impl .applyEnterpriseInfraConfigToWorkflowTemplate (workflowRequest , workflowTemplate , infraConfig )
616
624
}
617
625
618
626
// applyEnterpriseInfraConfigToWorkflowTemplate is a placeholder for enterprise-specific infra config application.
619
- func (impl * WorkflowServiceImpl ) applyEnterpriseInfraConfigToWorkflowTemplate (workflowRequest * types.WorkflowRequest , workflowTemplate * bean3.WorkflowTemplate , infraConfig * v1.InfraConfig ) {
627
+ func (impl * WorkflowServiceImpl ) applyEnterpriseInfraConfigToWorkflowTemplate (workflowRequest * types.WorkflowRequest , workflowTemplate * bean3.WorkflowTemplate , infraConfig * v1.InfraConfig ) error {
620
628
impl .Logger .Debugw ("enterprise infra config application (no-op in OSS)" , "workflowId" , workflowRequest .WorkflowId )
629
+ return nil
621
630
}
0 commit comments