Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StorageID to adapter GetStorageNamespaceInfo and ResolveNamespace #8551

Merged
merged 14 commits into from
Jan 29, 2025

Conversation

itaigilo
Copy link
Contributor

Closes #8550.

Notes

  • DefaultResolveNamespace is still not using StorageID. This might be implemented later on.
  • BlockstoreType() for the stats in server Setup still needs a decision.

@itaigilo itaigilo added the exclude-changelog PR description should not be included in next release changelog label Jan 26, 2025
Copy link

E2E Test Results - Quickstart

11 passed

Copy link

E2E Test Results - DynamoDB Local - Local Block Adapter

13 passed

@@ -430,7 +430,8 @@ func checkRepos(ctx context.Context, logger logging.Logger, authMetadataManager
logger.Debug("lakeFS isn't initialized, skipping mismatched adapter checks")
} else {
logger.
WithField("adapter_type", blockStore.BlockstoreType()).
// TODO (gilo): uncomment this?
Copy link
Contributor

@nadavsteindler nadavsteindler Jan 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a log for repos validation, adding the adapter_type.
The BlockstoreType in now actually in the context of a repo -
So I think it's ok to remove this from the log.

@itaigilo itaigilo requested review from N-o-Z and guy-har January 26, 2025 15:32
Copy link
Contributor

@nadavsteindler nadavsteindler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest a slight change to the design that will make this much cleaner

pkg/api/controller.go Outdated Show resolved Hide resolved
pkg/block/adapter.go Outdated Show resolved Hide resolved
BlockstoreMetadata(ctx context.Context) (*BlockstoreMetadata, error)
GetStorageNamespaceInfo() StorageNamespaceInfo
ResolveNamespace(storageNamespace, key string, identifierType IdentifierType) (QualifiedKey, error)
BlockstoreType(storageID string) string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these methods take storageid then they need to return error in the case that they are passed an invalid storageid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Changing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added 😖

Copy link
Contributor

@nadavsteindler nadavsteindler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please have a look at my open comments

Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks,

I think we can solves this in a simpler way if we switch the wrapping order MetricsAdapter <-> BlockAdapter.
See if this makes more sense

@@ -430,7 +430,8 @@ func checkRepos(ctx context.Context, logger logging.Logger, authMetadataManager
logger.Debug("lakeFS isn't initialized, skipping mismatched adapter checks")
} else {
logger.
WithField("adapter_type", blockStore.BlockstoreType()).
// TODO (gilo): uncomment this?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Why don't we just pass the responsibility to check the repo to the block adapter, provide it with the repository object and let it do this validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might make sense.
But -
We'll anyway need to refactor this part soon, when adding a couple more validations.
So I suggest we'll postpone it to this stage.

@@ -23,12 +23,20 @@ func (m *MetricsAdapter) InnerAdapter() Adapter {
}

func (m *MetricsAdapter) Put(ctx context.Context, obj ObjectPointer, sizeBytes int64, reader io.Reader, opts PutOpts) (*PutResponse, error) {
ctx = httputil.SetClientTrace(ctx, m.adapter.BlockstoreType())
blockstoreType, err := m.adapter.BlockstoreType(obj.StorageID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought:
If BlockAdapter will wrap MetricsAdapter instead of the other way around, you'd probably won't need to provide the storageID to BlockstoreType

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this will improve the code,
And I'm kinda ok with the MetricsAdapter being a bit more "technical".

In this case also, we'll (probably) have to make such changes in this area when dealing with the stats and metrics of this change. So I suggest linking this comment to the relevant Issue, and dealing with this later.
Does this make sense to you?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean more "technical"?
Switching the wrapping order might release us from the need to pass the storageID to the blockstore type.
This PR handles the issue of "Add StorageID to adapter metadata functions". What is the relevant issue for this comment if not this one?

Copy link
Member

@N-o-Z N-o-Z Jan 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look at the example of statsCollector

Copy link
Contributor Author

@itaigilo itaigilo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@N-o-Z thanks for the interesting suggestions.

Can you PTAL again?

@@ -430,7 +430,8 @@ func checkRepos(ctx context.Context, logger logging.Logger, authMetadataManager
logger.Debug("lakeFS isn't initialized, skipping mismatched adapter checks")
} else {
logger.
WithField("adapter_type", blockStore.BlockstoreType()).
// TODO (gilo): uncomment this?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might make sense.
But -
We'll anyway need to refactor this part soon, when adding a couple more validations.
So I suggest we'll postpone it to this stage.

@@ -23,12 +23,20 @@ func (m *MetricsAdapter) InnerAdapter() Adapter {
}

func (m *MetricsAdapter) Put(ctx context.Context, obj ObjectPointer, sizeBytes int64, reader io.Reader, opts PutOpts) (*PutResponse, error) {
ctx = httputil.SetClientTrace(ctx, m.adapter.BlockstoreType())
blockstoreType, err := m.adapter.BlockstoreType(obj.StorageID)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this will improve the code,
And I'm kinda ok with the MetricsAdapter being a bit more "technical".

In this case also, we'll (probably) have to make such changes in this area when dealing with the stats and metrics of this change. So I suggest linking this comment to the relevant Issue, and dealing with this later.
Does this make sense to you?

@itaigilo itaigilo requested a review from N-o-Z January 27, 2025 19:05
@itaigilo
Copy link
Contributor Author

@N-o-Z removed storageID param from StorageType().
PTAL again.

@itaigilo itaigilo changed the title Add StorageID to adapter metadata functions Add StorageID to adapter GetStorageNamespaceInfo and ResolveNamespace Jan 29, 2025
Copy link
Member

@N-o-Z N-o-Z left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@itaigilo itaigilo enabled auto-merge (squash) January 29, 2025 17:47
@itaigilo itaigilo merged commit 9badc63 into master Jan 29, 2025
40 checks passed
@itaigilo itaigilo deleted the task/add-storage-id-to-adapter-metadata-funcs branch January 29, 2025 18:05
N-o-Z added a commit that referenced this pull request Jan 30, 2025
# This is the 1st commit message:

StorageConfigList response changes

# The commit message #2 will be skipped:

# Fix newConfig

# The commit message #3 will be skipped:

# More fixes

# The commit message #4 will be skipped:

# More fixes

# The commit message #5 will be skipped:

# Add admin/superuser error handling and cleanup (#8559)
#
# * Add admin/superuser error handling and cleanup
#
# - Added a defer function to clean up the admin user if an error occurs during creation.
# - Added tests for creating an admin user, verifying successful creation, attempting to create another admin user, deleting the admin user, creating an admin user without a secret access key, and re-adding the admin user.
# - Included a new test `TestAddAdminUser` to verify the behavior of the `AddAdminUser` function in various scenarios.
#
# * Added a logger to log the error message and warn about deleting the user

# The commit message #6 will be skipped:

# Add StorageID to adapter GetStorageNamespaceInfo and ResolveNamespace (#8551)
#
# * Add StorageID to adapter metadata functions
#
# * Fix tests
#
# * Add error handling
#
# * Fix tests
#
# * Fix lint
#
# * Revert "Fix lint"
#
# This reverts commit 850f17b.
#
# * Revert "Fix tests"
#
# This reverts commit 7bf9acc.
#
# * Revert "Add error handling"
#
# This reverts commit 9d3f0a2.
#
# * Revert "Fix tests"
#
# This reverts commit a2a4ab5.
#
# * Revert "Add StorageID to adapter metadata functions"
#
# This reverts commit 06b32ee.
#
# * Add storageID to metadata functions
#
# * Fix tests
#
# * Fix tests
#
# * Remove storageID from BlockstoreMetadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude-changelog PR description should not be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add StorageID to block.Adapter metadata functions
3 participants