RE: RE: Liferay containers version 7.4.3.94-ga94 or higher don't work in Kubernetes

David H Nebinger, modified 1 Year ago. New Member Posts: 5 Join Date: 3/27/24 Recent Posts

Hello,

I am migrating the Liferay application from virtual machines hosting to Kubernetes cluster, but Liferay containers with version liferay/portal:7.4.3.94-ga94 or higher don't work correctly - Liferay hangs during the initialization without any error messages, performed tests in AWS EKS and local Minikube. The issue is still not fixed in the newest container version liferay/portal:7.4.3.112-ga112.

 

Incorrect behavior - liferay/portal:7.4.3.94-ga94 hangs:

[LIFERAY] To SSH into this container, run: "docker exec -it liferay-598b4b465c-vx229 /bin/bash".

[LIFERAY] Using zulu8 JDK. You can use another JDK by setting the "JAVA_VERSION" environment variable.
[LIFERAY] Available JDKs: zulu11, zulu8.
[LIFERAY] Run this container with the option "-v $(pwd)/xyz123:/mnt/liferay" to bridge $(pwd)/xyz123 in the host operating system to /mnt/liferay on the container.

[LIFERAY] The directory /mnt/liferay/files does not exist. Create the directory $(pwd)/xyz123/files on the host operating system to create the directory /mnt/liferay/files on the container. Files in /mnt/liferay/files will be copied to /opt/liferay before Liferay Portal starts.

[LIFERAY] The directory /mnt/liferay/scripts does not exist. Create the directory $(pwd)/xyz123/scripts on the host operating system to create the directory /mnt/liferay/scripts on the container. Files in /mnt/liferay/scripts will be executed, in alphabetical order, before Liferay Portal starts.

[LIFERAY] The directory /mnt/liferay/deploy does not exist. Create the directory $(pwd)/xyz123/deploy on the host operating system to create the directory /mnt/liferay/deploy on the container. Copy files to $(pwd)/xyz123/deploy to deploy modules to Liferay Portal at runtime.

[LIFERAY] Starting Liferay Portal. To stop the container with CTRL-C, run this container with the option "-it".

27-Mar-2024 09:44:04.247 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1115] milliseconds
Loading jar:file:/opt/liferay/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib/portal-impl.jar!/system.properties
Loading jar:file:/opt/liferay/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib/portal-impl.jar!/portal.properties
2024-03-27 09:44:07.485 INFO  [main][PortalContextLoaderListener:114] JVM arguments: -Djava.util.logging.config.file=/opt/liferay/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dfile.encoding=UTF-8 -Djava.locale.providers=JRE,COMPAT,CLDR -Djava.net.preferIPv4Stack=true -Duser.timezone=GMT -Xms2560m -Xmx2560m -XX:MaxNewSize=1536m -XX:MaxMetaspaceSize=768m -XX:MetaspaceSize=768m -XX:NewSize=1536m -XX:SurvivorRatio=7 -Dignore.endorsed.dirs= -Dcatalina.base=/opt/liferay/tomcat -Dcatalina.home=/opt/liferay/tomcat -Djava.io.tmpdir=/opt/liferay/tomcat/temp
2024-03-27 09:44:28.025 WARN  [main][DialectDetector:73] Liferay is configured to use Hypersonic as its database. Do NOT use Hypersonic in production. Hypersonic is an embedded database useful for development and demonstration purposes. The database settings can be changed in portal-ext.properties.
2024-03-27 09:44:28.026 INFO  [main][DialectDetector:144] Using dialect com.liferay.portal.dao.orm.hibernate.HSQLDialect for HSQL Database Engine 2.7
2024-03-27 09:44:37.721 INFO  [main][ModuleFrameworkImpl:1297] Starting initial bundles
2024-03-27 09:44:44.094 INFO  [SystemExecutorServiceUtil-1][InterpolationConfigurationPlugin:109] Configured directory for secrets: /opt/liferay/osgi/configs
2024-03-27 09:44:44.178 INFO  [main][ModuleFrameworkImpl:1587] Started initial bundles
2024-03-27 09:44:44.185 INFO  [main][ModuleFrameworkImpl:1631] Starting dynamic bundles
2024-03-27 09:44:53.022 WARN  [Start Level: Equinox Container: bb074310-5ef6-4234-8d15-dbfc48280ae9][SidecarManager:75] Liferay automatically starts a child process of Elasticsearch named sidecar for convenient development and demonstration purposes. Do NOT use sidecar in production. Refer to the documentation for details on the limitations of sidecar and instructions on configuring a remote Elasticsearch connection in the Control Panel.
2024-03-27 09:45:17.644 INFO  [Start Level: Equinox Container: bb074310-5ef6-4234-8d15-dbfc48280ae9][Sidecar:106] Sidecar Elasticsearch liferay started at 127.0.0.1:9201
2024-03-27 09:45:20.377 INFO  [main][ModuleFrameworkImpl:1654] Started dynamic bundles
2024-03-27 09:45:20.379 INFO  [main][ModuleFrameworkImpl:1661] Starting web bundles   
2024-03-27 09:45:25.721 INFO  [main][ModuleFrameworkImpl:1715] Started web bundles
2024-03-27 09:45:25.722 INFO  [main][ModuleFrameworkImpl:272] Navigate to Control Panel > System > Gogo Shell and enter "lb" to see all bundles

 

