fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

feat/indexserver: extend UpdateIndexStatus request (#1068)

Add repository state and failure message fields to UpdateIndexStatusRequest.

+295 -109
+168 -82
cmd/zoekt-sourcegraph-indexserver/grpc/protos/sourcegraph/zoekt/configuration/v1/configuration.pb.go
··· 73 73 return file_sourcegraph_zoekt_configuration_v1_configuration_proto_rawDescGZIP(), []int{0} 74 74 } 75 75 76 + type UpdateIndexStatusRequest_Repository_State int32 77 + 78 + const ( 79 + UpdateIndexStatusRequest_Repository_STATE_UNSPECIFIED UpdateIndexStatusRequest_Repository_State = 0 80 + UpdateIndexStatusRequest_Repository_STATE_SUCCESS UpdateIndexStatusRequest_Repository_State = 1 81 + UpdateIndexStatusRequest_Repository_STATE_FAILURE UpdateIndexStatusRequest_Repository_State = 2 82 + ) 83 + 84 + // Enum value maps for UpdateIndexStatusRequest_Repository_State. 85 + var ( 86 + UpdateIndexStatusRequest_Repository_State_name = map[int32]string{ 87 + 0: "STATE_UNSPECIFIED", 88 + 1: "STATE_SUCCESS", 89 + 2: "STATE_FAILURE", 90 + } 91 + UpdateIndexStatusRequest_Repository_State_value = map[string]int32{ 92 + "STATE_UNSPECIFIED": 0, 93 + "STATE_SUCCESS": 1, 94 + "STATE_FAILURE": 2, 95 + } 96 + ) 97 + 98 + func (x UpdateIndexStatusRequest_Repository_State) Enum() *UpdateIndexStatusRequest_Repository_State { 99 + p := new(UpdateIndexStatusRequest_Repository_State) 100 + *p = x 101 + return p 102 + } 103 + 104 + func (x UpdateIndexStatusRequest_Repository_State) String() string { 105 + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) 106 + } 107 + 108 + func (UpdateIndexStatusRequest_Repository_State) Descriptor() protoreflect.EnumDescriptor { 109 + return file_sourcegraph_zoekt_configuration_v1_configuration_proto_enumTypes[1].Descriptor() 110 + } 111 + 112 + func (UpdateIndexStatusRequest_Repository_State) Type() protoreflect.EnumType { 113 + return &file_sourcegraph_zoekt_configuration_v1_configuration_proto_enumTypes[1] 114 + } 115 + 116 + func (x UpdateIndexStatusRequest_Repository_State) Number() protoreflect.EnumNumber { 117 + return protoreflect.EnumNumber(x) 118 + } 119 + 120 + // Deprecated: Use UpdateIndexStatusRequest_Repository_State.Descriptor instead. 121 + func (UpdateIndexStatusRequest_Repository_State) EnumDescriptor() ([]byte, []int) { 122 + return file_sourcegraph_zoekt_configuration_v1_configuration_proto_rawDescGZIP(), []int{8, 0, 0} 123 + } 124 + 76 125 // SearchConfigurationRequest is the request to the SearchConfiguration RPC. 77 126 type SearchConfigurationRequest struct { 78 127 state protoimpl.MessageState ··· 748 797 Branches []*ZoektRepositoryBranch `protobuf:"bytes,2,rep,name=branches,proto3" json:"branches,omitempty"` 749 798 // index_time_unix is the unix timestamp for when the index was created. 750 799 IndexTimeUnix int64 `protobuf:"varint,3,opt,name=index_time_unix,json=indexTimeUnix,proto3" json:"index_time_unix,omitempty"` 800 + // state describes the outcome of the most recent indexing attempt. 801 + // 802 + // Unspecified is treated as success by the server for backwards compatibility 803 + // with older clients that only reported successful indexing. 804 + State UpdateIndexStatusRequest_Repository_State `protobuf:"varint,4,opt,name=state,proto3,enum=sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest_Repository_State" json:"state,omitempty"` 805 + // failure_message describes the most recent indexing failure when state is failure. 806 + FailureMessage string `protobuf:"bytes,5,opt,name=failure_message,json=failureMessage,proto3" json:"failure_message,omitempty"` 751 807 } 752 808 753 809 func (x *UpdateIndexStatusRequest_Repository) Reset() { ··· 801 857 return x.IndexTimeUnix 802 858 } 803 859 return 0 860 + } 861 + 862 + func (x *UpdateIndexStatusRequest_Repository) GetState() UpdateIndexStatusRequest_Repository_State { 863 + if x != nil { 864 + return x.State 865 + } 866 + return UpdateIndexStatusRequest_Repository_STATE_UNSPECIFIED 867 + } 868 + 869 + func (x *UpdateIndexStatusRequest_Repository) GetFailureMessage() string { 870 + if x != nil { 871 + return x.FailureMessage 872 + } 873 + return "" 804 874 } 805 875 806 876 var File_sourcegraph_zoekt_configuration_v1_configuration_proto protoreflect.FileDescriptor ··· 896 966 0x03, 0x28, 0x05, 0x52, 0x0a, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x64, 0x49, 0x64, 0x73, 0x22, 897 967 0x29, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 898 968 0x19, 0x0a, 0x08, 0x72, 0x65, 0x70, 0x6f, 0x5f, 0x69, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 899 - 0x05, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6f, 0x49, 0x64, 0x73, 0x22, 0xae, 0x02, 0x0a, 0x18, 0x55, 969 + 0x05, 0x52, 0x07, 0x72, 0x65, 0x70, 0x6f, 0x49, 0x64, 0x73, 0x22, 0x82, 0x04, 0x0a, 0x18, 0x55, 900 970 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 901 971 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x6b, 0x0a, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 902 972 0x69, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x47, 0x2e, ··· 905 975 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 906 976 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x52, 0x65, 0x70, 0x6f, 907 977 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x0c, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 908 - 0x72, 0x69, 0x65, 0x73, 0x1a, 0xa4, 0x01, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 978 + 0x72, 0x69, 0x65, 0x73, 0x1a, 0xf8, 0x02, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 909 979 0x6f, 0x72, 0x79, 0x12, 0x17, 0x0a, 0x07, 0x72, 0x65, 0x70, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, 910 980 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x49, 0x64, 0x12, 0x55, 0x0a, 0x08, 911 981 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x39, ··· 915 985 0x6f, 0x72, 0x79, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x52, 0x08, 0x62, 0x72, 0x61, 0x6e, 0x63, 916 986 0x68, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x74, 0x69, 0x6d, 917 987 0x65, 0x5f, 0x75, 0x6e, 0x69, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x69, 0x6e, 918 - 0x64, 0x65, 0x78, 0x54, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, 0x78, 0x22, 0x1b, 0x0a, 0x19, 0x55, 919 - 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 920 - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x91, 0x01, 0x0a, 0x0f, 0x43, 0x54, 0x61, 921 - 0x67, 0x73, 0x50, 0x61, 0x72, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x22, 0x0a, 0x1e, 922 - 0x43, 0x5f, 0x54, 0x41, 0x47, 0x53, 0x5f, 0x50, 0x41, 0x52, 0x53, 0x45, 0x52, 0x5f, 0x54, 0x59, 923 - 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 924 - 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x5f, 0x54, 0x41, 0x47, 0x53, 0x5f, 0x50, 0x41, 0x52, 0x53, 0x45, 925 - 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x20, 0x0a, 926 - 0x1c, 0x43, 0x5f, 0x54, 0x41, 0x47, 0x53, 0x5f, 0x50, 0x41, 0x52, 0x53, 0x45, 0x52, 0x5f, 0x54, 927 - 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x49, 0x56, 0x45, 0x52, 0x53, 0x41, 0x4c, 0x10, 0x02, 0x12, 928 - 0x1b, 0x0a, 0x17, 0x43, 0x5f, 0x54, 0x41, 0x47, 0x53, 0x5f, 0x50, 0x41, 0x52, 0x53, 0x45, 0x52, 929 - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x43, 0x49, 0x50, 0x10, 0x03, 0x32, 0xb8, 0x03, 0x0a, 930 - 0x19, 0x5a, 0x6f, 0x65, 0x6b, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 931 - 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x98, 0x01, 0x0a, 0x13, 0x53, 932 - 0x65, 0x61, 0x72, 0x63, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 933 - 0x6f, 0x6e, 0x12, 0x3e, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 988 + 0x64, 0x65, 0x78, 0x54, 0x69, 0x6d, 0x65, 0x55, 0x6e, 0x69, 0x78, 0x12, 0x63, 0x0a, 0x05, 0x73, 989 + 0x74, 0x61, 0x74, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x4d, 0x2e, 0x73, 0x6f, 0x75, 990 + 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2e, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2e, 0x63, 991 + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 992 + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 0x61, 0x74, 0x75, 993 + 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 994 + 0x6f, 0x72, 0x79, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x52, 0x05, 0x73, 0x74, 0x61, 0x74, 0x65, 995 + 0x12, 0x27, 0x0a, 0x0f, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x5f, 0x6d, 0x65, 0x73, 0x73, 996 + 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x66, 0x61, 0x69, 0x6c, 0x75, 997 + 0x72, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x44, 0x0a, 0x05, 0x53, 0x74, 0x61, 998 + 0x74, 0x65, 0x12, 0x15, 0x0a, 0x11, 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 999 + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 1000 + 0x54, 0x45, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 1001 + 0x53, 0x54, 0x41, 0x54, 0x45, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, 0x02, 0x22, 1002 + 0x1b, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 1003 + 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x91, 0x01, 0x0a, 1004 + 0x0f, 0x43, 0x54, 0x61, 0x67, 0x73, 0x50, 0x61, 0x72, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 1005 + 0x12, 0x22, 0x0a, 0x1e, 0x43, 0x5f, 0x54, 0x41, 0x47, 0x53, 0x5f, 0x50, 0x41, 0x52, 0x53, 0x45, 1006 + 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 1007 + 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x5f, 0x54, 0x41, 0x47, 0x53, 0x5f, 0x50, 1008 + 0x41, 0x52, 0x53, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 1009 + 0x01, 0x12, 0x20, 0x0a, 0x1c, 0x43, 0x5f, 0x54, 0x41, 0x47, 0x53, 0x5f, 0x50, 0x41, 0x52, 0x53, 1010 + 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x49, 0x56, 0x45, 0x52, 0x53, 0x41, 1011 + 0x4c, 0x10, 0x02, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x5f, 0x54, 0x41, 0x47, 0x53, 0x5f, 0x50, 0x41, 1012 + 0x52, 0x53, 0x45, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x53, 0x43, 0x49, 0x50, 0x10, 0x03, 1013 + 0x32, 0xb8, 0x03, 0x0a, 0x19, 0x5a, 0x6f, 0x65, 0x6b, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 1014 + 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x98, 1015 + 0x01, 0x0a, 0x13, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 1016 + 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3e, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 1017 + 0x72, 0x61, 0x70, 0x68, 0x2e, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 1018 + 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 1019 + 0x63, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 1020 + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 1021 + 0x72, 0x61, 0x70, 0x68, 0x2e, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 1022 + 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 1023 + 0x63, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 1024 + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6b, 0x0a, 0x04, 0x4c, 0x69, 0x73, 1025 + 0x74, 0x12, 0x2f, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2e, 1026 + 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 1027 + 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 1028 + 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 934 1029 0x2e, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 935 - 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x43, 0x6f, 936 - 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 937 - 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 938 - 0x2e, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 939 - 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x43, 0x6f, 940 - 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 941 - 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6b, 0x0a, 0x04, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x2e, 942 - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2e, 0x7a, 0x6f, 0x65, 0x6b, 943 - 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 944 - 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 945 - 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2e, 0x7a, 0x6f, 0x65, 946 - 0x6b, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 947 - 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 948 - 0x22, 0x00, 0x12, 0x92, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 949 - 0x65, 0x78, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3c, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 950 - 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2e, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 951 - 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 952 - 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 953 - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3d, 0x2e, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 954 - 0x72, 0x61, 0x70, 0x68, 0x2e, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 955 - 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 956 - 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 957 - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x6f, 0x5a, 0x6d, 0x67, 0x69, 0x74, 0x68, 0x75, 958 - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 959 - 0x68, 0x2f, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x7a, 0x6f, 0x65, 0x6b, 960 - 0x74, 0x2d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2d, 0x69, 0x6e, 961 - 0x64, 0x65, 0x78, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 962 - 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 963 - 0x68, 0x2f, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 964 - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 1030 + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 1031 + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x92, 0x01, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 1032 + 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x3c, 0x2e, 0x73, 1033 + 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2e, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 1034 + 0x2e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 1035 + 0x31, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 0x61, 1036 + 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3d, 0x2e, 0x73, 0x6f, 0x75, 1037 + 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2e, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2e, 0x63, 1038 + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 1039 + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x53, 0x74, 0x61, 0x74, 0x75, 1040 + 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x6f, 0x5a, 0x6d, 0x67, 1041 + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 1042 + 0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 1043 + 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 1044 + 0x68, 0x2d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x67, 0x72, 1045 + 0x70, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 1046 + 0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 0x7a, 0x6f, 0x65, 0x6b, 0x74, 0x2f, 0x63, 0x6f, 0x6e, 0x66, 1047 + 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 1048 + 0x6f, 0x74, 0x6f, 0x33, 965 1049 } 966 1050 967 1051 var ( ··· 976 1060 return file_sourcegraph_zoekt_configuration_v1_configuration_proto_rawDescData 977 1061 } 978 1062 979 - var file_sourcegraph_zoekt_configuration_v1_configuration_proto_enumTypes = make([]protoimpl.EnumInfo, 1) 1063 + var file_sourcegraph_zoekt_configuration_v1_configuration_proto_enumTypes = make([]protoimpl.EnumInfo, 2) 980 1064 var file_sourcegraph_zoekt_configuration_v1_configuration_proto_msgTypes = make([]protoimpl.MessageInfo, 11) 981 1065 var file_sourcegraph_zoekt_configuration_v1_configuration_proto_goTypes = []interface{}{ 982 - (CTagsParserType)(0), // 0: sourcegraph.zoekt.configuration.v1.CTagsParserType 983 - (*SearchConfigurationRequest)(nil), // 1: sourcegraph.zoekt.configuration.v1.SearchConfigurationRequest 984 - (*SearchConfigurationResponse)(nil), // 2: sourcegraph.zoekt.configuration.v1.SearchConfigurationResponse 985 - (*Fingerprint)(nil), // 3: sourcegraph.zoekt.configuration.v1.Fingerprint 986 - (*LanguageMapping)(nil), // 4: sourcegraph.zoekt.configuration.v1.LanguageMapping 987 - (*ZoektIndexOptions)(nil), // 5: sourcegraph.zoekt.configuration.v1.ZoektIndexOptions 988 - (*ZoektRepositoryBranch)(nil), // 6: sourcegraph.zoekt.configuration.v1.ZoektRepositoryBranch 989 - (*ListRequest)(nil), // 7: sourcegraph.zoekt.configuration.v1.ListRequest 990 - (*ListResponse)(nil), // 8: sourcegraph.zoekt.configuration.v1.ListResponse 991 - (*UpdateIndexStatusRequest)(nil), // 9: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest 992 - (*UpdateIndexStatusResponse)(nil), // 10: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusResponse 993 - (*UpdateIndexStatusRequest_Repository)(nil), // 11: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.Repository 994 - (*timestamppb.Timestamp)(nil), // 12: google.protobuf.Timestamp 1066 + (CTagsParserType)(0), // 0: sourcegraph.zoekt.configuration.v1.CTagsParserType 1067 + (UpdateIndexStatusRequest_Repository_State)(0), // 1: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.Repository.State 1068 + (*SearchConfigurationRequest)(nil), // 2: sourcegraph.zoekt.configuration.v1.SearchConfigurationRequest 1069 + (*SearchConfigurationResponse)(nil), // 3: sourcegraph.zoekt.configuration.v1.SearchConfigurationResponse 1070 + (*Fingerprint)(nil), // 4: sourcegraph.zoekt.configuration.v1.Fingerprint 1071 + (*LanguageMapping)(nil), // 5: sourcegraph.zoekt.configuration.v1.LanguageMapping 1072 + (*ZoektIndexOptions)(nil), // 6: sourcegraph.zoekt.configuration.v1.ZoektIndexOptions 1073 + (*ZoektRepositoryBranch)(nil), // 7: sourcegraph.zoekt.configuration.v1.ZoektRepositoryBranch 1074 + (*ListRequest)(nil), // 8: sourcegraph.zoekt.configuration.v1.ListRequest 1075 + (*ListResponse)(nil), // 9: sourcegraph.zoekt.configuration.v1.ListResponse 1076 + (*UpdateIndexStatusRequest)(nil), // 10: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest 1077 + (*UpdateIndexStatusResponse)(nil), // 11: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusResponse 1078 + (*UpdateIndexStatusRequest_Repository)(nil), // 12: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.Repository 1079 + (*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp 995 1080 } 996 1081 var file_sourcegraph_zoekt_configuration_v1_configuration_proto_depIdxs = []int32{ 997 - 3, // 0: sourcegraph.zoekt.configuration.v1.SearchConfigurationRequest.fingerprint:type_name -> sourcegraph.zoekt.configuration.v1.Fingerprint 998 - 3, // 1: sourcegraph.zoekt.configuration.v1.SearchConfigurationResponse.fingerprint:type_name -> sourcegraph.zoekt.configuration.v1.Fingerprint 999 - 5, // 2: sourcegraph.zoekt.configuration.v1.SearchConfigurationResponse.updated_options:type_name -> sourcegraph.zoekt.configuration.v1.ZoektIndexOptions 1000 - 12, // 3: sourcegraph.zoekt.configuration.v1.Fingerprint.generated_at:type_name -> google.protobuf.Timestamp 1082 + 4, // 0: sourcegraph.zoekt.configuration.v1.SearchConfigurationRequest.fingerprint:type_name -> sourcegraph.zoekt.configuration.v1.Fingerprint 1083 + 4, // 1: sourcegraph.zoekt.configuration.v1.SearchConfigurationResponse.fingerprint:type_name -> sourcegraph.zoekt.configuration.v1.Fingerprint 1084 + 6, // 2: sourcegraph.zoekt.configuration.v1.SearchConfigurationResponse.updated_options:type_name -> sourcegraph.zoekt.configuration.v1.ZoektIndexOptions 1085 + 13, // 3: sourcegraph.zoekt.configuration.v1.Fingerprint.generated_at:type_name -> google.protobuf.Timestamp 1001 1086 0, // 4: sourcegraph.zoekt.configuration.v1.LanguageMapping.ctags:type_name -> sourcegraph.zoekt.configuration.v1.CTagsParserType 1002 - 6, // 5: sourcegraph.zoekt.configuration.v1.ZoektIndexOptions.branches:type_name -> sourcegraph.zoekt.configuration.v1.ZoektRepositoryBranch 1003 - 4, // 6: sourcegraph.zoekt.configuration.v1.ZoektIndexOptions.language_map:type_name -> sourcegraph.zoekt.configuration.v1.LanguageMapping 1004 - 11, // 7: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.repositories:type_name -> sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.Repository 1005 - 6, // 8: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.Repository.branches:type_name -> sourcegraph.zoekt.configuration.v1.ZoektRepositoryBranch 1006 - 1, // 9: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.SearchConfiguration:input_type -> sourcegraph.zoekt.configuration.v1.SearchConfigurationRequest 1007 - 7, // 10: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.List:input_type -> sourcegraph.zoekt.configuration.v1.ListRequest 1008 - 9, // 11: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.UpdateIndexStatus:input_type -> sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest 1009 - 2, // 12: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.SearchConfiguration:output_type -> sourcegraph.zoekt.configuration.v1.SearchConfigurationResponse 1010 - 8, // 13: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.List:output_type -> sourcegraph.zoekt.configuration.v1.ListResponse 1011 - 10, // 14: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.UpdateIndexStatus:output_type -> sourcegraph.zoekt.configuration.v1.UpdateIndexStatusResponse 1012 - 12, // [12:15] is the sub-list for method output_type 1013 - 9, // [9:12] is the sub-list for method input_type 1014 - 9, // [9:9] is the sub-list for extension type_name 1015 - 9, // [9:9] is the sub-list for extension extendee 1016 - 0, // [0:9] is the sub-list for field type_name 1087 + 7, // 5: sourcegraph.zoekt.configuration.v1.ZoektIndexOptions.branches:type_name -> sourcegraph.zoekt.configuration.v1.ZoektRepositoryBranch 1088 + 5, // 6: sourcegraph.zoekt.configuration.v1.ZoektIndexOptions.language_map:type_name -> sourcegraph.zoekt.configuration.v1.LanguageMapping 1089 + 12, // 7: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.repositories:type_name -> sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.Repository 1090 + 7, // 8: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.Repository.branches:type_name -> sourcegraph.zoekt.configuration.v1.ZoektRepositoryBranch 1091 + 1, // 9: sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.Repository.state:type_name -> sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest.Repository.State 1092 + 2, // 10: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.SearchConfiguration:input_type -> sourcegraph.zoekt.configuration.v1.SearchConfigurationRequest 1093 + 8, // 11: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.List:input_type -> sourcegraph.zoekt.configuration.v1.ListRequest 1094 + 10, // 12: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.UpdateIndexStatus:input_type -> sourcegraph.zoekt.configuration.v1.UpdateIndexStatusRequest 1095 + 3, // 13: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.SearchConfiguration:output_type -> sourcegraph.zoekt.configuration.v1.SearchConfigurationResponse 1096 + 9, // 14: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.List:output_type -> sourcegraph.zoekt.configuration.v1.ListResponse 1097 + 11, // 15: sourcegraph.zoekt.configuration.v1.ZoektConfigurationService.UpdateIndexStatus:output_type -> sourcegraph.zoekt.configuration.v1.UpdateIndexStatusResponse 1098 + 13, // [13:16] is the sub-list for method output_type 1099 + 10, // [10:13] is the sub-list for method input_type 1100 + 10, // [10:10] is the sub-list for extension type_name 1101 + 10, // [10:10] is the sub-list for extension extendee 1102 + 0, // [0:10] is the sub-list for field type_name 1017 1103 } 1018 1104 1019 1105 func init() { file_sourcegraph_zoekt_configuration_v1_configuration_proto_init() } ··· 1160 1246 File: protoimpl.DescBuilder{ 1161 1247 GoPackagePath: reflect.TypeOf(x{}).PkgPath(), 1162 1248 RawDescriptor: file_sourcegraph_zoekt_configuration_v1_configuration_proto_rawDesc, 1163 - NumEnums: 1, 1249 + NumEnums: 2, 1164 1250 NumMessages: 11, 1165 1251 NumExtensions: 0, 1166 1252 NumServices: 1,
+15
cmd/zoekt-sourcegraph-indexserver/grpc/protos/sourcegraph/zoekt/configuration/v1/configuration.proto
··· 146 146 // UpdateIndexStatusRequest is the request to the UpdateIndexStatus RPC. 147 147 message UpdateIndexStatusRequest { 148 148 message Repository { 149 + enum State { 150 + STATE_UNSPECIFIED = 0; 151 + STATE_SUCCESS = 1; 152 + STATE_FAILURE = 2; 153 + } 154 + 149 155 // repo_id is the Sourcegraph repository ID. 150 156 uint32 repo_id = 1; 151 157 ··· 154 160 155 161 // index_time_unix is the unix timestamp for when the index was created. 156 162 int64 index_time_unix = 3; 163 + 164 + // state describes the outcome of the most recent indexing attempt. 165 + // 166 + // Unspecified is treated as success by the server for backwards compatibility 167 + // with older clients that only reported successful indexing. 168 + State state = 4; 169 + 170 + // failure_message describes the most recent indexing failure when state is failure. 171 + string failure_message = 5; 157 172 } 158 173 159 174 repeated Repository repositories = 1;
+55 -1
cmd/zoekt-sourcegraph-indexserver/index_integration_test.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "errors" 5 6 "fmt" 6 7 "net" 7 8 "os" ··· 16 17 "github.com/stretchr/testify/require" 17 18 18 19 "github.com/sourcegraph/zoekt" 20 + configv1 "github.com/sourcegraph/zoekt/cmd/zoekt-sourcegraph-indexserver/grpc/protos/sourcegraph/zoekt/configuration/v1" 19 21 "github.com/sourcegraph/zoekt/gitindex" 20 22 "github.com/sourcegraph/zoekt/query" 21 23 "github.com/sourcegraph/zoekt/search" ··· 112 114 assertSearchContains(t, searcher, "devneedle", "dev.txt") 113 115 assertSearchEmpty(t, searcher, "largeneedle") 114 116 115 - require.NoError(updateIndexStatusOnSourcegraph(c, args, sg)) 117 + require.NoError(updateIndexStatusOnSourcegraph(c, args, sg, nil)) 116 118 require.Len(sg.updates, 1) 117 119 require.Len(sg.updates[0], 1) 118 120 require.Equal(args.RepoID, sg.updates[0][0].RepoID) 119 121 require.Equal(metadata.IndexTime.Unix(), sg.updates[0][0].IndexTimeUnix) 122 + require.Equal(configv1.UpdateIndexStatusRequest_Repository_STATE_SUCCESS, sg.updates[0][0].State) 123 + require.Empty(sg.updates[0][0].FailureMessage) 124 + if diff := cmp.Diff(args.Branches, sg.updates[0][0].Branches); diff != "" { 125 + t.Fatalf("status branches mismatch (-want +got):\n%s", diff) 126 + } 127 + }) 128 + } 129 + } 130 + 131 + func TestUpdateIndexStatusOnSourcegraphFailure(t *testing.T) { 132 + indexTime := time.Unix(123, 0) 133 + 134 + for _, tc := range []struct { 135 + name string 136 + metadata *zoekt.IndexMetadata 137 + metadataOK bool 138 + metadataErr error 139 + wantIndexTime int64 140 + }{ 141 + { 142 + name: "metadata available", 143 + metadata: &zoekt.IndexMetadata{IndexTime: indexTime}, 144 + metadataOK: true, 145 + wantIndexTime: indexTime.Unix(), 146 + }, 147 + { 148 + name: "metadata unavailable", 149 + metadataErr: errors.New("metadata boom"), 150 + }, 151 + } { 152 + t.Run(tc.name, func(t *testing.T) { 153 + sg := &recordingSourcegraph{} 154 + args := &indexArgs{IndexOptions: IndexOptions{ 155 + RepoID: 123, 156 + Name: "test/repo", 157 + Branches: []zoekt.RepositoryBranch{ 158 + {Name: "HEAD", Version: "deadbeef"}, 159 + }, 160 + }} 161 + c := gitIndexConfig{ 162 + findRepositoryMetadata: func(args *indexArgs) (repository *zoekt.Repository, metadata *zoekt.IndexMetadata, ok bool, err error) { 163 + return nil, tc.metadata, tc.metadataOK, tc.metadataErr 164 + }, 165 + } 166 + 167 + require.NoError(t, updateIndexStatusOnSourcegraph(c, args, sg, errors.New("boom"))) 168 + require.Len(t, sg.updates, 1) 169 + require.Len(t, sg.updates[0], 1) 170 + require.Equal(t, args.RepoID, sg.updates[0][0].RepoID) 171 + require.Equal(t, tc.wantIndexTime, sg.updates[0][0].IndexTimeUnix) 172 + require.Equal(t, configv1.UpdateIndexStatusRequest_Repository_STATE_FAILURE, sg.updates[0][0].State) 173 + require.Equal(t, "boom", sg.updates[0][0].FailureMessage) 120 174 if diff := cmp.Diff(args.Branches, sg.updates[0][0].Branches); diff != "" { 121 175 t.Fatalf("status branches mismatch (-want +got):\n%s", diff) 122 176 }
+42 -17
cmd/zoekt-sourcegraph-indexserver/main.go
··· 675 675 timeout: s.timeout, 676 676 } 677 677 678 - err = gitIndex(ctx, c, args, s.Sourcegraph, s.logger) 679 - if err != nil { 680 - return indexStateFail, err 681 - } 682 - 683 - if err := updateIndexStatusOnSourcegraph(c, args, s.Sourcegraph); err != nil { 678 + logIndexStatusUpdateError := func(err error) { 684 679 s.logger.Error("failed to update index status", 685 680 sglog.String("repo", args.Name), 686 681 sglog.Uint32("id", args.RepoID), ··· 689 684 ) 690 685 } 691 686 687 + err = gitIndex(ctx, c, args, s.Sourcegraph, s.logger) 688 + if err != nil { 689 + if statusErr := updateIndexStatusOnSourcegraph(c, args, s.Sourcegraph, err); statusErr != nil { 690 + logIndexStatusUpdateError(statusErr) 691 + } 692 + return indexStateFail, err 693 + } 694 + 695 + if err := updateIndexStatusOnSourcegraph(c, args, s.Sourcegraph, nil); err != nil { 696 + logIndexStatusUpdateError(err) 697 + } 698 + 692 699 return indexStateSuccess, nil 693 700 } 694 701 695 702 // updateIndexStatusOnSourcegraph pushes the current state to sourcegraph so 696 703 // it can update the zoekt_repos table. 697 - func updateIndexStatusOnSourcegraph(c gitIndexConfig, args *indexArgs, sg Sourcegraph) error { 698 - // We need to read from disk for IndexTime. 699 - _, metadata, ok, err := c.findRepositoryMetadata(args) 700 - if err != nil { 701 - return fmt.Errorf("failed to read metadata for new/updated index: %w", err) 702 - } 703 - if !ok { 704 - return errors.New("failed to find metadata for new/updated index") 704 + func updateIndexStatusOnSourcegraph(c gitIndexConfig, args *indexArgs, sg Sourcegraph, indexErr error) error { 705 + state := configv1.UpdateIndexStatusRequest_Repository_STATE_SUCCESS 706 + var failureMessage string 707 + var indexTimeUnix int64 708 + if indexErr != nil { 709 + state = configv1.UpdateIndexStatusRequest_Repository_STATE_FAILURE 710 + failureMessage = indexErr.Error() 711 + 712 + // On failure, metadata may not exist yet. Include index time if we can, 713 + // but do not block reporting the failure status. 714 + if _, metadata, ok, err := c.findRepositoryMetadata(args); err == nil && ok { 715 + indexTimeUnix = metadata.IndexTime.Unix() 716 + } 717 + } else { 718 + // We need to read from disk for IndexTime. 719 + _, metadata, ok, err := c.findRepositoryMetadata(args) 720 + if err != nil { 721 + return fmt.Errorf("failed to read metadata for new/updated index: %w", err) 722 + } 723 + if !ok { 724 + return errors.New("failed to find metadata for new/updated index") 725 + } 726 + indexTimeUnix = metadata.IndexTime.Unix() 705 727 } 706 728 707 729 status := []indexStatus{{ 708 - RepoID: args.RepoID, 709 - Branches: args.Branches, 710 - IndexTimeUnix: metadata.IndexTime.Unix(), 730 + RepoID: args.RepoID, 731 + Branches: args.Branches, 732 + IndexTimeUnix: indexTimeUnix, 733 + State: state, 734 + FailureMessage: failureMessage, 711 735 }} 736 + 712 737 if err := sg.UpdateIndexStatus(status); err != nil { 713 738 return fmt.Errorf("failed to update sourcegraph with status: %w", err) 714 739 }
+15 -9
cmd/zoekt-sourcegraph-indexserver/sg.go
··· 369 369 } 370 370 371 371 type indexStatus struct { 372 - RepoID uint32 373 - Branches []zoekt.RepositoryBranch 374 - IndexTimeUnix int64 372 + RepoID uint32 373 + Branches []zoekt.RepositoryBranch 374 + IndexTimeUnix int64 375 + State configv1.UpdateIndexStatusRequest_Repository_State 376 + FailureMessage string 375 377 } 376 378 377 379 type updateIndexStatusRequest struct { ··· 392 394 } 393 395 394 396 repositories = append(repositories, &configv1.UpdateIndexStatusRequest_Repository{ 395 - RepoId: repo.RepoID, 396 - Branches: branches, 397 - IndexTimeUnix: repo.IndexTimeUnix, 397 + RepoId: repo.RepoID, 398 + Branches: branches, 399 + IndexTimeUnix: repo.IndexTimeUnix, 400 + State: repo.State, 401 + FailureMessage: repo.FailureMessage, 398 402 }) 399 403 } 400 404 ··· 419 423 } 420 424 421 425 repositories = append(repositories, indexStatus{ 422 - RepoID: repo.GetRepoId(), 423 - Branches: branches, 424 - IndexTimeUnix: repo.GetIndexTimeUnix(), 426 + RepoID: repo.GetRepoId(), 427 + Branches: branches, 428 + IndexTimeUnix: repo.GetIndexTimeUnix(), 429 + State: repo.GetState(), 430 + FailureMessage: repo.GetFailureMessage(), 425 431 }) 426 432 } 427 433