Skip to content

Commit 2ff9acc

Browse files
BorisShekJ12934
authored andcommitted
#2680 Handle missing ScheduledScan gracefully by auto-discovery
Previously, the Container Auto-Discovery controller logged an error when trying to fetch a ScheduledScan that was already deleted. This change introduces a check for `IsNotFound` errors, treating them as expected behavior instead of logging them as errors. Now, if a ScheduledScan is not found, an informational log message is recorded instead of an error. This prevents unnecessary noise in logs. Signed-off-by: Boris Shek <boris.shek@iteratec.com>
1 parent a2ebbae commit 2ff9acc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

auto-discovery/kubernetes/controllers/container_scan_controller.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,11 @@ func (r *ContainerScanReconciler) getOrphanedScanImageIDs(ctx context.Context, p
427427
var scan executionv1.ScheduledScan
428428
err := r.Client.Get(ctx, types.NamespacedName{Name: scanName, Namespace: pod.Namespace}, &scan)
429429
if err != nil {
430-
r.Log.Error(err, "Unable to fetch scan", "name", scanName)
430+
if k8sErrors.IsNotFound(err) {
431+
r.Log.Info("Scan was already deleted, nothing to do", "name", scanName)
432+
} else {
433+
r.Log.Error(err, "Unable to fetch scan", "name", scanName)
434+
}
431435
} else if !r.containerIDInUse(ctx, pod, imageID) {
432436
result[cleanedImageID] = append(result[cleanedImageID], scanConfig)
433437
}

0 commit comments

Comments
 (0)