Skip to content

Commit

Permalink
ACLs: Remove migration code (#8129)
Browse files Browse the repository at this point in the history
* ACLs: Remove migration

* CR Fixes
  • Loading branch information
N-o-Z authored Sep 4, 2024
1 parent 707deb2 commit 3a08137
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 915 deletions.
19 changes: 12 additions & 7 deletions cmd/lakefs/cmd/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (
"github.com/treeverse/lakefs/pkg/config"
"github.com/treeverse/lakefs/pkg/kv"
"github.com/treeverse/lakefs/pkg/kv/kvparams"
"github.com/treeverse/lakefs/pkg/kv/migrations"
"github.com/treeverse/lakefs/pkg/logging"
)

// migrateCmd represents the migrate command
Expand Down Expand Up @@ -102,11 +100,16 @@ var upCmd = &cobra.Command{
},
}

func DoMigration(ctx context.Context, kvStore kv.Store, cfg *config.Config, force bool) error {
func DoMigration(ctx context.Context, kvStore kv.Store, _ *config.Config, _ bool) error {
var (
version int
err error
)

// This loop performs all migration paths until reaching the latest KV schema version
// A precondition is coming up from a lakeFS version that supports KV migration (kv.InitialMigrateVersion)
// Each migration scenario is responsible also to bump the KV schema to the next version
// The iteration ends when we reach the latest version
for !kv.IsLatestSchemaVersion(version) {
version, err = kv.GetDBSchemaVersion(ctx, kvStore)
if err != nil {
Expand All @@ -115,10 +118,12 @@ func DoMigration(ctx context.Context, kvStore kv.Store, cfg *config.Config, forc
switch {
case version >= kv.NextSchemaVersion || version < kv.InitialMigrateVersion:
return fmt.Errorf("wrong starting version %d: %w", version, kv.ErrMigrationVersion)
case version < kv.ACLNoReposMigrateVersion:
err = migrations.MigrateToACL(ctx, kvStore, cfg, logging.ContextUnavailable(), version, force)
case version < kv.ACLImportMigrateVersion:
err = migrations.MigrateImportPermissions(ctx, kvStore, cfg)
// Due to removal of ACLs from lakeFS, ACL migration code is no longer needed. Users who previously used RBAC will be migrated
// directly to basic auth.
// Since there are no other migration scenarios ATM we just need to bump the schema version
// This will need to be modified once a new migration scenario is required
default:
err = kv.SetDBSchemaVersion(ctx, kvStore, kv.ACLImportMigrateVersion)
}
if err != nil {
return err
Expand Down
12 changes: 0 additions & 12 deletions cmd/lakefs/cmd/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ func TestDoMigrate(t *testing.T) {
require.True(t, kv.IsLatestSchemaVersion(version))
})

t.Run("from_acl_v1_no_force", func(t *testing.T) {
cfg := config.Config{}
cfg.Auth.UIConfig.RBAC = config.AuthRBACSimplified
kvStore := kvtest.GetStore(ctx, t)
require.NoError(t, kv.SetDBSchemaVersion(ctx, kvStore, kv.ACLMigrateVersion))
err := cmd.DoMigration(ctx, kvStore, &cfg, false)
require.ErrorIs(t, err, kv.ErrMigrationVersion)
version, err := kv.GetDBSchemaVersion(ctx, kvStore)
require.NoError(t, err)
require.Equal(t, kv.ACLMigrateVersion, version)
})

t.Run("from_acl_v1_force", func(t *testing.T) {
cfg := config.Config{}
cfg.Auth.UIConfig.RBAC = config.AuthRBACSimplified
Expand Down
53 changes: 0 additions & 53 deletions pkg/kv/migrations/import_permissions.go

This file was deleted.

Loading

0 comments on commit 3a08137

Please sign in to comment.