Running Apache Drill on OpenShift fails at startup - openshift

does anyway have experience on running apache drill on openshift?
I'm having a problem where I'm trying to run the standard docker-image in openshift
https://hub.docker.com/r/apache/drill
really just the embedded mode without trying to configure anything.
it works fine if I run it in my local docker desktop daemon and it's totally fine.
but when I deploy it to openshift it becomes totally weird by not even starting up.
my deployment yaml is very straight forward:
apiVersion: apps/v1
kind: Deployment
metadata:
name: apache-drill
labels:
app.kubernetes.io/component: apache-drill-svc
spec:
replicas: 1
selector:
matchLabels:
template:
metadata:
labels:
app.kubernetes.io/component: apache-drill-svc
spec:
containers:
- name: apache-drill
image: apache/drill
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 1
memory: 1Gi
limits:
cpu: 4
memory: 4Gi
But once it launches this is the feedback that it fails to start because of the log directories:
I believe it might be because of this guidelines regarding the security.
https://docs.openshift.com/container-platform/3.11/creating_images/guidelines.html#openshift-specific-guidelines
so because of that I've tried to create my own image wrapping the official one:
https://hub.docker.com/r/cstmgl/adrill/tags (probably there are better ways to do this)
anyway I still get an error even thought the image also works final in my local docker daemon but if I try it on OpenShift I get this error:
apiVersion: apps/v1
kind: Deployment
metadata:
name: apache-drill
labels:
app.kubernetes.io/component: apache-drill-svc
spec:
replicas: 1
template:
metadata:
labels:
app.kubernetes.io/component: apache-drill-svc
spec:
containers:
- name: apache-drill
image: cstmgl/adrill:1.18.0
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 1
memory: 1Gi
limits:
cpu: 4
memory: 4Gi
Any idea what I'm doing wrong? I'll update this soon with the actual startup error it's rather basic but I believe it's a problem with the user running the application just not sure how to get around it.
ERROR: Drill config file not readable: /opt/drill/conf/drill-override.conf - Wrong user?
Anyway I changed that image also to something like this in my dockerfile
FROM cstmgl/adrill:1.18.0
ARG APP_ROOT=/opt/drill
RUN chmod -R ugo+rw ${APP_ROOT}
RUN echo ${UID}
USER ${UID}
WORKDIR ${DRILL_HOME}
ENTRYPOINT [ "drill-embedded" ]
but still not working, this is the log:
Error: Failure in starting embedded Drillbit: org.apache.drill.exec.exception.DrillbitStartupException: Failed to login. (state=,code=0)
java.sql.SQLException: Failure in starting embedded Drillbit: org.apache.drill.exec.exception.DrillbitStartupException: Failed to login.
at org.apache.drill.jdbc.impl.DrillConnectionImpl.<init>(DrillConnectionImpl.java:143)
at org.apache.drill.jdbc.impl.DrillJdbc41Factory.newDrillConnection(DrillJdbc41Factory.java:67)
at org.apache.drill.jdbc.impl.DrillFactory.newConnection(DrillFactory.java:67)
at org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:138)
at org.apache.drill.jdbc.Driver.connect(Driver.java:75)
at sqlline.DatabaseConnection.connect(DatabaseConnection.java:135)
at sqlline.DatabaseConnection.getConnection(DatabaseConnection.java:192)
at sqlline.Commands.connect(Commands.java:1364)
at sqlline.Commands.connect(Commands.java:1244)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:38)
at sqlline.SqlLine.dispatch(SqlLine.java:730)
at sqlline.SqlLine.initArgs(SqlLine.java:410)
at sqlline.SqlLine.begin(SqlLine.java:515)
at sqlline.SqlLine.start(SqlLine.java:267)
at sqlline.SqlLine.main(SqlLine.java:206)
Caused by: org.apache.drill.exec.exception.DrillbitStartupException: Failed to login.
at org.apache.drill.exec.server.BootStrapContext.login(BootStrapContext.java:161)
at org.apache.drill.exec.server.BootStrapContext.<init>(BootStrapContext.java:82)
at org.apache.drill.exec.server.Drillbit.<init>(Drillbit.java:171)
at org.apache.drill.exec.server.Drillbit.<init>(Drillbit.java:135)
at org.apache.drill.jdbc.impl.DrillConnectionImpl.<init>(DrillConnectionImpl.java:133)
... 18 more
Caused by: org.apache.hadoop.security.KerberosAuthException: failure to login: javax.security.auth.login.LoginException: java.lang.NullPointerException: invalid null input: name
at com.sun.security.auth.UnixPrincipal.<init>(UnixPrincipal.java:71)
at com.sun.security.auth.module.UnixLoginModule.login(UnixLoginModule.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.security.auth.login.LoginContext.invoke(LoginContext.java:755)
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
at javax.security.auth.login.LoginContext.login(LoginContext.java:587)
at org.apache.hadoop.security.UserGroupInformation$HadoopLoginContext.login(UserGroupInformation.java:1926)
at org.apache.hadoop.security.UserGroupInformation.doSubjectLogin(UserGroupInformation.java:1837)
at org.apache.hadoop.security.UserGroupInformation.createLoginUser(UserGroupInformation.java:710)
at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:660)
at org.apache.drill.exec.server.BootStrapContext.login(BootStrapContext.java:156)
at org.apache.drill.exec.server.BootStrapContext.<init>(BootStrapContext.java:82)
at org.apache.drill.exec.server.Drillbit.<init>(Drillbit.java:171)
at org.apache.drill.exec.server.Drillbit.<init>(Drillbit.java:135)
at org.apache.drill.jdbc.impl.DrillConnectionImpl.<init>(DrillConnectionImpl.java:133)
at org.apache.drill.jdbc.impl.DrillJdbc41Factory.newDrillConnection(DrillJdbc41Factory.java:67)
at org.apache.drill.jdbc.impl.DrillFactory.newConnection(DrillFactory.java:67)
at org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:138)
at org.apache.drill.jdbc.Driver.connect(Driver.java:75)
at sqlline.DatabaseConnection.connect(DatabaseConnection.java:135)
at sqlline.DatabaseConnection.getConnection(DatabaseConnection.java:192)
at sqlline.Commands.connect(Commands.java:1364)
at sqlline.Commands.connect(Commands.java:1244)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:38)
at sqlline.SqlLine.dispatch(SqlLine.java:730)
at sqlline.SqlLine.initArgs(SqlLine.java:410)
at sqlline.SqlLine.begin(SqlLine.java:515)
at sqlline.SqlLine.start(SqlLine.java:267)
at sqlline.SqlLine.main(SqlLine.java:206)
at org.apache.hadoop.security.UserGroupInformation.doSubjectLogin(UserGroupInformation.java:1847)
at org.apache.hadoop.security.UserGroupInformation.createLoginUser(UserGroupInformation.java:710)
at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:660)
at org.apache.drill.exec.server.BootStrapContext.login(BootStrapContext.java:156)
... 22 more
Caused by: javax.security.auth.login.LoginException: java.lang.NullPointerException: invalid null input: name
at com.sun.security.auth.UnixPrincipal.<init>(UnixPrincipal.java:71)
at com.sun.security.auth.module.UnixLoginModule.login(UnixLoginModule.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.security.auth.login.LoginContext.invoke(LoginContext.java:755)
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
at javax.security.auth.login.LoginContext.login(LoginContext.java:587)
at org.apache.hadoop.security.UserGroupInformation$HadoopLoginContext.login(UserGroupInformation.java:1926)
at org.apache.hadoop.security.UserGroupInformation.doSubjectLogin(UserGroupInformation.java:1837)
at org.apache.hadoop.security.UserGroupInformation.createLoginUser(UserGroupInformation.java:710)
at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:660)
at org.apache.drill.exec.server.BootStrapContext.login(BootStrapContext.java:156)
at org.apache.drill.exec.server.BootStrapContext.<init>(BootStrapContext.java:82)
at org.apache.drill.exec.server.Drillbit.<init>(Drillbit.java:171)
at org.apache.drill.exec.server.Drillbit.<init>(Drillbit.java:135)
at org.apache.drill.jdbc.impl.DrillConnectionImpl.<init>(DrillConnectionImpl.java:133)
at org.apache.drill.jdbc.impl.DrillJdbc41Factory.newDrillConnection(DrillJdbc41Factory.java:67)
at org.apache.drill.jdbc.impl.DrillFactory.newConnection(DrillFactory.java:67)
at org.apache.calcite.avatica.UnregisteredDriver.connect(UnregisteredDriver.java:138)
at org.apache.drill.jdbc.Driver.connect(Driver.java:75)
at sqlline.DatabaseConnection.connect(DatabaseConnection.java:135)
at sqlline.DatabaseConnection.getConnection(DatabaseConnection.java:192)
at sqlline.Commands.connect(Commands.java:1364)
at sqlline.Commands.connect(Commands.java:1244)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:38)
at sqlline.SqlLine.dispatch(SqlLine.java:730)
at sqlline.SqlLine.initArgs(SqlLine.java:410)
at sqlline.SqlLine.begin(SqlLine.java:515)
at sqlline.SqlLine.start(SqlLine.java:267)
at sqlline.SqlLine.main(SqlLine.java:206)
at javax.security.auth.login.LoginContext.invoke(LoginContext.java:856)
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
at javax.security.auth.login.LoginContext.login(LoginContext.java:587)
at org.apache.hadoop.security.UserGroupInformation$HadoopLoginContext.login(UserGroupInformation.java:1926)
at org.apache.hadoop.security.UserGroupInformation.doSubjectLogin(UserGroupInformation.java:1837)
... 25 more
Apache Drill 1.18.0
"Two things are infinite: the universe and Drill; and I'm not sure about the universe."

