head by_attribute doesn't return the latest created object #113

Closed
opened 2025-12-28 18:00:12 +00:00 by sami · 6 comments
Owner

Originally created by @evgeniiz321 on GitHub (Apr 18, 2025).

Originally assigned to: @smallhive on GitHub.

  1. Create multiple objects with same attribute
  2. Try to get by attribute -> the latest is returned as expected
  3. Try to head by attribute -> not the latest returned

See https://github.com/nspcc-dev/neofs-testcases/pull/1033, test_head_by_same_attribute
Also - https://github.com/nspcc-dev/neofs-rest-gw/pull/282

Originally created by @evgeniiz321 on GitHub (Apr 18, 2025). Originally assigned to: @smallhive on GitHub. 1. Create multiple objects with same attribute 2. Try to get by attribute -> the latest is returned as expected 3. Try to head by attribute -> not the latest returned See https://github.com/nspcc-dev/neofs-testcases/pull/1033, `test_head_by_same_attribute` Also - https://github.com/nspcc-dev/neofs-rest-gw/pull/282
sami 2025-12-28 18:00:12 +00:00
  • closed this issue
  • added the
    bug
    S4
    I4
    U1
    labels
Author
Owner

@smallhive commented on GitHub (Apr 18, 2025):

There are two moments to think:

If the test wants to get/head/filter the actual object among similar, it should always remember about https://github.com/nspcc-dev/neofs-s3-gw/pull/1104. It means you should add time.sleep(1) between each object put. Otherwise, all objects have the same creation timestamp and order is not guaranteed. This means the gate (rest and s3 as well) doesn't have the ability to understand which object is the latest.

By default, REST GW doesn't add timestamp attribute to an object. The client should add it manually, or the gate should be configured with pool.default-timestamp: true to put timestamp attribute to any object on put.

Anyway, UploadContainerObject (It is used in test, but pay attention, it is deprecated) doesn't add timestamp even with pool.default-timestamp: true.

We should consider adding a timestamp for all objects as a default attribute

@smallhive commented on GitHub (Apr 18, 2025): There are two moments to think: If the test wants to get/head/filter the actual object among similar, it should always remember about https://github.com/nspcc-dev/neofs-s3-gw/pull/1104. It means you should add `time.sleep(1)` between each object put. Otherwise, all objects have the same creation timestamp and order is not guaranteed. This means the gate (rest and s3 as well) doesn't have the ability to understand which object is the latest. By default, REST GW doesn't add `timestamp` attribute to an object. The client should add it manually, or the gate should be configured with `pool.default-timestamp: true` to put `timestamp` attribute to any object on put. Anyway, `UploadContainerObject` (It is used in test, but pay attention, it is deprecated) doesn't add `timestamp` even with `pool.default-timestamp: true`. We should consider adding a `timestamp` for all objects as a default attribute
Author
Owner

@roman-khimov commented on GitHub (Apr 21, 2025):

Tests shouldn't use deprecated methods unless they're specifically testing them (which is not the case here).

@roman-khimov commented on GitHub (Apr 21, 2025): Tests shouldn't use deprecated methods unless they're specifically testing them (which is not the case here).
Author
Owner

@evgeniiz321 commented on GitHub (Apr 21, 2025):

@smallhive i updated tests to use the new api, now i got 404 both for get and head operations -

"GET /v1/objects/ANpAUZKdtjSa9Qzy4MaiXU9dYcpUJHt8u5hQgKpNELNG/by_attribute/FileName/InterestingFileName HTTP/11" 404
@evgeniiz321 commented on GitHub (Apr 21, 2025): @smallhive i updated tests to use the new api, now i got 404 both for get and head operations - ``` "GET /v1/objects/ANpAUZKdtjSa9Qzy4MaiXU9dYcpUJHt8u5hQgKpNELNG/by_attribute/FileName/InterestingFileName HTTP/11" 404 ```
Author
Owner

@smallhive commented on GitHub (Apr 22, 2025):

The new method has a slightly different API interface. Custom attributes should be passed in X-Attributes header like a JSON map

{"FileName":"InterestingFileName"}

I suggest updating the gate config and setting up the pool.default-timestamp: trueoption. Current test doesn't passTimestamporDate` header; therefore, sorting is not stable

@smallhive commented on GitHub (Apr 22, 2025): The new method has a slightly different API interface. Custom attributes should be passed in `X-Attributes` [header](https://github.com/nspcc-dev/neofs-rest-gw/blob/3b5b65e495d23f24c83176f2d43e17f4eeb6c609/spec/rest.yaml#L1159) like a JSON map ```json {"FileName":"InterestingFileName"} ``` I suggest updating the gate config and setting up the pool.default-timestamp: true` option. Current test doesn't pass `Timestamp` or `Date` header; therefore, sorting is not stable
Author
Owner

@roman-khimov commented on GitHub (Apr 22, 2025):

For a test it can be easier to control timestamps directly. Then a separate test can check default-timestamp option.

@roman-khimov commented on GitHub (Apr 22, 2025): For a test it can be easier to control timestamps directly. Then a separate test can check `default-timestamp` option.
Author
Owner

@evgeniiz321 commented on GitHub (Apr 22, 2025):

added tests specifically for default-timestamp and updated existing to pass Timestamp. Seems working.

@evgeniiz321 commented on GitHub (Apr 22, 2025): added tests specifically for `default-timestamp` and updated existing to pass `Timestamp`. Seems working.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-rest-gw#113
No description provided.