-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Track workflow state of BOM processing / analysis in database to make it accessible to multiple API server instances #664
Labels
component/api-server
enhancement
New feature or request
meta
p1
Critical bugs that prevent DT from being used, or features that must be implemented ASAP
size/XL
Higher effort
Comments
nscuro
added
enhancement
New feature or request
p1
Critical bugs that prevent DT from being used, or features that must be implemented ASAP
proposal
size/M
Medium effort
component/api-server
labels
Jul 11, 2023
nscuro
changed the title
WIP: Track processing / analysis status in database to make it accessible to multiple API server instances
Track processing / analysis status in database to make it accessible to multiple API server instances
Jul 11, 2023
nscuro
changed the title
Track processing / analysis status in database to make it accessible to multiple API server instances
Track workflow state of BOM processing / analysis in database to make it accessible to multiple API server instances
Jul 12, 2023
This was referenced Jul 14, 2023
5 tasks
This was referenced Jul 20, 2023
This was referenced Jul 25, 2023
5 tasks
nscuro
added a commit
that referenced
this issue
Aug 1, 2023
So it can be revisited and reviewed without going through loads of issues. Signed-off-by: nscuro <[email protected]>
nscuro
added a commit
that referenced
this issue
Aug 1, 2023
So it can be revisited and reviewed without going through loads of issues. Closes #664 Signed-off-by: nscuro <[email protected]>
sahibamittal
pushed a commit
that referenced
this issue
Aug 1, 2023
mehab
pushed a commit
that referenced
this issue
Sep 12, 2023
Signed-off-by: mehab <[email protected]>
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
component/api-server
enhancement
New feature or request
meta
p1
Critical bugs that prevent DT from being used, or features that must be implemented ASAP
size/XL
Higher effort
For CI/CD use-cases, Dependency-Track offers a mechanism that allows clients to poll whether the BOM they just uploaded is still being processed. "Processing" in this context refers to:
This is an important capability, allowing for implementation of quality gates and reporting in CI/CD pipelines.
The mechanism works by assigning identifiers (UUIDs) to events in Alpine's in-memory event system. As long as an event associated to a given identifier can be found in its internal queue, the identifier is considered to be "processing":
Events can be chained, such that a
BomUploadEvent
will trigger aVulnerabilityAnalysisEvent
, which will trigger aPolicyEvaluationEvent
, and so on. The event identifier is inherited by chained events.As everything happens in-memory, this mechanism does not work when multiple instances of the API server are used in an active-active deployment. For the functionality to continue to work, the state of processing steps must be persistent to external storage.
Decoupled from #633.
Implementation Status
Design
What to track
The order of execution as of today is as follows:
States
There are multiple states a processing step can be in:
PENDING
: Initial stateCOMPLETED
: Completion detected; No failuresFAILED
: Completion detected; FailuresCANCELLED
: Never started because a precondition failedNOT_APPLICABLE
: The step is not applicable to the subject of the analysisTIMED_OUT
: The deadline for the step completion was exceeded; Step is unlikely to completeEach step is responsible for updating its own state.
The overall state can be considered to be complete, if there's no step in
PENDING
state.When a step failure is detected, a "failure reason" message must be persisted. If multiple steps fail, (rough) failure details for each step must be available.
Workflow
The API server will act as workflow orchestrator, kicking off new steps as needed. This implies that completion of a step must be registered by the API server.
To illustrate how the initial stage of the workflow should look like:
When triggering a re-analysis of an already existing project, the workflow may be kicked off as follows:
Proposed Table Schema
Each step of the workflow will be represented in a dedicated row. This allows us to add or remove steps without altering the database schema (see original version of the schema further down below), or even add steps while the workflow is running. It also plays better with concurrent writes, as no two threads / instances will need to modify the same row.
SERIAL
SERIAL FK
VARCHAR(36)
484d9eaa-7ea4-4476-97d6-f36327b5a626
TIMESTAMP
1999-01-08 04:05:06
TIMESTAMP
1999-01-08 04:05:06
VARCHAR(64)
METRICS_UPDATE
VARCHAR(64)
PENDING
TEXT
Failed to acquire database connection
Potential Future Improvements:
Original Version
VARCHAR(36)
484d9eaa-7ea4-4476-97d6-f36327b5a626
TIMESTAMP
1999-01-08 04:05:06
TIMESTAMP
1999-01-08 04:05:06
VARCHAR(64)
PENDING
VARCHAR(64)
PENDING
VARCHAR(64)
PENDING
VARCHAR(64)
PENDING
VARCHAR(64)
PENDING
VARCHAR(64)
PENDING
TEXT
FAILURE_REASON
is a field of unlimited length. It either holds no value (NULL
), or a JSON object listing failure details per step, e.g.:Where applicable, the "detailed" status of a step is tracked in a dedicated table. For example, for vulnerability analysis:
hyades/commons-persistence/src/main/resources/migrations/postgres/V0.0.1__API-Server-4.8.2.sql
Lines 158 to 171 in e70c47f
Retention
Rows in the table should be cleaned up on a recurring basis.
This could be as simple as scheduling a job that executes this SQL query:
A retention time of 1-3 days since the last update should be reasonable.
REST API endpoints
The existing endpoint to check whether a BOM is still being processed should continue to work as expected:
An additional endpoint may be added, which allows for retrieval of the individual step states:
If all a client cares about are vulnerability analysis results, they could stop polling immediately after
vulnerabilityAnalysis
transitions into theCOMPLETED
state.The text was updated successfully, but these errors were encountered: