control-service: refactor job cancellation method due to 404 errors - #1114
Conversation
Signed-off-by: mrMoZ1 <mzhivkov@vmware.com>
antoniivanov
left a comment
There was a problem hiding this comment.
Tests are missing. I assume you've planned some tests?
No since we already have a test that covers cancellation functionality and all tests pass. |
Well of course not. One can never have a bug that is covered by our tests. By definition, our tests would have caught it before it became a bug. Clearly, we have a gap in the tests. We need to reproduce the issue in a test . Otherwise we have no insurance against regression - that the issue will re-surface again in the future. It also gives us more confidence that the buf fix is working (especially when we are not even sure). |
Signed-off-by: mrMoZ1 <mzhivkov@vmware.com>
Signed-off-by: mrMoZ1 <mzhivkov@vmware.com>
what: Added a new interface method in the job execution repository that retrieves the executions by comparing ID, data job name and data job team. Switched the Spring data interface methods used in the KubernetesService class' cancelJobExecution method. Fixed a few log calls which had reversed variables for printing e.g it would pring the job instead of the team name and vice versa.
why: The previous implementation would only compare for execution ID, allowing users to cancel job executions of other team/job by providing the correct execution. Moreover the default method would produce a query with INNER JOIN data_job datajob1_ on the DataJob table which in some cases would return 404 not found errors when attempting to cancel job executions. After debugging we noticed that the listExecutions method is not affected by this pitfall and it's query uses a LEFT OUTER join, which the new method also uses. Note below is the old findByID method's produced query and the new method's query for comparison:
And this is the query produced by the new method in the interface:
testing: We already have a unit test that covers job cancellations, which contained no changed tests locally.
Signed-off-by: Momchil Zhivkov mzhivkov@vmware.com