-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[backend] add executionTrace table #2296
base: release/current
Are you sure you want to change the base?
Conversation
openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaExecutor.java
Outdated
Show resolved
Hide resolved
openbas-api/src/main/java/io/openbas/injectors/caldera/CalderaResultCollector.java
Show resolved
Hide resolved
...as-api/src/main/java/io/openbas/injectors/caldera/service/CalderaResultCollectorService.java
Outdated
Show resolved
Hide resolved
...as-api/src/main/java/io/openbas/injectors/caldera/service/CalderaResultCollectorService.java
Outdated
Show resolved
Hide resolved
openbas-api/src/main/java/io/openbas/migration/V3_62__Add_ExecutionTraces_table.java
Show resolved
Hide resolved
openbas-api/src/main/java/io/openbas/rest/inject/InjectApi.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.injectRepository, | ||
this.injectStatusRepository, | ||
this.calderaService, | ||
this.injectStatusService); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You pass injectStatusService + injectStatusRepository ? You can't pass the service only ? Because injectStatusService uses injectStatusRepository
openbas-api/src/main/java/io/openbas/migration/V3_62__Add_ExecutionTraces_table.java
Show resolved
Hide resolved
openbas-api/src/main/java/io/openbas/migration/V3_62__Add_ExecutionTraces_table.java
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
if (successCount > 0 && errorCount == 0 && maybePreventedCount == 0 & partialCount == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
& alone in your if, is it normal ? Same below
} | ||
|
||
injectStatus.addTrace( | ||
ExecutionTraceStatus.INFO, "Process finish", ExecutionTraceAction.PROCESS_FINISH, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Process finished ?
openbas-api/src/main/java/io/openbas/rest/inject/service/InjectStatusService.java
Show resolved
Hide resolved
...as-api/src/main/java/io/openbas/injectors/caldera/service/CalderaResultCollectorService.java
Show resolved
Hide resolved
@@ -32,56 +29,20 @@ public abstract class BaseInjectStatus implements Base { | |||
@NotNull | |||
private ExecutionStatus name; | |||
|
|||
// region dates tracking | |||
@Column(name = "status_executions") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Do we need a migration for old execution ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we shouldn't ? Because status_executions in the inject_statuses table would only be used for old executed injects while also having a relation to ExecutionTrace. This is confusing since both represent the same thing, leading to redundancy and unclear data relationships.
@@ -32,26 +32,11 @@ public String getName() { | |||
|
|||
@Builder.Default | |||
@JsonProperty("status_traces") | |||
private List<InjectStatusExecution> traces = new ArrayList<>(); | |||
private List<ExecutionTraces> traces = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Do we need an ExecutionTracesOutput ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be done in the next chunk since you'll be working on what to send to the frontend. But if you prefer I can clean it now ?
import lombok.Getter; | ||
|
||
@Getter | ||
public class DetailedException extends RuntimeException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I am not a big fan of this nomenclature.
But, I don't have any other idea.
@@ -34,6 +38,7 @@ public class ExecutionExecutorService { | |||
private final OpenBASExecutorContextService openBASExecutorContextService; | |||
private final InjectStatusRepository injectStatusRepository; | |||
|
|||
@Transactional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Why we have a transactional here ? If we have any error not handle in the try catch, we will loop on error for a specific inject.
@@ -96,7 +96,7 @@ public List<DataAttachment> resolveAttachments( | |||
doc.getName(), doc.getOriginalFilename(), content, doc.getContentType())); | |||
} catch (Exception e) { | |||
String message = "Error getting direct attachment " + doc.getName(); | |||
execution.addTrace(traceError(message)); | |||
execution.addTrace(getNewErrorTrace(message, ExecutionTraceAction.EXECUTION)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Why having an EXECUTION here ?
It's an internal process, we don't do anything on the inject itself.
openbas-api/src/main/java/io/openbas/injectors/email/service/EmailService.java
Show resolved
Hide resolved
@Column(name = "status_executions") | ||
@Convert(converter = InjectStatusExecutionConverter.class) | ||
@JsonProperty("status_traces") | ||
private List<InjectStatusExecution> traces = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Why we don't have the same bahavior as for InjectStatus ?
@@ -12,9 +12,6 @@ | |||
@Setter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I am not sure it's a good idea to have two model: one for test and one for real action.
openbas-model/src/main/java/io/openbas/database/model/ExecutionTraceStatus.java
Show resolved
Hide resolved
openbas-api/src/main/java/io/openbas/rest/inject/form/InjectExecutionAction.java
Show resolved
Hide resolved
It's great to have this level of granularity in the traces :). 🎉 Tests : ✅
|
|
||
CLEANUP_EXECUTION, | ||
COMPLETE, // when inject of one asset is finish, or of one user | ||
PROCESS_FINISH // inject is completely done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed ?
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Signed-off-by: Marine LM <[email protected]>
Proposed changes
Related issues