Skip to content

Commit

Permalink
Add StorageID to some validations
Browse files Browse the repository at this point in the history
  • Loading branch information
itaigilo committed Feb 6, 2025
1 parent 3f4af4f commit e8b1aed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,7 @@ func (c *Controller) CreateRepository(w http.ResponseWriter, r *http.Request, bo
}

if !swag.BoolValue(body.ReadOnly) {
if err := c.ensureStorageNamespace(ctx, storageNamespace); err != nil {
if err := c.ensureStorageNamespace(ctx, storageID, storageNamespace); err != nil {
var (
reason string
retErr error
Expand Down Expand Up @@ -2135,7 +2135,7 @@ func (c *Controller) validateStorageNamespace(storageID, storageNamespace string
return nil
}

func (c *Controller) ensureStorageNamespace(ctx context.Context, storageNamespace string) error {
func (c *Controller) ensureStorageNamespace(ctx context.Context, storageID, storageNamespace string) error {
const (
dummyData = "this is dummy data - created by lakeFS to check accessibility"
dummyObjName = "dummy"
Expand All @@ -2148,34 +2148,34 @@ func (c *Controller) ensureStorageNamespace(ctx context.Context, storageNamespac
// this serves two purposes, first, we maintain safety check for older lakeFS version.
// second, in scenarios where lakeFS shouldn't have access to the root namespace (i.e pre-sign URL only).
if c.Config.GetBaseConfig().Graveler.EnsureReadableRootNamespace {
// TODO (gilo): ObjectPointer init - add StorageID here
rootObj := block.ObjectPointer{
StorageID: storageID,
StorageNamespace: storageNamespace,
IdentifierType: block.IdentifierTypeRelative,
Identifier: dummyObjName,
}

if s, err := c.BlockAdapter.Get(ctx, rootObj); err == nil {
_ = s.Close()
return fmt.Errorf("found lakeFS objects in the storage namespace root(%s): %w",
storageNamespace, ErrStorageNamespaceInUse)
return fmt.Errorf("found lakeFS objects in the storage root (%s:%s): %w",
storageID, storageNamespace, ErrStorageNamespaceInUse)
} else if !errors.Is(err, block.ErrDataNotFound) {
return err
}
}

// check if the dummy file exists
obj := block.ObjectPointer{
// TODO (gilo): ObjectPointer init - add StorageID here
StorageID: storageID,
StorageNamespace: storageNamespace,
IdentifierType: block.IdentifierTypeRelative,
Identifier: dummyKey,
}

if s, err := c.BlockAdapter.Get(ctx, obj); err == nil {
_ = s.Close()
return fmt.Errorf("found lakeFS objects in the storage namespace(%s) key(%s): %w",
storageNamespace, obj.Identifier, ErrStorageNamespaceInUse)
return fmt.Errorf("found lakeFS objects in the storage (%s:%s) key(%s): %w",
storageID, storageNamespace, obj.Identifier, ErrStorageNamespaceInUse)
} else if !errors.Is(err, block.ErrDataNotFound) {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/block/local/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,8 @@ func (l *Adapter) ResolveNamespace(_, storageNamespace, key string, identifierTy
}

// Check if path allowed and return error if path is not allowed
// TODO (gilo): ObjectPointer init - add StorageID here
_, err = l.extractParamsFromObj(block.ObjectPointer{
StorageID: storageID,

Check failure on line 563 in pkg/block/local/adapter.go

View workflow job for this annotation

GitHub Actions / Analyze

undefined: storageID

Check failure on line 563 in pkg/block/local/adapter.go

View workflow job for this annotation

GitHub Actions / Run Go tests

undefined: storageID

Check failure on line 563 in pkg/block/local/adapter.go

View workflow job for this annotation

GitHub Actions / Run Linters and Checkers

undefined: storageID
StorageNamespace: storageNamespace,
Identifier: key,
IdentifierType: identifierType,
Expand Down

0 comments on commit e8b1aed

Please sign in to comment.