Correct behavior - liferay/portal:7.4.3.93-ga93 starts the application:

[LIFERAY] To SSH into this container, run: "docker exec -it liferay-6694d8cd67-2bqp6 /bin/bash".      

[LIFERAY] Using zulu8 JDK. You can use another JDK by setting the "JAVA_VERSION" environment variable.
[LIFERAY] Available JDKs: zulu11, zulu8.
[LIFERAY] Run this container with the option "-v $(pwd)/xyz123:/mnt/liferay" to bridge $(pwd)/xyz123 in the host operating system to /mnt/liferay on the container.

[LIFERAY] The directory /mnt/liferay/files does not exist. Create the directory $(pwd)/xyz123/files on the host operating system to create the directory /mnt/liferay/files on the container. Files in /mnt/liferay/files will be copied to /opt/liferay before Liferay Portal starts.

[LIFERAY] The directory /mnt/liferay/scripts does not exist. Create the directory $(pwd)/xyz123/scripts on the host operating system to create the directory /mnt/liferay/scripts on the container. Files in /mnt/liferay/scripts will be executed, in alphabetical order, before Liferay Portal starts.

[LIFERAY] The directory /mnt/liferay/deploy does not exist. Create the directory $(pwd)/xyz123/deploy on the host operating system to create the directory /mnt/liferay/deploy on the container. Copy files to $(pwd)/xyz123/deploy to deploy modules to Liferay Portal at runtime.

[LIFERAY] Starting Liferay Portal. To stop the container with CTRL-C, run this container with the option "-it".