I have come across this problem myself and after some hard googling, reading this post a few times, and some OpenShift documentation I stumbled upon the way to resolve this.
The problem you are seeing in the logs indicates there is a problem with the name, if you look into sqlline.log you will see that user.name and user.home are empty - it looks something like this:
INFO o.apache.drill.exec.server.Drillbit - Drillbit environment: user.name=?
INFO o.apache.drill.exec.server.Drillbit - Drillbit environment: user.home=?
It seems not everyone knows this but basically OpenShift generates user IDs upon pod creation and the user does not have a home or a name, but in an older version of documentation from OpenShift they provide a way to generate 'default' for the username:
https://docs.openshift.com/container-platform/3.10/creating_images/guidelines.html#openshift-specific-guidelines
Specifically you want this uid_entrypoint script in your image that you can run to generate default for your 100xxxxx user:
https://github.com/RHsyseng/container-rhel-examples/blob/master/starter-arbitrary-uid/bin/uid_entrypoint
You will need to make sure that when building your image that you change the permission of /etc/passswd in order to be able to modify it when you start your image
After I did this I was able to start Drill and you should see the user.name and user.home updated in the log file sqlline.log:
INFO o.apache.drill.exec.server.Drillbit - Drillbit environment: user.name=default
INFO o.apache.drill.exec.server.Drillbit - Drillbit environment: user.home=/

