@@ -80,6 +80,40 @@ func getInitResponse() (*rpc.InitResp, error) {
8080 resp .PlatformsIndexErrors = rescanResp .PlatformsIndexErrors
8181 }
8282
83+ // Init() succeeded but there were errors loading platform indexes,
84+ // let's rescan and try again
85+ if resp .GetPlatformsIndexErrors () != nil {
86+
87+ // log each error
88+ for _ , err := range resp .GetPlatformsIndexErrors () {
89+ logrus .Errorf ("Error loading platform index: %v" , err )
90+ }
91+
92+ // update platform index
93+ _ , err := commands .UpdateIndex (context .Background (),
94+ & rpc.UpdateIndexReq {Instance : resp .GetInstance ()}, output .ProgressBar ())
95+ if err != nil {
96+ return nil , errors .Wrap (err , "updating the core index" )
97+ }
98+
99+ // rescan
100+ rescanResp , err := commands .Rescan (resp .GetInstance ().GetId ())
101+ if err != nil {
102+ return nil , errors .Wrap (err , "during rescan" )
103+ }
104+
105+ // errors persist
106+ if rescanResp .GetPlatformsIndexErrors () != nil {
107+ for _ , err := range rescanResp .GetPlatformsIndexErrors () {
108+ logrus .Errorf ("Still errors after rescan: %v" , err )
109+ }
110+ }
111+
112+ // succeeded, copy over PlatformsIndexErrors in case errors occurred
113+ // during rescan
114+ resp .PlatformsIndexErrors = rescanResp .PlatformsIndexErrors
115+ }
116+
83117 return resp , nil
84118}
85119
0 commit comments