@@ -749,11 +749,12 @@ private List<V1Volume> getVolumes(String domainUid) {
749
749
@ Override
750
750
protected V1Container createPrimaryContainer () {
751
751
final PodTuning podTuning = TuningParameters .getInstance ().getPodTuning ();
752
+ Pair <V1Probe , V1Probe > probes = createLivenessAndStartupProbe (podTuning );
752
753
V1Container v1Container = super .createPrimaryContainer ()
753
754
.ports (getContainerPorts ())
754
755
.lifecycle (createLifecycle ())
755
- .livenessProbe (createLivenessProbe ( podTuning ))
756
- .startupProbe (getStartupProbe ());
756
+ .livenessProbe (probes . left ( ))
757
+ .startupProbe (probes . right ());
757
758
758
759
if (!mockWls ()) {
759
760
v1Container .readinessProbe (createReadinessProbe (podTuning ));
@@ -968,6 +969,11 @@ private V1Probe getReadinessProbe() {
968
969
.map (V1ProbeBuilder ::new ).map (V1ProbeBuilder ::build ).orElse (new V1Probe ());
969
970
}
970
971
972
+ private Pair <V1Probe , V1Probe > createLivenessAndStartupProbe (PodTuning tuning ) {
973
+ V1Probe livenessProbe = createLivenessProbe (tuning );
974
+ return new Pair <>(livenessProbe , createStartupProbe (livenessProbe , tuning ));
975
+ }
976
+
971
977
private V1Probe createLivenessProbe (PodTuning tuning ) {
972
978
V1Probe livenessProbe = getLivenessProbe ();
973
979
@@ -988,21 +994,12 @@ private V1Probe createLivenessProbe(PodTuning tuning) {
988
994
livenessProbe .setSuccessThreshold (tuning .getLivenessProbeSuccessThreshold ());
989
995
}
990
996
991
- try {
992
- V1HTTPGetAction httpGetAction = livenessProbe .getHttpGet ();
993
- if (httpGetAction != null ) {
994
- if (httpGetAction .getPort () == null ) {
995
- httpGetAction .setPort (new IntOrString (getLocalAdminProtocolChannelPort ()));
996
- }
997
- if (httpGetAction .getScheme () == null && isLocalAdminProtocolChannelSecure ()) {
998
- httpGetAction .setScheme ("HTTPS" );
999
- }
1000
- } else if (livenessProbe .getExec () == null
1001
- && livenessProbe .getTcpSocket () == null && livenessProbe .getGrpc () == null ) {
1002
- livenessProbe .setExec (execAction (LIVENESS_PROBE ));
1003
- }
1004
- } catch (Exception e ) {
1005
- // do nothing
997
+ V1HTTPGetAction httpGetAction = livenessProbe .getHttpGet ();
998
+ if (httpGetAction != null ) {
999
+ initializeHttpGetAction (httpGetAction );
1000
+ } else if (livenessProbe .getExec () == null
1001
+ && livenessProbe .getTcpSocket () == null && livenessProbe .getGrpc () == null ) {
1002
+ livenessProbe .setExec (execAction (LIVENESS_PROBE ));
1006
1003
}
1007
1004
1008
1005
return livenessProbe ;
@@ -1013,8 +1010,52 @@ private V1Probe getLivenessProbe() {
1013
1010
.map (V1ProbeBuilder ::new ).map (V1ProbeBuilder ::build ).orElse (new V1Probe ());
1014
1011
}
1015
1012
1013
+ private V1Probe createStartupProbe (V1Probe livenessProbe , PodTuning tuning ) {
1014
+ V1Probe startupProbe = getStartupProbe ();
1015
+
1016
+ if (startupProbe .getInitialDelaySeconds () == null && tuning .getStartupProbeInitialDelaySeconds () > 0 ) {
1017
+ startupProbe .setInitialDelaySeconds (tuning .getStartupProbeInitialDelaySeconds ());
1018
+ }
1019
+ if (startupProbe .getTimeoutSeconds () == null ) {
1020
+ startupProbe .setTimeoutSeconds (tuning .getStartupProbeTimeoutSeconds ());
1021
+ }
1022
+ if (startupProbe .getPeriodSeconds () == null ) {
1023
+ startupProbe .setPeriodSeconds (tuning .getStartupProbePeriodSeconds ());
1024
+ }
1025
+ if (startupProbe .getFailureThreshold () == null ) {
1026
+ startupProbe .setFailureThreshold (tuning .getStartupProbeFailureThreshold ());
1027
+ }
1028
+ if (startupProbe .getSuccessThreshold () == null
1029
+ && tuning .getStartupProbeSuccessThreshold () != DEFAULT_SUCCESS_THRESHOLD ) {
1030
+ startupProbe .setSuccessThreshold (tuning .getStartupProbeSuccessThreshold ());
1031
+ }
1032
+
1033
+ V1HTTPGetAction httpGetAction = startupProbe .getHttpGet ();
1034
+ if (httpGetAction != null ) {
1035
+ initializeHttpGetAction (httpGetAction );
1036
+ } else if (startupProbe .getExec () == null
1037
+ && startupProbe .getTcpSocket () == null && startupProbe .getGrpc () == null ) {
1038
+ startupProbe .setHttpGet (livenessProbe .getHttpGet ());
1039
+ startupProbe .setExec (livenessProbe .getExec ());
1040
+ startupProbe .setTcpSocket (livenessProbe .getTcpSocket ());
1041
+ startupProbe .setGrpc (livenessProbe .getGrpc ());
1042
+ }
1043
+
1044
+ return startupProbe ;
1045
+ }
1046
+
1016
1047
private V1Probe getStartupProbe () {
1017
- return getServerSpec ().getStartupProbe ();
1048
+ return Optional .ofNullable (getServerSpec ().getStartupProbe ())
1049
+ .map (V1ProbeBuilder ::new ).map (V1ProbeBuilder ::build ).orElse (new V1Probe ());
1050
+ }
1051
+
1052
+ private void initializeHttpGetAction (@ Nonnull V1HTTPGetAction httpGetAction ) {
1053
+ if (httpGetAction .getPort () == null ) {
1054
+ httpGetAction .setPort (new IntOrString (getLocalAdminProtocolChannelPort ()));
1055
+ }
1056
+ if (httpGetAction .getScheme () == null && isLocalAdminProtocolChannelSecure ()) {
1057
+ httpGetAction .setScheme ("HTTPS" );
1058
+ }
1018
1059
}
1019
1060
1020
1061
private boolean mockWls () {
@@ -1381,6 +1422,15 @@ private void restoreSecurityContextEmptyInitContainer(V1Pod recipe, V1Pod curren
1381
1422
}));
1382
1423
}
1383
1424
1425
+ private void restoreNoStartupProbe (V1Pod recipe , V1Pod currentPod ) {
1426
+ Optional .ofNullable (recipe .getSpec ().getContainers ())
1427
+ .ifPresent (containers ->
1428
+ containers .forEach (container -> Optional .ofNullable (currentPod .getSpec ().getContainers ())
1429
+ .flatMap (currentContainers -> currentContainers .stream ()
1430
+ .filter (cc -> cc .getName ().equals (container .getName ())).findFirst ())
1431
+ .ifPresent (match -> container .setStartupProbe (match .getStartupProbe ()))));
1432
+ }
1433
+
1384
1434
private boolean canAdjustRecentOperatorMajorVersion3HashToMatch (V1Pod currentPod , String requiredHash ) {
1385
1435
// start with list of adjustment methods
1386
1436
// generate stream of combinations
@@ -1396,7 +1446,8 @@ private boolean canAdjustRecentOperatorMajorVersion3HashToMatch(V1Pod currentPod
1396
1446
Pair .of ("restoreFluentdVolume" , this ::restoreFluentdVolume ),
1397
1447
Pair .of ("restoreSecurityContext" , this ::restoreSecurityContext ),
1398
1448
Pair .of ("restoreSecurityContextEmpty" , this ::restoreSecurityContextEmpty ),
1399
- Pair .of ("restoreSecurityContextEmptyInitContainer" , this ::restoreSecurityContextEmptyInitContainer ));
1449
+ Pair .of ("restoreSecurityContextEmptyInitContainer" , this ::restoreSecurityContextEmptyInitContainer ),
1450
+ Pair .of ("restoreNoStartupProbe" , this ::restoreNoStartupProbe ));
1400
1451
return Combinations .of (adjustments )
1401
1452
.map (adjustment -> adjustedHash (currentPod , adjustment ))
1402
1453
.anyMatch (requiredHash ::equals );
0 commit comments