How to set systeml locale for images

Solution Unverified - Updated

Environment

  • Red Hat OpenShift Container Platform
    • 3.x
    • 4.x
  • JBoss EAP for OpenShift
    • 7.x

Issue

  • When we deploy s2i images, it does not display the local language correctly. For example, JBoss EAP image outputs the language like this:
  08:20:00,421 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: JBoss EAP 7.0.8.GA (WildFly Core 2.1.18.Final-redhat-1) ? 9446ms ??????? -  ???? 598 ???? 306 ???????? (380 ???????????????????????????)?
  • Neither setting # echo 'JAVA_OPTS="$JAVA_OPTS -Duser.language=ja -Duser.country=JP"' >> /opt/eap/bin/standalone.conf nor LANG=ja_JP.UTF-8 works fine. How we can correct this language issue?

Resolution

Set JAVA_OPTS_APPEND system properties for the language and encoding. For example, for Japanese:

oc set env dc <YOUR_DC_NAME> JAVA_OPTS_APPEND="-Duser.language=ja -Duser.country=JP -Dfile.encoding=UTF8"

NOTE: If the locale is changed and using JBoss EAP 7.2 or later, the livenessProbe/readinessProbe bundled with EAP will fail due to known issue This content is not included.JBEAP-23302 with the following error message. If you need to change the locale from the default, livenessProbe/readinessProbe needs a custom probe setting. JBEAP-23302 has been fixed in JBoss EAP 7.4.11.

$ oc describe pod <pod-name>
...

Events:
  Type     Reason          Age                    From               Message
  ----     ------          ----                   ----               -------
...
  Normal   Killing         3m10s                  kubelet            Container <container-name> failed liveness probe, will be restarted
  Warning  Unhealthy       3m10s (x3 over 3m30s)  kubelet            Liveness probe failed: {
    "probe.eap.dmr.EapProbe": {
        "probe.eap.dmr.ServerStatusTest": "running",
        "probe.eap.dmr.DeploymentTest": {
            "echo.war": "OK"
        },
        "probe.eap.dmr.BootErrorsTest": "No boot errors",
        "probe.eap.dmr.ServerRunningModeTest": "NORMAL"
    },
    "probe.eap.dmr.HealthCheckProbe": {
        "probe.eap.dmr.HealthCheckTest": "Exception executing test: 'ascii' codec can't encode characters in position 13-16: ordinal not in range(128)"
    }
}

A simple custom example of livenessProbe/readinessProbe is to probe by the /health endpoint as following:

        livenessProbe:
          failureThreshold: 3
          httpGet:
            path: /health
            port: 9990
            scheme: HTTP
          initialDelaySeconds: 60
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
...
        readinessProbe:
          failureThreshold: 3
          httpGet:
            path: /health
            port: 9990
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 10
          successThreshold: 1
          timeoutSeconds: 5
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.