Process 'object not found' error when object is missing in object service #120

Merged
alexvanin merged 1 commits from alexvanin/frostfs-s3-gw:fix/obj-not-found into master 2023-07-26 21:08:01 +00:00

Closes #78

Closes #78
alexvanin self-assigned this 2023-05-26 15:36:59 +00:00
alexvanin force-pushed fix/obj-not-found from d09d29a259 to 1a00b843b5 2023-05-29 14:06:26 +00:00 Compare
alexvanin changed title from WIP: Process 'object not found' error when object is missing in object service to Process 'object not found' error when object is missing in object service 2023-05-29 14:22:35 +00:00
alexvanin requested review from storage-services-committers 2023-05-29 14:22:43 +00:00
alexvanin requested review from storage-services-developers 2023-05-29 14:22:43 +00:00
dkirillov reviewed 2023-05-30 08:16:15 +00:00
@ -647,2 +647,4 @@
}
if client.IsErrObjectNotFound(obj.Error) {
n.log.Debug("object not found removed", zap.String("bucket", bkt.Name), zap.Stringer("cid", bkt.CID),
Collaborator

Probably it's better omit removed word from log message

Probably it's better omit `removed` word from log message
dkirillov marked this conversation as resolved
@ -649,0 +650,4 @@
n.log.Debug("object not found removed", zap.String("bucket", bkt.Name), zap.Stringer("cid", bkt.CID),
zap.String("object", obj.Name), zap.String("oid", obj.VersionID))
obj.Error = nil
Collaborator

Don't we want to return object not found to user to tell him that something went wrong?

Don't we want to return `object not found` to user to tell him that something went wrong?
Poster
Owner

Isn't the main idea of the issue is to return no error when trying delete unavailable object?

Isn't the main idea of the issue is to return no error when trying delete unavailable object?
dkirillov marked this conversation as resolved
@ -649,0 +652,4 @@
obj.Error = nil
n.cache.DeleteObjectName(bkt.CID, bkt.Name, obj.Name)
Collaborator

Can move this out of if block to reuse with previous if?

Can move this out of `if` block to reuse with previous `if`?
Poster
Owner

Not sure, because we don't to delete cache on other errors besides not found / already removed?

Not sure, because we don't to delete cache on other errors besides not found / already removed?
Collaborator

I mean instead of:

if client.IsErrObjectAlreadyRemoved(obj.Error) {
	// ...
	n.cache.DeleteObjectName(bkt.CID, bkt.Name, obj.Name)
}

if client.IsErrObjectNotFound(obj.Error) {
	// ...
	n.cache.DeleteObjectName(bkt.CID, bkt.Name, obj.Name)
}

return obj

write:

if client.IsErrObjectAlreadyRemoved(obj.Error) {
	// ...
} else if client.IsErrObjectNotFound(obj.Error) {
	// ...
}

n.cache.DeleteObjectName(bkt.CID, bkt.Name, obj.Name)

return obj
I mean instead of: ```golang if client.IsErrObjectAlreadyRemoved(obj.Error) { // ... n.cache.DeleteObjectName(bkt.CID, bkt.Name, obj.Name) } if client.IsErrObjectNotFound(obj.Error) { // ... n.cache.DeleteObjectName(bkt.CID, bkt.Name, obj.Name) } return obj ``` write: ```golang if client.IsErrObjectAlreadyRemoved(obj.Error) { // ... } else if client.IsErrObjectNotFound(obj.Error) { // ... } n.cache.DeleteObjectName(bkt.CID, bkt.Name, obj.Name) return obj ```
Collaborator

though it's a matter of taste

though it's a matter of taste
Poster
Owner

Consider parsing "access denied" error.

First snippet does not clear the cache, second snippet does. I am not sure we want to clear cache for any error beside "not found" and "already removed".

Consider parsing "access denied" error. First snippet does not clear the cache, second snippet does. I am not sure we want to clear cache for any error beside "not found" and "already removed".
dkirillov marked this conversation as resolved
Collaborator

Let's add the following test to this file:

func TestDeleteBucketOnNotFoundError(t *testing.T) {
	hc := prepareHandlerContext(t)

	bktName, objName := "bucket-for-removal", "object-to-delete"
	bktInfo := createTestBucket(hc, bktName)

	putObject(t, hc, bktName, objName)

	nodeVersion, err := hc.tree.GetUnversioned(hc.context, bktInfo, objName)
	require.NoError(t, err)
	var addr oid.Address
	addr.SetContainer(bktInfo.CID)
	addr.SetObject(nodeVersion.OID)
	hc.tp.SetObjectError(addr, apistatus.ObjectNotFound{})

	deleteObjects(t, hc, bktName, [][2]string{{objName, emptyVersion}})

	deleteBucket(t, hc, bktName, http.StatusNoContent)
}
Let's add the following test to [this file](https://git.frostfs.info/alexvanin/frostfs-s3-gw/src/commit/1a00b843b57c5b922cb9bae783c5f8eef5df97f4/api/handler/delete_test.go#L38): ```golang func TestDeleteBucketOnNotFoundError(t *testing.T) { hc := prepareHandlerContext(t) bktName, objName := "bucket-for-removal", "object-to-delete" bktInfo := createTestBucket(hc, bktName) putObject(t, hc, bktName, objName) nodeVersion, err := hc.tree.GetUnversioned(hc.context, bktInfo, objName) require.NoError(t, err) var addr oid.Address addr.SetContainer(bktInfo.CID) addr.SetObject(nodeVersion.OID) hc.tp.SetObjectError(addr, apistatus.ObjectNotFound{}) deleteObjects(t, hc, bktName, [][2]string{{objName, emptyVersion}}) deleteBucket(t, hc, bktName, http.StatusNoContent) } ```
alexvanin force-pushed fix/obj-not-found from 1a00b843b5 to 6aa6679653 2023-06-01 12:31:28 +00:00 Compare
alexvanin force-pushed fix/obj-not-found from 6aa6679653 to 868edfdb31 2023-06-01 13:13:34 +00:00 Compare
dkirillov approved these changes 2023-06-01 14:23:25 +00:00
ironbee approved these changes 2023-06-02 13:00:49 +00:00
alexvanin merged commit 868edfdb31 into master 2023-06-02 13:04:30 +00:00
alexvanin deleted branch fix/obj-not-found 2023-06-02 13:04:32 +00:00
Sign in to join this conversation.
There is no content yet.