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

feat(kv): enable reading from URM by user index #17618

Merged
merged 2 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

### Bug Fixes

1. [17618](https://github.com/influxdata/influxdb/pull/17618): Add index for URM by user ID to improve lookup performance

### UI Improvements

1. [17714](https://github.com/influxdata/influxdb/pull/17714): Cloud environments no longer render markdown images, for security reasons.
Expand Down
11 changes: 3 additions & 8 deletions kv/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func NewService(log *zap.Logger, kv Store, configs ...ServiceConfig) *Service {
id, _ := urm.UserID.Encode()
return id, nil
},
)),
), WithIndexReadPathEnabled),
disableAuthorizationsForMaxPermissions: func(context.Context) bool {
return false
},
Expand Down Expand Up @@ -115,18 +115,13 @@ func NewService(log *zap.Logger, kv Store, configs ...ServiceConfig) *Service {
s.clock = clock.New()
}

if s.Config.URMByUserIndexReadPathEnabled {
WithIndexReadPathEnabled(s.urmByUserIndex)
}

return s
}

// ServiceConfig allows us to configure Services
type ServiceConfig struct {
SessionLength time.Duration
Clock clock.Clock
URMByUserIndexReadPathEnabled bool
SessionLength time.Duration
Clock clock.Clock
}

// AutoMigrationStore is a Store which also describes whether or not
Expand Down
12 changes: 0 additions & 12 deletions kv/urm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,10 @@ func TestBoltUserResourceMappingService(t *testing.T) {
influxdbtesting.UserResourceMappingService(initURMServiceFunc(NewTestBoltStore), t)
}

func TestBoltUserResourceMappingService_WithUserIndex(t *testing.T) {
influxdbtesting.UserResourceMappingService(initURMServiceFunc(NewTestBoltStore, kv.ServiceConfig{
URMByUserIndexReadPathEnabled: true,
}), t)
}

func TestInmemUserResourceMappingService(t *testing.T) {
influxdbtesting.UserResourceMappingService(initURMServiceFunc(NewTestBoltStore), t)
}

func TestInmemUserResourceMappingService_WithUserIndex(t *testing.T) {
influxdbtesting.UserResourceMappingService(initURMServiceFunc(NewTestBoltStore, kv.ServiceConfig{
URMByUserIndexReadPathEnabled: true,
}), t)
}

type userResourceMappingTestFunc func(influxdbtesting.UserResourceFields, *testing.T) (influxdb.UserResourceMappingService, func())

func initURMServiceFunc(storeFn func(*testing.T) (kv.Store, func(), error), confs ...kv.ServiceConfig) userResourceMappingTestFunc {
Expand Down