Improve determining AccessBox latest version #335

Closed
opened 2024-03-15 13:13:11 +00:00 by dkirillov · 1 comment
Member

Currently we can have multiple AccessBox version #135. To find out which version is last we sort them by creation epoch and object id but we don't take into account S3-CRDT-Versions-Add header. If we create several versions of credentials during the same epoch we cannot be sure that the last one we created be considered s3-gw as latest (though no split brain and we exactly know the actual order and it represented in headers)

So I want the following test pass:

func TestObjectVersionsSort(t *testing.T) {
	t.Run("sort by headers", func(t *testing.T) {
		versions := NewObjectVersions("test")
		versions.AppendVersion(&ObjectVersion{Headers: versions.GetCRDTHeaders(), OjbID: getTestOID(2)})
		versions.AppendVersion(&ObjectVersion{Headers: versions.GetCRDTHeaders(), OjbID: getTestOID(3)})
		versions.AppendVersion(&ObjectVersion{Headers: versions.GetCRDTHeaders(), OjbID: getTestOID(4)})
		versions.AppendVersion(&ObjectVersion{Headers: versions.GetCRDTHeaders(), OjbID: getTestOID(1)})

		last := versions.GetLast()
		require.Equal(t, uint64(0), last.CreationEpoch)
		require.Equal(t, getTestOID(1).String(), last.VersionID())
	})
}

Describe the solution you'd like

Use S3-CRDT-Versions-Add header to know if one version is older than other (one version exists in header of other one). And only if neither one or second version id is contained in other headers use creation epoch and oid comparison

Describe alternatives you've considered

Don't do anything

Additional context

No

## Is your feature request related to a problem? Please describe. Currently we can have multiple `AccessBox` version #135. To find out which version is last we sort them [by creation epoch and object id](https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/src/commit/62cc5a04a71b3ed50f8cfe2038837fa1f13ef961/internal/frostfs/crdt/gset.go#L110) but we don't take into account `S3-CRDT-Versions-Add` header. If we create several versions of credentials during the same epoch we cannot be sure that the last one we created be considered s3-gw as latest (though no split brain and we exactly know the actual order and it represented in headers) So I want the following test pass: ```golang func TestObjectVersionsSort(t *testing.T) { t.Run("sort by headers", func(t *testing.T) { versions := NewObjectVersions("test") versions.AppendVersion(&ObjectVersion{Headers: versions.GetCRDTHeaders(), OjbID: getTestOID(2)}) versions.AppendVersion(&ObjectVersion{Headers: versions.GetCRDTHeaders(), OjbID: getTestOID(3)}) versions.AppendVersion(&ObjectVersion{Headers: versions.GetCRDTHeaders(), OjbID: getTestOID(4)}) versions.AppendVersion(&ObjectVersion{Headers: versions.GetCRDTHeaders(), OjbID: getTestOID(1)}) last := versions.GetLast() require.Equal(t, uint64(0), last.CreationEpoch) require.Equal(t, getTestOID(1).String(), last.VersionID()) }) } ``` ## Describe the solution you'd like Use `S3-CRDT-Versions-Add` header to know if one version is older than other (one version exists in header of other one). And only if neither one or second version id is contained in other headers use creation epoch and oid comparison ## Describe alternatives you've considered Don't do anything ## Additional context No
Author
Member

Done in #391

Done in https://git.frostfs.info/TrueCloudLab/frostfs-s3-gw/pulls/391
alexvanin added this to the v0.30.0 milestone 2024-07-16 11:18:57 +00:00
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: TrueCloudLab/frostfs-s3-gw#335
No description provided.