27-Mar-2024 08:52:15.900 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1377] milliseconds
Loading jar:file:/opt/liferay/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib/portal-impl.jar!/system.properties
Loading jar:file:/opt/liferay/tomcat/webapps/ROOT/WEB-INF/shielded-container-lib/portal-impl.jar!/portal.properties
2024-03-27 08:52:19.222 INFO  [main][PortalContextLoaderListener:114] JVM arguments: -Djava.util.logging.config.file=/opt/liferay/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dfile.encoding=UTF-8 -Djava.locale.providers=JRE,COMPAT,CLDR -Djava.net.preferIPv4Stack=true -Duser.timezone=GMT -Xms2560m -Xmx2560m -XX:MaxNewSize=1536m -XX:MaxMetaspaceSize=768m -XX:MetaspaceSize=768m -XX:NewSize=1536m -XX:SurvivorRatio=7 -Dignore.endorsed.dirs= -Dcatalina.base=/opt/liferay/tomcat -Dcatalina.home=/opt/liferay/tomcat -Djava.io.tmpdir=/opt/liferay/tomcat/temp
2024-03-27 08:52:41.650 WARN  [main][DialectDetector:73] Liferay is configured to use Hypersonic as its database. Do NOT use Hypersonic in production. Hypersonic is an embedded database useful for development and demonstration purposes. The database settings can be changed in portal-ext.properties.
2024-03-27 08:52:41.650 INFO  [main][DialectDetector:144] Using dialect com.liferay.portal.dao.orm.hibernate.HSQLDialect for HSQL Database Engine 2.7
2024-03-27 08:52:53.901 INFO  [main][ModuleFrameworkImpl:1297] Starting initial bundles
2024-03-27 08:52:56.028 INFO  [SystemExecutorServiceUtil-1][InterpolationConfigurationPlugin:109] Configured directory for secrets: /opt/liferay/osgi/configs
2024-03-27 08:53:00.133 INFO  [main][ModuleFrameworkImpl:1587] Started initial bundles
2024-03-27 08:53:00.134 INFO  [main][ModuleFrameworkImpl:1631] Starting dynamic bundles
2024-03-27 08:53:09.100 WARN  [Start Level: Equinox Container: bf99a5a8-85e5-4e0f-9a75-1eed595f26bf][SidecarManager:75] Liferay automatically starts a child process of Elasticsearch named sidecar for convenient development and demonstration purposes. Do NOT use sidecar in production. Refer to the documentation for details on the limitations of sidecar and instructions on configuring a remote Elasticsearch connection in the Control Panel.
2024-03-27 08:53:39.546 INFO  [Start Level: Equinox Container: bf99a5a8-85e5-4e0f-9a75-1eed595f26bf][Sidecar:106] Sidecar Elasticsearch liferay started at 127.0.0.1:9201
2024-03-27 08:53:42.793 INFO  [main][ModuleFrameworkImpl:1654] Started dynamic bundles
2024-03-27 08:53:42.795 INFO  [main][ModuleFrameworkImpl:1661] Starting web bundles
2024-03-27 08:53:49.610 INFO  [main][ModuleFrameworkImpl:1715] Started web bundles
2024-03-27 08:53:49.611 INFO  [main][ModuleFrameworkImpl:272] Navigate to Control Panel > System > Gogo Shell and enter "lb" to see all bundles

    __    ____________________  _____  __
   / /   /  _/ ____/ ____/ __ \/   \ \/ /
  / /    / // /_  / __/ / /_/ / /| |\  /
 / /____/ // __/ / /___/ _, _/ ___ |/ /
/_____/___/_/   /_____/_/ |_/_/  |_/_/

Starting Liferay Community Edition Portal 7.4.3.93 CE GA93 (Cavanaugh / Build 7403 / September 8, 2023)

2024-03-27 08:53:57.035 INFO  [main][StartupHelperUtil:76] There are no patches installed
2024-03-27 08:53:57.443 INFO  [main][LoggingTimer:74] Starting com.liferay.portal.events.StartupHelperUtil#initResourceActions
2024-03-27 08:53:57.497 INFO  [main][LoggingTimer:35] Completed com.liferay.portal.events.StartupHelperUtil#initResourceActions in 53 ms
2024-03-27 08:53:59.139 INFO  [main][AutoDeployDir:152] Auto deploy scanner started for /opt/liferay/deploy
2024-03-27 08:54:22.199 INFO  [SystemExecutorServiceUtil-1-com.liferay.portal.osgi.web.wab.extender.internal.WabFactory-BundleTrackerOpener][ThemeHotDeployListener:99] 1 theme for minium-theme is available for use
2024-03-27 08:54:22.326 INFO  [SystemExecutorServiceUtil-1-com.liferay.portal.osgi.web.wab.extender.internal.WabFactory-BundleTrackerOpener][ThemeHotDeployListener:99] 1 theme for classic-theme is available for use
2024-03-27 08:54:22.431 INFO  [SystemExecutorServiceUtil-1-com.liferay.portal.osgi.web.wab.extender.internal.WabFactory-BundleTrackerOpener][ThemeHotDeployListener:99] 1 theme for admin-theme is available for use
2024-03-27 08:54:22.549 INFO  [SystemExecutorServiceUtil-1-com.liferay.portal.osgi.web.wab.extender.internal.WabFactory-BundleTrackerOpener][ThemeHotDeployListener:99] 1 theme for speedwell-theme is available for use
2024-03-27 08:54:22.632 INFO  [SystemExecutorServiceUtil-1-com.liferay.portal.osgi.web.wab.extender.internal.WabFactory-BundleTrackerOpener][ThemeHotDeployListener:99] 1 theme for dialect-theme is available for use
27-Mar-2024 08:54:27.133 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [131230] milliseconds

 

