Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit 127394e

Browse files
committed
Fix ordering issues in ScheduledScans
Timestamp wasn't properly set. Reverting to just using native kubernetes creation timestamp as the are more reliable.
1 parent 891605a commit 127394e

File tree

4 files changed

+1
-15
lines changed

4 files changed

+1
-15
lines changed

operator/apis/execution/v1/scan_types.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ type ScanStatus struct {
4444
// RawResultFile Filename of the result file of the scanner. e.g. `nmap-result.xml`
4545
RawResultFile string `json:"rawResultFile,omitempty"`
4646

47-
StartTime *metav1.Time `json:"startTime,omitempty"`
48-
4947
Findings FindingStats `json:"findings,omitempty"`
5048
}
5149

operator/apis/execution/v1/zz_generated.deepcopy.go

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/config/crd/bases/execution.experimental.securecodebox.io_scans.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ spec:
113113
description: RawResultType determines which kind of ParseDefinition
114114
will be used to turn the raw results of the scanner into findings
115115
type: string
116-
startTime:
117-
format: date-time
118-
type: string
119116
state:
120117
type: string
121118
type: object

operator/controllers/execution/scheduledscan_controller.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ func (r *ScheduledScanReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
7575
}
7676

7777
sort.Slice(completedScans, func(i, j int) bool {
78-
if completedScans[i].Status.StartTime == nil {
79-
return completedScans[j].Status.StartTime != nil
80-
}
81-
return completedScans[i].Status.StartTime.Before(completedScans[j].Status.StartTime)
78+
return completedScans[i].ObjectMeta.CreationTimestamp.Before(&completedScans[j].ObjectMeta.CreationTimestamp)
8279
})
8380

8481
if len(completedScans) >= 1 {
@@ -126,8 +123,6 @@ func (r *ScheduledScanReconciler) Reconcile(req ctrl.Request) (ctrl.Result, erro
126123
Spec: *scheduledScan.Spec.ScanSpec.DeepCopy(),
127124
}
128125
scan.Name = fmt.Sprintf("%s-%d", scheduledScan.Name, nextSchedule.Unix())
129-
metaNow := metav1.Now()
130-
scan.Status.StartTime = &metaNow
131126
if err := ctrl.SetControllerReference(&scheduledScan, scan, r.Scheme); err != nil {
132127
log.Error(err, "unable to set owner reference on scan")
133128
return ctrl.Result{}, err

0 commit comments

Comments
 (0)