Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

gitserver: Clarify what RepositoryLock indicates #61862

Merged
merged 1 commit into from
Apr 18, 2024
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
6 changes: 5 additions & 1 deletion cmd/gitserver/internal/repo_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ func repoCloneProgress(fs gitserverfs.FS, locker RepositoryLocker, repo api.Repo
resp := protocol.RepoCloneProgress{
Cloned: cloned,
}
resp.CloneProgress, resp.CloneInProgress = locker.Status(repo)
cloneProgress, locked := locker.Status(repo)
if isAlwaysCloningTest(repo) {
resp.CloneInProgress = true
resp.CloneProgress = "This will never finish cloning"
}
if !cloned && locked {
resp.CloneInProgress = true
resp.CloneProgress = cloneProgress
}
return &resp, nil
}

Expand Down
6 changes: 5 additions & 1 deletion cmd/gitserver/internal/server_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,11 @@ func (gs *grpcServer) checkRepoExists(ctx context.Context, repo api.RepoName) er
}
}

cloneProgress, cloneInProgress := gs.locker.Status(repo)
cloneProgress, locked := gs.locker.Status(repo)

// We checked above that the repo is not cloned. So if the repo is currently
// locked, it must be a clone in progress.
cloneInProgress := locked

return newRepoNotFoundError(repo, cloneInProgress, cloneProgress)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/gitserver/internal/serverutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (
"github.com/sourcegraph/sourcegraph/internal/types"
)

func cloneStatus(cloned, cloning bool) types.CloneStatus {
func cloneStatus(cloned, locked bool) types.CloneStatus {
switch {
case cloned:
return types.CloneStatusCloned
case cloning:
case locked:
return types.CloneStatusCloning
}
return types.CloneStatusNotCloned
Expand Down
4 changes: 2 additions & 2 deletions cmd/gitserver/internal/statesyncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ func syncRepoState(
// Failed to determine cloned state, we have to skip this record for now.
continue
}
_, cloning := locker.Status(repo.Name)
_, locked := locker.Status(repo.Name)

var shouldUpdate bool
if repo.ShardID != shardID {
repo.ShardID = shardID
shouldUpdate = true
}
cloneStatus := cloneStatus(cloned, cloning)
cloneStatus := cloneStatus(cloned, locked)
if repo.CloneStatus != cloneStatus {
repo.CloneStatus = cloneStatus
// Since the repo has been recloned or is being cloned
Expand Down