Skip to content

Commit

Permalink
🐛fix: s3: ignore "NotFound" errors
Browse files Browse the repository at this point in the history
The `s3.HeadObject` API call can return "NotFound" when either the
bucket or the object does not exist (as opposed to the more descriptive
`s3.ErrCodeNoSuchKey` or `s3.ErrCodeNoSuchBucket`).

This would cause the machine controller to loop indefinitely trying to
delete an already deleted object but failing:

```
E0316 16:37:08.973942     366 awsmachine_controller.go:307] "unable to delete machine" err=<
	deleting bootstrap data object: deleting S3 object: NotFound: Not Found
		status code: 404, request id: 5Z101DW1KN380WTY, host id: tYlSi9K38lBkIsr2DNf/xFfgDuFaVfeUmpscXdljiMZC5iRxPIDuXSLwHJwdFnosYCfi7Bih25GaDpVAbSq4ZA==
 >
```
  • Loading branch information
r4f4 committed Mar 18, 2024
1 parent 39d097f commit 6f7925b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/cloud/services/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ func (s *Service) Delete(m *scope.MachineScope) error {

s.scope.Debug("Delete object call succeeded despite missing GetObject permission", "bucket", bucket, "key", key)

return nil
case "NotFound":
s.scope.Debug("Either bucket or object does not exist", "bucket", bucket, "key", key)
return nil
case s3.ErrCodeNoSuchKey:
s.scope.Debug("Object already deleted", "bucket", bucket, "key", key)
Expand Down

0 comments on commit 6f7925b

Please sign in to comment.