1syntax = "proto3";
2
3package gitaly;
4
5option go_package = "gitlab.com/gitlab-org/gitaly/v14/proto/go/gitalypb";
6
7import "lint.proto";
8import "shared.proto";
9
10service PraefectInfoService {
11  option (intercepted) = true;
12
13  rpc RepositoryReplicas(RepositoryReplicasRequest) returns (RepositoryReplicasResponse);
14
15  // DatalossCheck checks for unavailable repositories.
16  rpc DatalossCheck(DatalossCheckRequest) returns (DatalossCheckResponse);
17
18  // SetAuthoritativeStorage sets the authoritative storage for a repository on a given virtual storage.
19  // This causes the current version of the repository on the authoritative storage to be considered the
20  // latest and overwrite any other version on the virtual storage.
21  rpc SetAuthoritativeStorage(SetAuthoritativeStorageRequest) returns (SetAuthoritativeStorageResponse);
22
23  // SetReplicationFactor assigns or unassigns host nodes from the repository to meet the desired replication factor.
24  // SetReplicationFactor returns an error when trying to set a replication factor that exceeds the storage node count
25  // in the virtual storage. An error is also returned when trying to set a replication factor below one. The primary node
26  // won't be unassigned as it needs a copy of the repository to accept writes. Likewise, the primary is the first storage
27  // that gets assigned when setting a replication factor for a repository. Assignments of unconfigured storages are ignored.
28  // This might cause the actual replication factor to be higher than desired if the replication factor is set during an upgrade
29  // from a Praefect node that does not yet know about a new node. As assignments of unconfigured storages are ignored, replication
30  // factor of repositories assigned to a storage node removed from the cluster is effectively decreased.
31  rpc SetReplicationFactor(SetReplicationFactorRequest) returns (SetReplicationFactorResponse);
32}
33
34// SetReplicationFactorRequest sets the desired replication factor for a repository.
35message SetReplicationFactorRequest {
36  // virtual_storage is the virtual storage the repository is located in
37  string virtual_storage = 1;
38  // relative_path is the relative path of the repository
39  string relative_path = 2;
40  // replication_factor is the desired replication factor. Replication must be equal or greater than 1.
41  int32 replication_factor = 3;
42}
43
44// SetReplicationFactorResponse returns the assigned hosts after setting the desired replication factor.
45message SetReplicationFactorResponse {
46  // storages are the storages assigned to host the repository.
47  repeated string storages = 1;
48}
49
50message SetAuthoritativeStorageRequest {
51  string virtual_storage = 1;
52  string relative_path = 2;
53  string authoritative_storage = 3;
54}
55
56message SetAuthoritativeStorageResponse {}
57
58message DatalossCheckRequest {
59  string virtual_storage = 1;
60  // include_partially_unavailable indicates whether to include repositories which are available but
61  // are unavailable on some assigned storages.
62  bool include_partially_replicated = 2;
63}
64
65message DatalossCheckResponse {
66  message Repository {
67    message Storage {
68      // name of the storage
69      string name = 1;
70      // behind_by indicates how many generations this storage is behind.
71      int64 behind_by = 2;
72      // assigned indicates whether the storage is assigned to host the repository.
73      bool assigned = 3;
74      // healthy indicates whether the storage is considered healthy by the consensus of Praefect nodes.
75      bool healthy = 4;
76      // valid_primary indicates whether the storage is ready to act as the primary if necessary.
77      bool valid_primary = 5;
78    }
79
80    // relative path of the repository with outdated replicas
81    string relative_path = 1;
82    // storages on which the repository is outdated
83    repeated Storage storages = 2;
84    // unavailable indicates whether the repository is in unavailable.
85    bool unavailable = 3;
86
87    // current primary storage of the repository
88    string primary = 4;
89  }
90
91  // repositories with data loss
92  repeated Repository repositories = 2;
93}
94
95message RepositoryReplicasRequest{
96  Repository repository = 1;
97}
98
99message RepositoryReplicasResponse{
100  message RepositoryDetails {
101    Repository repository = 1;
102    string checksum = 2;
103  };
104
105  RepositoryDetails primary = 1;
106  repeated RepositoryDetails replicas = 2;
107}
108