@@ -934,6 +934,7 @@ func runIDEReadinessProbe(cfg *Config, ideConfig *IDEConfig, ide IDEKind) (deskt
934934 if ide == DesktopIDE {
935935 defaultProbePort = desktopIDEPort
936936 }
937+
937938 switch ideConfig .ReadinessProbe .Type {
938939 case ReadinessProcessProbe :
939940 return
@@ -944,48 +945,62 @@ func runIDEReadinessProbe(cfg *Config, ideConfig *IDEConfig, ide IDEKind) (deskt
944945 host = defaultIfEmpty (ideConfig .ReadinessProbe .HTTPProbe .Host , "localhost" )
945946 port = defaultIfZero (ideConfig .ReadinessProbe .HTTPProbe .Port , defaultProbePort )
946947 url = fmt .Sprintf ("%s://%s:%d/%s" , schema , host , port , strings .TrimPrefix (ideConfig .ReadinessProbe .HTTPProbe .Path , "/" ))
947- client = http.Client {Timeout : 1 * time .Second }
948- tick = time .NewTicker (500 * time .Millisecond )
949948 )
950- defer tick .Stop ()
951949
952950 t0 := time .Now ()
953951
954- for {
955- <- tick . C
956-
957- resp , err := client . Get (url )
952+ var body [] byte
953+ for range time . Tick ( 250 * time . Millisecond ) {
954+ var err error
955+ body , err = ideStatusRequest (url )
958956 if err != nil {
957+ log .WithField ("ide" , ide .String ()).WithError (err ).Debug ("Error running IDE readiness probe" )
959958 continue
960959 }
961- defer resp .Body .Close ()
962960
963- if resp . StatusCode == http . StatusOK {
964- log . WithField ( "ide" , ide . String ()). WithField ( "status" , resp . StatusCode ). Infof ( "IDE readiness took %.3f seconds" , time . Since ( t0 ). Seconds ())
961+ break
962+ }
965963
966- if ide == DesktopIDE {
967- bodyBytes , err := ioutil .ReadAll (resp .Body )
968- log .WithField ("ide" , ide .String ()).Infof ("IDE status probe body: %s" , string (bodyBytes ))
969- if err != nil {
970- log .WithField ("ide" , ide .String ()).WithError (err ).Infof ("Error reading response body from IDE status probe." )
971- break
972- }
973- err = json .Unmarshal (bodyBytes , & desktopIDEStatus )
974- if err != nil {
975- log .WithField ("ide" , ide .String ()).WithError (err ).WithField ("body" , bodyBytes ).Debugf ("Error parsing JSON body from IDE status probe." )
976- break
977- }
978- log .WithField ("ide" , ide .String ()).Infof ("Desktop IDE status: %s" , desktopIDEStatus )
979- }
980- break
981- }
964+ log .WithField ("ide" , ide .String ()).Infof ("IDE readiness took %.3f seconds" , time .Since (t0 ).Seconds ())
982965
983- log .WithField ("ide" , ide .String ()).WithField ("status" , resp .StatusCode ).Info ("IDE readiness probe came back with non-200 status code" )
966+ if ide != DesktopIDE {
967+ return
968+ }
969+
970+ err := json .Unmarshal (body , & desktopIDEStatus )
971+ if err != nil {
972+ log .WithField ("ide" , ide .String ()).WithError (err ).WithField ("body" , body ).Debugf ("Error parsing JSON body from IDE status probe." )
973+ return
984974 }
975+
976+ log .WithField ("ide" , ide .String ()).Infof ("Desktop IDE status: %s" , desktopIDEStatus )
977+ return
985978 }
979+
986980 return
987981}
988982
983+ func ideStatusRequest (url string ) ([]byte , error ) {
984+ client := http.Client {Timeout : 1 * time .Second }
985+
986+ resp , err := client .Get (url )
987+ if err != nil {
988+ return nil , err
989+ }
990+ defer resp .Body .Close ()
991+
992+ if resp .StatusCode != http .StatusOK {
993+ return nil , xerrors .Errorf ("IDE readiness probe came back with non-200 status code (%v)" , resp .StatusCode )
994+ }
995+
996+ body , err := ioutil .ReadAll (resp .Body )
997+ if err != nil {
998+ return nil , err
999+ }
1000+
1001+ return body , nil
1002+ }
1003+
9891004func isBlacklistedEnvvar (name string ) bool {
9901005 // exclude blacklisted
9911006 prefixBlacklist := []string {
0 commit comments