Steps to reproduce:

1. Create a file liferay-k8s.yml with the following content:

apiVersion: v1
kind: Service
metadata:
  name: liferay
  namespace: default
spec:
  type: ClusterIP
  selector:
    app: liferay
  ports:
    - name: http
      protocol: TCP
      port: 8080
      targetPort: 8080
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: liferay
  namespace: default
  labels:
    app: liferay
spec:
  replicas: 1
  selector:
    matchLabels:
      app: liferay
  template:
    metadata:
      labels:
        app: liferay
    spec:
      containers:
        - name: liferay
          # image: "liferay/portal:7.4.3.93-ga93"
          image: "liferay/portal:7.4.3.94-ga94"
          # image: "liferay/portal:7.4.3.112-ga112"
          imagePullPolicy: Always

2. Create Kubernetes resources: kubectl apply -f liferay-k8s.yml

3. Observe pod logs: kubectl logs -f $(kubectl get pods | grep -o 'liferay-[a-z0-9-]*')

4. (Optionally) Forward open port to forward traffic from localhost to the container: kubectl port-forward $(kubectl get pods | grep -o 'liferay-[a-z0-9-]*') 8080:8080

5. (Optionally) Connect to Liferay website (if it does not hang on initialization) from your browser: http://localhost:8080/

6. Delete Kubernets resources: kubectl delete -f liferay-k8s.yml

7. Change the container version in the liferay-k8s.yml file and repeat the process

thumbnail
David H Nebinger, modified 1 Year ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

Can you take thread dumps to get a clue where the system hangs?

And - depending on that result - maybe just try if Java11 runs better. It's been a long time that I've run a server on Java8...

David H Nebinger, modified 1 Year ago. New Member Posts: 5 Join Date: 3/27/24 Recent Posts

Thank you Olaf! I added the environment variable JAVA_VERSION: zulu11, and that solved the problem. The container runs on zulu8 by default, it seems like it's time to change it :)

David H Nebinger, modified 1 Year ago. New Member Posts: 5 Join Date: 3/27/24 Recent Posts

I don't know why the comment from Olaf Kock disappeared (at least for me).

Can you take thread dumps to get a clue where the system hangs?

And - depending on that result - maybe just try if Java11 runs better. It's been a long time that I've run a server on Java8...

The suggestion was great, adding the environment variable JAVA_VERSION: zulu11 solved the issue. It seems like it should be a default version in the container. Thank you Olaf once again!

Jamie Sammons, modified 1 Year ago. New Member Post: 1 Join Date: 6/27/24 Recent Posts

For anyone that is also running into this issue but is not able to upgrade to Java 8:

We have found that Java 8 incorrectly detects the number of processors available on Kubernetes when no request limits are set. In this case java falls back to using only 1 processor and this causes a deadlock in the upgrade process. Simply starting the upgrade process with "./db_upgrade_client.sh --jvm-opts="-XX:ActiveProcessorCount=4"" will override the detection and set the number of available processors to 4.

Alternative is to start the upgrade pod with request limits set.