@@ -749,11 +749,12 @@ private List<V1Volume> getVolumes(String domainUid) {
749749 @ Override
750750 protected V1Container createPrimaryContainer () {
751751 final PodTuning podTuning = TuningParameters .getInstance ().getPodTuning ();
752+ Pair <V1Probe , V1Probe > probes = createLivenessAndStartupProbe (podTuning );
752753 V1Container v1Container = super .createPrimaryContainer ()
753754 .ports (getContainerPorts ())
754755 .lifecycle (createLifecycle ())
755- .livenessProbe (createLivenessProbe ( podTuning ))
756- .startupProbe (getStartupProbe ());
756+ .livenessProbe (probes . left ( ))
757+ .startupProbe (probes . right ());
757758
758759 if (!mockWls ()) {
759760 v1Container .readinessProbe (createReadinessProbe (podTuning ));
@@ -968,6 +969,11 @@ private V1Probe getReadinessProbe() {
968969 .map (V1ProbeBuilder ::new ).map (V1ProbeBuilder ::build ).orElse (new V1Probe ());
969970 }
970971
972+ private Pair <V1Probe , V1Probe > createLivenessAndStartupProbe (PodTuning tuning ) {
973+ V1Probe livenessProbe = createLivenessProbe (tuning );
974+ return new Pair <>(livenessProbe , createStartupProbe (livenessProbe , tuning ));
975+ }
976+
971977 private V1Probe createLivenessProbe (PodTuning tuning ) {
972978 V1Probe livenessProbe = getLivenessProbe ();
973979
@@ -988,21 +994,12 @@ private V1Probe createLivenessProbe(PodTuning tuning) {
988994 livenessProbe .setSuccessThreshold (tuning .getLivenessProbeSuccessThreshold ());
989995 }
990996
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 ));
10061003 }
10071004
10081005 return livenessProbe ;
@@ -1013,8 +1010,52 @@ private V1Probe getLivenessProbe() {
10131010 .map (V1ProbeBuilder ::new ).map (V1ProbeBuilder ::build ).orElse (new V1Probe ());
10141011 }
10151012
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+
10161047 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+ }
10181059 }
10191060
10201061 private boolean mockWls () {
@@ -1381,6 +1422,15 @@ private void restoreSecurityContextEmptyInitContainer(V1Pod recipe, V1Pod curren
13811422 }));
13821423 }
13831424
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+
13841434 private boolean canAdjustRecentOperatorMajorVersion3HashToMatch (V1Pod currentPod , String requiredHash ) {
13851435 // start with list of adjustment methods
13861436 // generate stream of combinations
@@ -1396,7 +1446,8 @@ private boolean canAdjustRecentOperatorMajorVersion3HashToMatch(V1Pod currentPod
13961446 Pair .of ("restoreFluentdVolume" , this ::restoreFluentdVolume ),
13971447 Pair .of ("restoreSecurityContext" , this ::restoreSecurityContext ),
13981448 Pair .of ("restoreSecurityContextEmpty" , this ::restoreSecurityContextEmpty ),
1399- Pair .of ("restoreSecurityContextEmptyInitContainer" , this ::restoreSecurityContextEmptyInitContainer ));
1449+ Pair .of ("restoreSecurityContextEmptyInitContainer" , this ::restoreSecurityContextEmptyInitContainer ),
1450+ Pair .of ("restoreNoStartupProbe" , this ::restoreNoStartupProbe ));
14001451 return Combinations .of (adjustments )
14011452 .map (adjustment -> adjustedHash (currentPod , adjustment ))
14021453 .anyMatch (requiredHash ::equals );
0 commit comments