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

Commit 090306b

Browse files
committed
Ignore not found errors when deleting files from s3
Not found doesn't really matter as we are trying to delete them anyway. This either means the scan has crashed before any files were uploaded or they were deleted by hand
1 parent dfb9dd1 commit 090306b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

operator/controllers/execution/scan_controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,19 @@ func removeString(slice []string, s string) (result []string) {
186186
return
187187
}
188188

189+
var errNotFound = "The specified key does not exist."
190+
189191
func (r *ScanReconciler) handleFinalizer(scan *executionv1.Scan) error {
190192
if containsString(scan.ObjectMeta.Finalizers, s3StorageFinalizer) {
191193
bucketName := os.Getenv("S3_BUCKET")
192194
r.Log.V(0).Info("Deleting External Files from FileStorage", "ScanUID", scan.UID)
193-
if err := r.MinioClient.RemoveObject(bucketName, fmt.Sprintf("scan-%s/%s", scan.UID, scan.Status.RawResultFile)); err != nil {
195+
err := r.MinioClient.RemoveObject(bucketName, fmt.Sprintf("scan-%s/%s", scan.UID, scan.Status.RawResultFile))
196+
if err != nil && err.Error() != errNotFound {
194197
return err
195198
}
196-
if err := r.MinioClient.RemoveObject(bucketName, fmt.Sprintf("scan-%s/findings.json", scan.UID)); err != nil {
199+
err = r.MinioClient.RemoveObject(bucketName, fmt.Sprintf("scan-%s/findings.json", scan.UID))
200+
201+
if err != nil && err.Error() != errNotFound {
197202
return err
198203
}
199204

0 commit comments

Comments
 (0)