Skip to content

Commit

Permalink
Merge pull request #4211 from Agnul97/fix-job_steps_failed_status
Browse files Browse the repository at this point in the history
🐛 [Job] Device target status incorrect when re-executing a failed step.
  • Loading branch information
Coduz authored Mar 7, 2025
2 parents 2eefec1 + 417f66f commit b766d8a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ public void beforeJob() throws Exception {
jobLogger.error(e, "Resetting {} targets to step index: {}... ERROR!", jobExecution.getTargetIds().size(), resetToStepIndex);
}
jobLogger.info("Resetting {} targets to step index: {}... DONE!", jobExecution.getTargetIds().size(), resetToStepIndex);
} else {
for (KapuaId jobTargetId : jobExecution.getTargetIds()) {
JobTarget jobTarget = KapuaSecurityUtils.doPrivileged(() -> jobTargetService.find(jobExecution.getScopeId(), jobTargetId));
if (jobTarget.getStatus().equals(JobTargetStatus.PROCESS_FAILED)) {
jobTarget.setStatus(JobTargetStatus.PROCESS_AWAITING);
jobTarget.setStatusMessage(null);
jobTarget.setException(null);
KapuaSecurityUtils.doPrivileged(() -> jobTargetService.update(jobTarget));
}
}
}

jobLogger.info("Running before job... DONE!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,34 @@ Feature: Job Engine Service - Operations
Then I confirm that job has 2 job execution
And I confirm that job target in job has step index 0 and status "PROCESS_OK"

Scenario: Start - JobTarget failed, then "loading status" (process_awaiting), then ok

Given I login as user with name "kapua-sys" and password "kapua-password"
And I create a device with name "rpione3"
And I create a job with the name "TestJob"
And I add device targets to job
| rpione3 |
And I search for step definition with the name
| Command Execution |
And I add job step to job with name "Test Step - Command Exec" and with selected job step definition and properties
| name | type | value |
| commandInput | org.eclipse.kapua.service.device.management.command.DeviceCommandInput | <?xml version="1.0" encoding="UTF-8"?><commandInput><command>ping</command><arguments><argument>-c</argument><argument>10</argument><argument>8.8.8.8</argument></arguments><timeout>30000</timeout><runAsynch>false</runAsynch></commandInput> |
| timeout | java.lang.Long | 30000 |
When I start a job
#Now I await some time in order to synch job-engine and the service used to read job executions...
And I wait job to finish its execution up to 15s
Then I confirm that job has 1 job execution
And I confirm that job target in job has step index 0 and status "PROCESS_FAILED"
Then I start the Kura Mock
And Device birth message is sent
And Device "rpione3" is connected within 10s
When I start a job
And I wait for another job start up to 2s
Then I confirm that job has 2 job execution
And I confirm that job target in job has step index 0 and status "PROCESS_AWAITING"
And I wait job to finish its execution up to 15s
And I confirm that job target in job has step index 0 and status "PROCESS_OK"

Scenario: Start - Two JobSteps

Given I login as user with name "kapua-sys" and password "kapua-password"
Expand Down

0 comments on commit b766d8a

Please sign in to comment.