@@ -934,6 +934,7 @@ func runIDEReadinessProbe(cfg *Config, ideConfig *IDEConfig, ide IDEKind) (deskt
934
934
if ide == DesktopIDE {
935
935
defaultProbePort = desktopIDEPort
936
936
}
937
+
937
938
switch ideConfig .ReadinessProbe .Type {
938
939
case ReadinessProcessProbe :
939
940
return
@@ -944,48 +945,62 @@ func runIDEReadinessProbe(cfg *Config, ideConfig *IDEConfig, ide IDEKind) (deskt
944
945
host = defaultIfEmpty (ideConfig .ReadinessProbe .HTTPProbe .Host , "localhost" )
945
946
port = defaultIfZero (ideConfig .ReadinessProbe .HTTPProbe .Port , defaultProbePort )
946
947
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 )
949
948
)
950
- defer tick .Stop ()
951
949
952
950
t0 := time .Now ()
953
951
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 )
958
956
if err != nil {
957
+ log .WithField ("ide" , ide .String ()).WithError (err ).Debug ("Error running IDE readiness probe" )
959
958
continue
960
959
}
961
- defer resp .Body .Close ()
962
960
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
+ }
965
963
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 ())
982
965
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
984
974
}
975
+
976
+ log .WithField ("ide" , ide .String ()).Infof ("Desktop IDE status: %s" , desktopIDEStatus )
977
+ return
985
978
}
979
+
986
980
return
987
981
}
988
982
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
+
989
1004
func isBlacklistedEnvvar (name string ) bool {
990
1005
// exclude blacklisted
991
1006
prefixBlacklist := []string {
0 commit comments