Skip to content

Commit 5dc41a4

Browse files
Reet00J12934
authored andcommitted
#2293 Changed definition of FinishedAt to include errored scans
to be able to use this to determine the deletion time for errored scans Signed-off-by: Samreet Singh <samreet.singh@iteratec.com>
1 parent a66ebbd commit 5dc41a4

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

operator/apis/execution/v1/scan_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const (
170170
type ScanStatus struct {
171171
State ScanState `json:"state,omitempty"`
172172

173-
// FinishedAt contains the time where the scan (including parser & hooks) has been marked as "Done"
173+
// FinishedAt contains the time where the scan (including parser & hooks) has been marked as "Done", or has errored
174174
FinishedAt *metav1.Time `json:"finishedAt,omitempty"`
175175
ErrorDescription string `json:"errorDescription,omitempty"`
176176

operator/controllers/execution/scans/scan_controller.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,12 @@ func updateScanStateMetrics(scan executionv1.Scan) {
256256

257257
func (r *ScanReconciler) updateScanStatus(ctx context.Context, scan *executionv1.Scan) error {
258258
updateScanStateMetrics(*scan)
259-
260-
if scan.Status.FinishedAt == nil {
261-
scan.Status.FinishedAt = &metav1.Time{Time: time.Now()}
259+
if scan.Status.State == executionv1.ScanStateDone || scan.Status.State == executionv1.ScanStateErrored {
260+
if scan.Status.FinishedAt == nil {
261+
scan.Status.FinishedAt = &metav1.Time{Time: time.Now()}
262+
}
262263
}
264+
263265
if err := r.Status().Update(ctx, scan); err != nil {
264266
r.Log.Error(err, "unable to update Scan status")
265267
return err

0 commit comments

Comments
 (0)