Skip to content

Commit

Permalink
Take the grpc auth header as a signal we need to validate the remote …
Browse files Browse the repository at this point in the history
…working set
  • Loading branch information
macneale4 committed Jan 11, 2024
1 parent 69a201a commit 0a6767a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 3 additions & 1 deletion go/libraries/doltcore/dbfactory/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ var NoCachingParameter = "__dolt__NO_CACHING"

func (fact DoltRemoteFactory) newChunkStore(ctx context.Context, nbf *types.NomsBinFormat, urlObj *url.URL, params map[string]interface{}, dp GRPCDialProvider) (chunks.ChunkStore, error) {
var user string
wsValidate := false
if userParam := params[GRPCUsernameAuthParam]; userParam != nil {
user = userParam.(string)
wsValidate = true
}
cfg, err := dp.GetGRPCDialParams(grpcendpoint.Config{
Endpoint: urlObj.Host,
Expand All @@ -124,7 +126,7 @@ func (fact DoltRemoteFactory) newChunkStore(ctx context.Context, nbf *types.Noms
}

csClient := remotesapi.NewChunkStoreServiceClient(conn)
cs, err := remotestorage.NewDoltChunkStoreFromPath(ctx, nbf, urlObj.Path, urlObj.Host, csClient)
cs, err := remotestorage.NewDoltChunkStoreFromPath(ctx, nbf, urlObj.Path, urlObj.Host, wsValidate, csClient)
if err != nil {
return nil, fmt.Errorf("could not access dolt url '%s': %w", urlObj.String(), err)
}
Expand Down
12 changes: 10 additions & 2 deletions go/libraries/doltcore/remotestorage/chunk_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ type DoltChunkStore struct {
concurrency ConcurrencyParams
stats cacheStats
logger chunks.DebugLogger
wsValidate bool
}

func NewDoltChunkStoreFromPath(ctx context.Context, nbf *types.NomsBinFormat, path, host string, csClient remotesapi.ChunkStoreServiceClient) (*DoltChunkStore, error) {
func NewDoltChunkStoreFromPath(ctx context.Context, nbf *types.NomsBinFormat, path, host string, wsval bool, csClient remotesapi.ChunkStoreServiceClient) (*DoltChunkStore, error) {
var repoId *remotesapi.RepoId

path = strings.Trim(path, "/")
Expand Down Expand Up @@ -163,6 +164,7 @@ func NewDoltChunkStoreFromPath(ctx context.Context, nbf *types.NomsBinFormat, pa
nbf: nbf,
httpFetcher: globalHttpFetcher,
concurrency: defaultConcurrency,
wsValidate: wsval,
}
err = cs.loadRoot(ctx)
if err != nil {
Expand Down Expand Up @@ -872,7 +874,13 @@ func (dcs *DoltChunkStore) PushConcurrencyControl() chunks.PushConcurrencyContro
if dcs.metadata.PushConcurrencyControl == remotesapi.PushConcurrencyControl_PUSH_CONCURRENCY_CONTROL_ASSERT_WORKING_SET {
return chunks.PushConcurrencyControl_AssertWorkingSet
}
// TODO: if dcs.metadata.PushConcurrencyControl == remotesapi.PushConcurrencyControl_PUSH_CONCURRENCY_CONTROL_UNSPECIFIED && using sql-server auth...we should AssertWorkingSet here.

if dcs.metadata.PushConcurrencyControl == remotesapi.PushConcurrencyControl_PUSH_CONCURRENCY_CONTROL_UNSPECIFIED {
if dcs.wsValidate {
return chunks.PushConcurrencyControl_AssertWorkingSet
}
}

return chunks.PushConcurrencyControl_IgnoreWorkingSet
}

Expand Down

0 comments on commit 0a6767a

Please sign in to comment.