Skip to content

Commit

Permalink
wip: Switched to in-memmory mapping store
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Kosiewski committed Oct 16, 2024
1 parent f451f40 commit 1656136
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pkg/setup/controller_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

"github.com/loft-sh/vcluster/pkg/config"
"github.com/loft-sh/vcluster/pkg/controllers/resources/nodes"
"github.com/loft-sh/vcluster/pkg/etcd"
"github.com/loft-sh/vcluster/pkg/mappings"
"github.com/loft-sh/vcluster/pkg/mappings/store"
"github.com/loft-sh/vcluster/pkg/mappings/store/verify"
Expand Down Expand Up @@ -363,10 +362,10 @@ func initControllerContext(
return nil, err
}

etcdClient, err := etcd.NewFromConfig(ctx, vClusterOptions)
if err != nil {
return nil, fmt.Errorf("create etcd client: %w", err)
}
// etcdClient, err := etcd.NewFromConfig(ctx, vClusterOptions)
// if err != nil {
// return nil, fmt.Errorf("create etcd client: %w", err)
// }

controllerContext := &synccontext.ControllerContext{
Context: ctx,
Expand All @@ -381,12 +380,17 @@ func initControllerContext(
Config: vClusterOptions,
}

mappingStore, err := store.NewStoreWithVerifyMapping(ctx, virtualManager.GetClient(), localManager.GetClient(), store.NewEtcdBackend(etcdClient), verify.NewVerifyMapping(controllerContext.ToRegisterContext().ToSyncContext("verify-mapping")))
// mappingStore, err := store.NewStoreWithVerifyMapping(ctx, virtualManager.GetClient(), localManager.GetClient(), store.NewEtcdBackend(etcdClient), verify.NewVerifyMapping(controllerContext.ToRegisterContext().ToSyncContext("verify-mapping")))
// if err != nil {
// return nil, fmt.Errorf("start mapping store: %w", err)
// }

inMemoryMappingStore, err := store.NewStoreWithVerifyMapping(ctx, virtualManager.GetClient(), localManager.GetClient(), store.NewMemoryBackend(), verify.NewVerifyMapping(controllerContext.ToRegisterContext().ToSyncContext("verify-mapping")))
if err != nil {
return nil, fmt.Errorf("start mapping store: %w", err)
return nil, fmt.Errorf("start in-memory mapping store: %w", err)
}

controllerContext.Mappings = mappings.NewMappingsRegistry(mappingStore)
controllerContext.Mappings = mappings.NewMappingsRegistry(inMemoryMappingStore)
return controllerContext, nil
}

Expand Down

0 comments on commit 1656136

Please sign in to comment.