Your application needs root access try this
Either you can add User root in dockerfile just after FROM statement.
or
oc adm policy add-scc-to-user anyuid -z default -n <yournamespace>

Related

Unable to run MYSQL 8.0 on AKS, getting the above errors [MY-012574] [InnoDB] Unable to lock ./#innodb_redo/#ib_redo0 error & Unable to open

Unable to run MYSQL :8.0 on AKS using PVC, below is my manifest files
[
I've just encountered a similar issue myself (when switching from mysql:5.5 to mysql:8).
The key to resolving it when using Azure Files appears to be setting the - nobrl setting on the StorageClass :
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: mysql-sc-azurefile
provisioner: file.csi.azure.com
allowVolumeExpansion: true
mountOptions:
- file_mode=0777
- mfsymlinks
- uid=999
- dir_mode=0777
- gid=999
- actimeo=30
- cache=strict
- nobrl
parameters:
skuName: Standard_LRS
Additionally, you may need to set the securityContext on the deployment to use 999 (to prevent mysql attempting to switch the user at startup) :
securityContext:
runAsUser: 999
runAsGroup: 999
fsGroup: 999

AWS EC2, Jenkins, Docker, Spring-boot+mysql I suspect my spring.datasource.url is wrong?

I'm very new to Docker and I've tried everything I can think of and have gotten desperate. I really hope one of you will know what might be happening. I'm working on a project where I've created a CI pipeline using Jenkins and Docker.
I've tried many things with my spring.datasource.url.
using the name 'db' as that is what the service is named in docker-compose.yml
using grep to find the ip address of my docker0 service, my docker container, etc.
trying localhost as it is
trying different environment variables in the docker-compose file. (using username and password, not using it.)
trying environment variables. I can't recall the exact format, but it's something like this: jdbc:mysql://${DATABASE_HOST}:${DATABASE_PORT}/${DATABASE_NAME}?createDatabaseIfNotExist=true&useSSL=false
trying to install mysql on the EC2 machine.
Many many other things (30 tries tonight, about 60 last night). If it's on stackoverflow, I probably tried it.
Being such a noob, I'm super likely to just not know something very basic. Honestly I'm about to give up and just try to run it with an H2 database. I would hope that would work easier, but I'm still holding a sliver of hope that this may help.
My project works on my local machine using localhost in my spring.datasource.url.
localhost success on mysql
On EC2 however, I get a variation of 'refused to connect' error.
docker sad times
In spring-boot I get similar errors to these:
if I try a hard coded name in the connection string for the host:
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source) ~[na:na]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.27.jar!/:8.0.27]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.27.jar!/:8.0.27]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.27.jar!/:8.0.27]
at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.27.jar!/:8.0.27]
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:89) ~[mysql-connector-java-8.0.27.jar!/:8.0.27]
at com.mysql.cj.NativeSession.connect(NativeSession.java:120) ~[mysql-connector-java-8.0.27.jar!/:8.0.27]
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:948) ~[mysql-connector-java-8.0.27.jar!/:8.0.27]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:818) ~[mysql-connector-java-8.0.27.jar!/:8.0.27]
... 57 common frames omitted
Caused by: java.net.UnknownHostException: db
at java.base/java.net.InetAddress$CachedAddresses.get(Unknown Source) ~[na:na]
at java.base/java.net.InetAddress.getAllByName0(Unknown Source) ~[na:na]
at java.base/java.net.InetAddress.getAllByName(Unknown Source) ~[na:na]
at java.base/java.net.InetAddress.getAllByName(Unknown Source) ~[na:na]
at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:133) ~[mysql-connector-java-8.0.27.jar!/:8.0.27]
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63) ~[mysql-connector-java-8.0.27.jar!/:8.0.27]
... 60 common frames omitted
The closest I got was using an IP address in the host slot similar to this:
jdbc:mysql://172.17.0.0:3306/foodboxdb?createDatabaseIfNotExist=true&useSSL=false
I tried 172.17.0.0, 172.18.0.2,172.18.0.3 based on what little I knew to look for:
using docker inspect
route on the ec2 root
This approach would timeout, so again, did not work - but didn't give a blatant failure error like the others where it would say the password was wrong, or the host was wrong.
I did find a comment saying that someone changed their RUN command somehow like this:
java -Dspring.profiles.active=dockerembbed,oauth-security -jar myapp.jar
but my command is formatted super differently and I'm not 100% sure how I can try to put that command into my Dockerfile. This is what I have right now:
ENTRYPOINT ["java","-jar","foodbox-service-rest-0.0.1-SNAPSHOT.jar"]
If anyone knows what this person was doing with the -Dspring.profiles.active=dockerembbed command and the proper way to put it into an ENTRYPOINT command, I'd love to see it.
Anyway, here is my code below. I'm pretty sure this is all the relevant stuff. My github repo is here: https://github.com/samparsons/pg6-backend
Thank you in advance - I really am not sure what else to try at this point!
My application.properties file looks like this:
# Application Properties
server.port=8081
spring.datasource.url=jdbc:mysql://localhost:3306/foodoxdb?createDatabaseIfNotExist=true&useSSL=false
spring.datasource.username=root
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
spring.jpa.defer-datasource-initialization=true
spring.jpa.hibernate.ddl-auto=create
spring.jpa.database=mysql
spring.jpa.show-sql=true
My Jenkinsfile Looks like this:
pipeline {
agent any
triggers {
pollSCM('* * * * *')
}
stages {
stage('Docker compose build') {
steps {
echo '----------------- This is a docker-compose phase ----------'
sh 'docker-compose up -d --force-recreate --remove-orphans --build'
}
}
}
}
My docker-compose.yml file looks like this:
version: '3.8'
services:
db:
image: mysql:8
environment:
- MYSQL_ROOT_PASSWORD=
- MYSQL_DATABASE=foodboxdb
- MYSQL_USER=root
- MYSQL_PASSWORD=pw
restart: always
ports:
- 3306:3306
volumes:
- foodboxdb:/var/lib/mysql
foodbox-service-rest:
container_name: foodbox-service-rest
restart: on-failure
image: foodbox-service-rest
build:
context: ./
dockerfile: Dockerfile
depends_on:
- db
ports:
- 8081:8081
environment:
- DATABASE_HOST=db
- DATABASE_USER=root
- DATABASE_PASSWORD=pw
- DATABASE_NAME=foodboxdb
- DATABASE_PORT=3306
volumes:
foodboxdb:
and lastly my Dockerfile looks like this:
# code below is from medium tutorial by Wynn Teo,
https://medium.com/geekculture/dockerizing-a-spring-boot-application-with-maven-122286e9f582
# it has been modified slightly for my use case.
# AS <NAME> to name this stage as maven
FROM maven:3.6.3 AS maven
RUN echo "jenkins ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
EXPOSE 8081
EXPOSE 3306
WORKDIR /usr/src/app
COPY . /usr/src/app
# Compile and package the application to an executable JAR
RUN mvn package -DskipTests
RUN echo "running in root"
RUN ls
RUN echo "running in /usr/src/app"
RUN ls /usr/src/app
RUN echo "running in /usr/src/app/target"
RUN ls /usr/src/app/target
# For Java 11,
FROM adoptopenjdk/openjdk11:alpine-jre
ARG JAR_FILE=foodbox-service-rest-0.0.1-SNAPSHOT.jar
WORKDIR /opt/app
# Copy the foodbox-service-rest-0.0.1-SNAPSHOT.jar from the maven stage to the /opt/app directory of the current stage.
COPY --from=maven /usr/src/app/target/${JAR_FILE} /opt/app/
ENTRYPOINT ["java","-jar","foodbox-service-rest-0.0.1-SNAPSHOT.jar"]
I got it to work. Here is what I did to figure this out.
Made sure docker-compose ran the service that I wanted to run. If you define the service that needs to run, it will create all the dependencies first. so, I changed my command from
docker-compose up -d --force-recreate --remove-orphans --build
to
docker-compose up -d --force-recreate --remove-orphans --build <PUT_SERVICE_NAME_HERE>
Here is the blurb I read on the docker-compose help docs that gave me this hint: https://docs.docker.com/compose/compose-file/compose-file-v2/#depends_on
Once I did this, I noticed while running docker ps -a to observe the status of my containers that I had a new issue - my database kept restarting. Obviously the service won’t work if the DB is down. So, to troubleshoot I found that you can grab container logs in Docker using the following command: docker logs -f <db_container_name>
using this command, I was able to figure out how to get the ‘just make it work’ setup going for my db. Please note - do not copy my environment setup, it’s terrible! I really just need it to work so I can get my project done. As this is for school, they’re not grading on security or even best practices honestly (this program is questionable at best!).
Finally, once the DB was working, I switched back to the format shown here
for my spring.datasource.url: jdbc:mysql://db:3306/foodboxdb?createDatabaseIfNotExist=true&useSSL=false using db as the database name, which is the name of the db service that I initiated in the docker-compose.yml file.
Feel free to reuse my repo with the caveats stated above.

