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

Commit 706c1e1

Browse files
committed
Add error states when no matching ScanType or ParseDefinition could be found
1 parent f4570b9 commit 706c1e1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

operator/controllers/execution/scan_controller.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ func (r *ScanReconciler) startScan(scan *executionv1.Scan) error {
188188
// requeue (we'll need to wait for a new notification), and we can get them
189189
// on deleted requests.
190190
log.V(7).Info("Unable to fetch ScanType")
191+
192+
scan.Status.State = "Errored"
193+
scan.Status.ErrorDescription = fmt.Sprintf("Configured ScanType '%s' not found in Scans Namespace. You'll likely need to deploy the ScanType.", scan.Spec.ScanType)
194+
if err := r.Status().Update(ctx, scan); err != nil {
195+
r.Log.Error(err, "unable to update Scan status")
196+
return err
197+
}
198+
191199
return fmt.Errorf("No ScanType of type '%s' found", scan.Spec.ScanType)
192200
}
193201
log.Info("Matching ScanType Found", "ScanType", scanType.Name)
@@ -283,6 +291,14 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
283291
var parseDefinition executionv1.ParseDefinition
284292
if err := r.Get(ctx, types.NamespacedName{Name: parseType, Namespace: scan.Namespace}, &parseDefinition); err != nil {
285293
log.V(7).Info("Unable to fetch ParseDefinition")
294+
295+
scan.Status.State = "Errored"
296+
scan.Status.ErrorDescription = fmt.Sprintf("No ParseDefinition for ResultType '%s' found in Scans Namespace.", parseType)
297+
if err := r.Status().Update(ctx, scan); err != nil {
298+
r.Log.Error(err, "unable to update Scan status")
299+
return err
300+
}
301+
286302
return fmt.Errorf("No ParseDefinition of type '%s' found", parseType)
287303
}
288304
log.Info("Matching ParseDefinition Found", "ParseDefinition", parseType)

0 commit comments

Comments
 (0)