@@ -742,11 +742,12 @@ private List<V1Volume> getVolumes(String domainUid) {
742
742
@ Override
743
743
protected V1Container createPrimaryContainer () {
744
744
final PodTuning podTuning = TuningParameters .getInstance ().getPodTuning ();
745
+ Pair <V1Probe , V1Probe > probes = createLivenessAndStartupProbe (podTuning );
745
746
V1Container v1Container = super .createPrimaryContainer ()
746
747
.ports (getContainerPorts ())
747
748
.lifecycle (createLifecycle ())
748
- .livenessProbe (createLivenessProbe ( podTuning ))
749
- .startupProbe (getStartupProbe ());
749
+ .livenessProbe (probes . left ( ))
750
+ .startupProbe (probes . right ());
750
751
751
752
if (!mockWls ()) {
752
753
v1Container .readinessProbe (createReadinessProbe (podTuning ));
@@ -961,6 +962,11 @@ private V1Probe getReadinessProbe() {
961
962
.map (V1ProbeBuilder ::new ).map (V1ProbeBuilder ::build ).orElse (new V1Probe ());
962
963
}
963
964
965
+ private Pair <V1Probe , V1Probe > createLivenessAndStartupProbe (PodTuning tuning ) {
966
+ V1Probe livenessProbe = createLivenessProbe (tuning );
967
+ return new Pair <>(livenessProbe , createStartupProbe (livenessProbe , tuning ));
968
+ }
969
+
964
970
private V1Probe createLivenessProbe (PodTuning tuning ) {
965
971
V1Probe livenessProbe = getLivenessProbe ();
966
972
@@ -981,21 +987,12 @@ private V1Probe createLivenessProbe(PodTuning tuning) {
981
987
livenessProbe .setSuccessThreshold (tuning .getLivenessProbeSuccessThreshold ());
982
988
}
983
989
984
- try {
985
- V1HTTPGetAction httpGetAction = livenessProbe .getHttpGet ();
986
- if (httpGetAction != null ) {
987
- if (httpGetAction .getPort () == null ) {
988
- httpGetAction .setPort (new IntOrString (getLocalAdminProtocolChannelPort ()));
989
- }
990
- if (httpGetAction .getScheme () == null && isLocalAdminProtocolChannelSecure ()) {
991
- httpGetAction .setScheme ("HTTPS" );
992
- }
993
- } else if (livenessProbe .getExec () == null
994
- && livenessProbe .getTcpSocket () == null && livenessProbe .getGrpc () == null ) {
995
- livenessProbe .setExec (execAction (LIVENESS_PROBE ));
996
- }
997
- } catch (Exception e ) {
998
- // do nothing
990
+ V1HTTPGetAction httpGetAction = livenessProbe .getHttpGet ();
991
+ if (httpGetAction != null ) {
992
+ initializeHttpGetAction (httpGetAction );
993
+ } else if (livenessProbe .getExec () == null
994
+ && livenessProbe .getTcpSocket () == null && livenessProbe .getGrpc () == null ) {
995
+ livenessProbe .setExec (execAction (LIVENESS_PROBE ));
999
996
}
1000
997
1001
998
return livenessProbe ;
@@ -1006,8 +1003,52 @@ private V1Probe getLivenessProbe() {
1006
1003
.map (V1ProbeBuilder ::new ).map (V1ProbeBuilder ::build ).orElse (new V1Probe ());
1007
1004
}
1008
1005
1006
+ private V1Probe createStartupProbe (V1Probe livenessProbe , PodTuning tuning ) {
1007
+ V1Probe startupProbe = getStartupProbe ();
1008
+
1009
+ if (startupProbe .getInitialDelaySeconds () == null && tuning .getStartupProbeInitialDelaySeconds () > 0 ) {
1010
+ startupProbe .setInitialDelaySeconds (tuning .getStartupProbeInitialDelaySeconds ());
1011
+ }
1012
+ if (startupProbe .getTimeoutSeconds () == null ) {
1013
+ startupProbe .setTimeoutSeconds (tuning .getStartupProbeTimeoutSeconds ());
1014
+ }
1015
+ if (startupProbe .getPeriodSeconds () == null ) {
1016
+ startupProbe .setPeriodSeconds (tuning .getStartupProbePeriodSeconds ());
1017
+ }
1018
+ if (startupProbe .getFailureThreshold () == null ) {
1019
+ startupProbe .setFailureThreshold (tuning .getStartupProbeFailureThreshold ());
1020
+ }
1021
+ if (startupProbe .getSuccessThreshold () == null
1022
+ && tuning .getStartupProbeSuccessThreshold () != DEFAULT_SUCCESS_THRESHOLD ) {
1023
+ startupProbe .setSuccessThreshold (tuning .getStartupProbeSuccessThreshold ());
1024
+ }
1025
+
1026
+ V1HTTPGetAction httpGetAction = startupProbe .getHttpGet ();
1027
+ if (httpGetAction != null ) {
1028
+ initializeHttpGetAction (httpGetAction );
1029
+ } else if (startupProbe .getExec () == null
1030
+ && startupProbe .getTcpSocket () == null && startupProbe .getGrpc () == null ) {
1031
+ startupProbe .setHttpGet (livenessProbe .getHttpGet ());
1032
+ startupProbe .setExec (livenessProbe .getExec ());
1033
+ startupProbe .setTcpSocket (livenessProbe .getTcpSocket ());
1034
+ startupProbe .setGrpc (livenessProbe .getGrpc ());
1035
+ }
1036
+
1037
+ return startupProbe ;
1038
+ }
1039
+
1009
1040
private V1Probe getStartupProbe () {
1010
- return getServerSpec ().getStartupProbe ();
1041
+ return Optional .ofNullable (getServerSpec ().getStartupProbe ())
1042
+ .map (V1ProbeBuilder ::new ).map (V1ProbeBuilder ::build ).orElse (new V1Probe ());
1043
+ }
1044
+
1045
+ private void initializeHttpGetAction (@ Nonnull V1HTTPGetAction httpGetAction ) {
1046
+ if (httpGetAction .getPort () == null ) {
1047
+ httpGetAction .setPort (new IntOrString (getLocalAdminProtocolChannelPort ()));
1048
+ }
1049
+ if (httpGetAction .getScheme () == null && isLocalAdminProtocolChannelSecure ()) {
1050
+ httpGetAction .setScheme ("HTTPS" );
1051
+ }
1011
1052
}
1012
1053
1013
1054
private boolean mockWls () {
@@ -1359,6 +1400,15 @@ private void restoreSecurityContextEmptyInitContainer(V1Pod recipe, V1Pod curren
1359
1400
}));
1360
1401
}
1361
1402
1403
+ private void restoreNoStartupProbe (V1Pod recipe , V1Pod currentPod ) {
1404
+ Optional .ofNullable (recipe .getSpec ().getContainers ())
1405
+ .ifPresent (containers ->
1406
+ containers .forEach (container -> Optional .ofNullable (currentPod .getSpec ().getContainers ())
1407
+ .flatMap (currentContainers -> currentContainers .stream ()
1408
+ .filter (cc -> cc .getName ().equals (container .getName ())).findFirst ())
1409
+ .ifPresent (match -> container .setStartupProbe (match .getStartupProbe ()))));
1410
+ }
1411
+
1362
1412
private boolean canAdjustRecentOperatorMajorVersion3HashToMatch (V1Pod currentPod , String requiredHash ) {
1363
1413
// start with list of adjustment methods
1364
1414
// generate stream of combinations
@@ -1374,7 +1424,8 @@ private boolean canAdjustRecentOperatorMajorVersion3HashToMatch(V1Pod currentPod
1374
1424
Pair .of ("restoreFluentdVolume" , this ::restoreFluentdVolume ),
1375
1425
Pair .of ("restoreSecurityContext" , this ::restoreSecurityContext ),
1376
1426
Pair .of ("restoreSecurityContextEmpty" , this ::restoreSecurityContextEmpty ),
1377
- Pair .of ("restoreSecurityContextEmptyInitContainer" , this ::restoreSecurityContextEmptyInitContainer ));
1427
+ Pair .of ("restoreSecurityContextEmptyInitContainer" , this ::restoreSecurityContextEmptyInitContainer ),
1428
+ Pair .of ("restoreNoStartupProbe" , this ::restoreNoStartupProbe ));
1378
1429
return Combinations .of (adjustments )
1379
1430
.map (adjustment -> adjustedHash (currentPod , adjustment ))
1380
1431
.anyMatch (requiredHash ::equals );
0 commit comments