MountVolume.setup failed for volume "...": mount failed: exit status 32

using openshift, and one pod keep pending, because nfs server cannot be mounted (nfs server is able to be mounted by mannually using command line, but cannot be mounted from the Pod)
I have installed nfs-common, so it's not the root cause. I trying to install nfs-utils, but I was failed, the error message is:
E: Unable to locate package: nfs-utils.
I also tried libnfs12 and libnfs-utils, they were the same as nfs-utils. I also used apt-get install upgade and update to solve the package locating problem, but they were useless.
I'm going to show the yaml file for connecting the nfs server
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-test01
lables:
disktype: baas
spec:
capacity:
storage: 1Gi
accessModes:
- ReadWriteMany
nfs:
path: /baas
server: 9.111.140.47
readOnly: false
persistentVolumeReclaimPolicy: Recycle
after using "oc describe pod/mypod" for the pending Pod, below is the feedback:
Warning FailedMount 14s kubelet, localhost MountVolume.SetUp failed for volume "pv-test01" : mount failed: exit status 32
Mounting command: systemd-run
Mounting arguments: --description=Kubernetes transient mount for /var/lib/origin/cluster-up/root/openshift.local.clusterup/openshift.local.volumes/pods/267db6f2-d875-11e9-80ba-005056bc3ce0/volumes/kubernetes.io~nfs/pv-test01 --scope -- mount -t nfs 9.111.140.47:/baas /var/lib/origin/cluster-up/root/openshift.local.clusterup/openshift.local.volumes/pods/267db6f2-d875-11e9-80ba-005056bc3ce0/volumes/kubernetes.io~nfs/pv-test01
Output: Running scope as unit run-28094.scope.
mount: wrong fs type, bad option, bad superblock on 9.111.140.47:/baas,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so.
so how can I mount to nfs server from the Pod? should I keep installing nfs-utils? If yes, how can I install it?

Trying to connect Jira (docker) to Mysql (non docker) 5.6.44 but have Connection refused

I'm trying to configure jira on a CentOS 7 virtual machine.
I managed to launch Jira's docker image without any problems with a docker-compose :
jira:
image: 'cptactionhank/atlassian-jira-software:latest'
container_name: jira
restart: unless-stopped
healthcheck:
disable: true
volumes:
- '/var/atlassian/jira:/var/atlassian/jira'
I also installed mySQL on my virtual machine (without using a docker) while following the installation procedure described here:
https://confluence.atlassian.com/adminjiraserver/connecting-jira-applications-to-mysql-5-6-938846854.html
Including :
CREATE DATABASE jiradb CHARACTER SET utf8 COLLATE utf8_bin;
CREATE USER 'jiradbuser'#'%' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON jiradb.* TO 'jiradbuser'#'%' IDENTIFIED BY 'secret';
flush privileges;
MySQL is accessible on my localhost port 3306 (the command telnet 0.0.0.0 3306 answers me well)
I also downloaded the 5.1.38 connector-j from MySQL and since I didn't have a lib folder in my /var/atlassian/jira, I created it with a mkdir and unzipped the jar in it.
I restart Jira with:
docker-compose stop jira
docker-compose rm jira
docker-compose start jira
Now, I go on my browser to the jira software address, at the time of the Database setup, I entered this information :
Database Connection: My Own Database
Database Type: MySQL 5.6
Hostname: localhost
Port: 3306
Database: jiradb
Username: jiradbuser
Password: secret
When I click on "Test Connection", it doesn't work. The answer is :
Error connecting to database
Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
Connection refused (Connection refused)
The log of jira when I click on "Test Connection" is below :
==> atlassian-jira.log <==
2019-07-19 14:42:37,906 http-nio-8080-exec-21 ERROR anonymous 882x13x1 b45eq1 10.107.135.18,172.18.0.3 /secure/SetupDatabase!connectionCheck.jspa [c.a.config.bootstrap.DefaultAtlassianBootstrapManager] Could not successfully test your database:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:339)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2253)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2286)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2085)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:795)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:44)
... 3 filtered
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:400)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:327)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.atlassian.config.bootstrap.DefaultAtlassianBootstrapManager.getTestDatabaseConnection(DefaultAtlassianBootstrapManager.java:347)
at com.atlassian.jira.config.database.JdbcDatasource.getConnection(JdbcDatasource.java:211)
at com.atlassian.jira.config.database.DatabaseConfig.testConnection(DatabaseConfig.java:88)
at com.atlassian.jira.web.action.setup.SetupDatabase.testConnection(SetupDatabase.java:230)
at com.atlassian.jira.web.action.setup.SetupDatabase.doValidation(SetupDatabase.java:194)
at com.atlassian.jira.web.action.setup.SetupDatabase.doConnectionCheck(SetupDatabase.java:126)
... 3 filtered
at java.lang.reflect.Method.invoke(Method.java:498)
at webwork.util.InjectionUtils$DefaultInjectionImpl.invoke(InjectionUtils.java:70)
at webwork.util.InjectionUtils.invoke(InjectionUtils.java:56)
... 2 filtered
at com.atlassian.jira.action.JiraActionSupport.execute(JiraActionSupport.java:63)
... 7 filtered
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
... 49 filtered
at com.atlassian.jira.security.JiraSecurityFilter.lambda$doFilter$0(JiraSecurityFilter.java:66)
... 1 filtered
at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:64)
... 31 filtered
at com.atlassian.jira.servermetrics.CorrelationIdPopulatorFilter.doFilter(CorrelationIdPopulatorFilter.java:30)
... 24 filtered
at com.atlassian.jira.servermetrics.MetricsCollectorFilter.doFilter(MetricsCollectorFilter.java:25)
... 25 filtered
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:211)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:298)
... 175 more
Is there anything I'm not doing right?
Thank you in advance.
Hugo
Mysql database is running on host (non-docker) at port 3306.
While Jira is running inside container. By-default container runs in bridge networking mode, where container network is different from host network. Hence localhost inside container is not the same as on host.
Here you can do two things:
In your Jira container refer to mysql database using private/public-ip:3306
OR
Run Jira docker container in host networking mode, so that localhost inside container is same as that on host. Because in this mode container uses network of host.
jira:
image: 'cptactionhank/atlassian-jira-software:latest'
container_name: jira
restart: unless-stopped
healthcheck:
disable: true
volumes:
- '/var/atlassian/jira:/var/atlassian/jira'
network_mode: "host"
NOTE: network_mode: "host" option will tell docker container to use host networking mode.
Hello and thank you for your answer. The network_mode: "host" didn't work for me because I also use Traefik. But you put me on the right track and this outcome helped me: How to connect locally hosted MySQL database with the docker container
The solution to my problem was to use this command :
docker inspect <container-id-or-name> | grep Gateway
"Gateway": "",
"IPv6Gateway": "",
"Gateway": "172.18.0.1",
"IPv6Gateway": "",
And use 172.18.0.1 instead of "localhost" for the "host" field of my local mySQL database
My solution was to set host.docker.internal instead of localhost in the connection url in the dbconfig.xml file. In the Dockerfile I have the following lines:
EXPOSE 3306
VOLUME ["/var/atlassian/application-data/jira"]
I hope it helps

How to connect spring-boot and mysql using docker?

I tried to make some rest API using spring-boot and MySQL.
And I finished it in my eclipse environment.
The next step is to create a docker image.
However, when I run the MySQL server and my rest API in docker, it gives me a connection refused error.
I found other basic spring-boot and MySQL tutorials. But I can't solve this problem.
This is mysql setting of spring-boot project.
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/users?allowPublicKeyRetrieval=true&useSSL=false&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username = root
spring.datasource.password = root
#spring.ldap.embedded.base-dn=dc=example,dc=org
#spring.ldap.base=dc=example,dc=org
#spring.ldap.password=admin
#spring.ldap.username=cn=admin,dc=example,dc=org
#spring.ldap.urls=ldap://localhost:389
##Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
#Open session in View
#spring.jpa.open-in-view=true
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate.ddl-auto=update
This is command to run mysql in the docker.
docker urn -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root --name mysql mysql
This is my docker file to make docker image for rest API.
FROM java:8
VOLUME /tmp
EXPOSE 8080
ADD target/userManageWithRest-0.0.1-SNAPSHOT.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
This is error message.
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_111]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_111]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_111]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_111]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.15.jar!/:8.0.15]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.15.jar!/:8.0.15]
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.15.jar!/:8.0.15]
at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.15.jar!/:8.0.15]
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91) ~[mysql-connector-java-8.0.15.jar!/:8.0.15]
at com.mysql.cj.NativeSession.connect(NativeSession.java:152) ~[mysql-connector-java-8.0.15.jar!/:8.0.15]
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:955) ~[mysql-connector-java-8.0.15.jar!/:8.0.15]
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825) ~[mysql-connector-java-8.0.15.jar!/:8.0.15]
... 56 common frames omitted
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_111]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_111]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_111]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_111]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_111]
at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_111]
at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155) ~[mysql-connector-java-8.0.15.jar!/:8.0.15]
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65) ~[mysql-connector-java-8.0.15.jar!/:8.0.15]
... 59 common frames omitted
I already tried to modify spring.datasource.url to jdbc:mysql://mysql:3306/users?....
How can I solve this problem?
Please help me.
As your MySQL database and Spring Boot app are running in a separate Docker container, access localhost or 127.0.0.1 within a Docker container isn't referring to the localhost of your host machine.
I would suggest to use docker-compose to link the Spring Boot application to your MySQL container and make it accessible via mysql as hostname as you have already tried it (jdbc:mysql://mysql:3306/users?...):
version: "3"
services:
backend:
build: .
depends_on:
- "mysql"
links:
- mysql
ports:
- "8080:8080"
mysql:
image: mysql:latest
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: root
Save this in the folder where your Spring Boot Dockerfile is located as docker-compose.yml and the run docker-compose build && docker-compose run.
With the links attribute to give access to your MySQL container via the container name and as they are sharing the same Docker network, the mysql hostname is resolved correctly
Even though this question is a bit old, I believe this explanation might be useful.
The reason for your issue is that you can control the order of service startup and shutdown with the depends_on option. Compose always starts and stops containers in dependency order, where dependencies are determined by depends_on, links...
However, for startup Compose does not wait until a container is “ready” (whatever that means for your particular application) - only until it’s running.
That may cause some issues, e.g. your spring-boot app starts very fast and tries to connect to MySQL, but even though MySQL container has started - MySQL inside is not ready to accept connections yet.
There are some workarounds for this. If you are interested in them, you might want to check this question.