The Perfrect Build Script

A build script should be simple, extensible and compile native.

Generally shell scripts do great job as build scripts. But if your development environment consist of Linux, Windows and Docker environments, shell script do not run out of the box on every platform. As well scripting languages like python need dependencies and are difficult to maintain for different platforms.

The solution would be a script which can run without dependencies on every platform. The solution I picked is “golang”. Runs as script, compiles native, easy to cross compile and does not need any dependencies.

Since all artifacts produces are docker images, the script is called “captain”

Add Jenkins Tool Location with ansible

Resently I hat do setup a jenkins slave with ansible. I used some ansible roles from ansible-galaxy, but all did miss to set the tool location.

So I read some java doc and added the tool location config to the ruby-jinja2 template.

import hudson.model.AbstractBuild
import hudson.model.Node
import hudson.plugins.sshslaves.SSHLauncher
import hudson.plugins.sshslaves.verifiers.NonVerifyingKeyVerificationStrategy
import hudson.plugins.sshslaves.verifiers.SshHostKeyVerificationStrategy
import hudson.slaves.ComputerLauncher
import hudson.slaves.DumbSlave
import hudson.util.VariableResolver
import jenkins.model.Jenkins
import hudson.slaves.*
import hudson.slaves.EnvironmentVariablesNodeProperty.Entry
import hudson.plugins.git.GitTool
import hudson.plugins.git.GitTool$DescriptorImpl

List env = new ArrayList();
{% for item in (slave_environments | dict3items) %}
env.add(new Entry("{{ item.key }}", "{{ item.value }}"))
{% endfor %}

List toolLoc = new ArrayList();
{% for item in (slave_tool_locations ) %}
toolLoc.add(new ToolLocationNodeProperty.ToolLocation(ToolInstallation.all().get(hudson.plugins.git.GitTool$DescriptorImpl.class), "{{ }}", "{{ item.home }}"))
{% endfor %}

EnvironmentVariablesNodeProperty envPro = new EnvironmentVariablesNodeProperty(env);
ToolLocationNodeProperty envToolLoc = new ToolLocationNodeProperty(toolLoc);

Jenkins jenkins = Jenkins.getInstance()

String nodeHostname = "{{ slave_linux_host }}"
String nodeCredentialID = "{{ slave_linux_jenkins_cred_id }}"
int nodePort = {{ slave_linux_ssh_port }}
SshHostKeyVerificationStrategy strategy = new NonVerifyingKeyVerificationStrategy()

ComputerLauncher nodeLauncher = new SSHLauncher( nodeHostname, nodePort,
nodeCredentialID, null, null, null, null, 31, 20, 10, strategy )

String nodeName = "{{ slave_agent_name }}"
String nodeRemoteFS = "{{ slave_linux_home }}"

Node node = new DumbSlave(nodeName, nodeRemoteFS, nodeLauncher)
node.setNumExecutors({{ slave_executors_num }})
node.setLabelString("{{ slave_linux_labels | join(' ') }}")
{% if slave_mode_exclusive %}
{% else %}
{% endif %}

If this did help you, consider to send me flower or a donut.

docker volume performance (portworx, nfs, bind mount)

I consider using NFS for shared volume on Docker Swarm. So I wonder how the performance of Docker NFS volumes may be.

Docker cache or delegated volumes have a huge effect on read an mostly outperform native read by far. On direct io this options do not have any effect.

The test is done on local host all to the same physical disk. Network latency is no considered. The Portworx is a standalone setup and might not represent the performance of a large cluster with replication.

docker run -it --rm -v jenkins_vol:/demo -v nfstest:/nfs ubuntu 

root@686890cca159:/# set -o vi                                                                                                                                                                                                                                                                                                                                                                                                                                                   
root@686890cca159:/# dd if=/dev/zero of=/bindmount/test bs=1M count=1000 oflag=direct                                                                                                                                                                     
1000+0 records in                                                                                                                                                                                                                                        
1000+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 4.80277 s, 218 MB/s
root@686890cca159:/# dd if=/dev/zero of=/portworxvolume/test bs=1M count=1000 oflag=direct                                                                                                                                                               
1000+0 records in                                                                                                                                                                                                                                        
1000+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 6.08722 s, 172 MB/s
root@686890cca159:/# dd if=/dev/zero of=/nfs/test bs=1M count=1000 oflag=direct                                                                                                                                                                          
1000+0 records in                                                                                                                                                                                                                                        
1000+0 records out
1048576000 bytes (1.0 GB, 1000 MiB) copied, 15.3807 s, 68.2 MB/s

But still the NFS seem to be significantly slower. NFS tuning did not change write performance.

Index Oracle RDBMS in Solr using Apache Spark

After I wrote multiprocessing python script which can be scaled with multiple docker containers to load billions of records from Oracle RDBMS to Solr Cloud I started to think of simpler solutions.

The basic idea is to handle all multiprocessing and scaling aspects by spark. As Spark is able to partition jdbc datasources out of the box the prove was needed that data can be saved in solr. Spakr-Solr provides the needed functionality.

Environment Preparation:

  • Setup Solr Cloud on Docker (one node in cloud mode is sufficient, create a collection “test”)
  • Run Oracle 18c on Docker
  • Run a Spark Cluster on Docker (I used this Spark images)

Copy the jdbc driver and the spark-solr driver

docker cp ojdbc8.jar spark-master:/
docker cp spark-solr-3.6.4-shaded.jar  spark-master:/
docker cp ojdbc8.jar spark-worker-1:/
docker cp spark-solr-3.6.4-shaded.jar  spark-worker-1:/

Start the Spark Shell (I use the pyspark) and load the date into a data frame

docker exec -it spark-master /spark/bin/pyspark --jars /ojdbc8.jar,/spark-solr-3.6.4-shaded.jar

empDF = \
    .format("jdbc") \
    .option("url", "jdbc:oracle:thin:test/test@//") \
    .option("dbtable", "test.emp") \
    .option("user", "test") \
    .option("password", "****") \
    .option("driver", "oracle.jdbc.driver.OracleDriver") \

Now save the date to Solr Cloud


And the date is in Solr Cloud.

On a Test with more date I had to add the Option .option(“commit_within”, “5000”)
I could not find explicit commit on solr-spark.

This solution should able scale well on a spark cluster by partitioning the data on the jdbc side. Transformation can be added on Spark. And such a solution would much less complex and better maintainable then a python multiprocessing solution (who ever used python multiprocessing may know what I mean).

If you have used similar setup please share your experiences.

Scale docker application with HAProxy

To be able to scale a docker service a instance can not have a static port definition for export.
HAProxy is a simple way to load balance traffic to diffrenet docker containers.

The concpet is that every container expose a port (can be the same for all), but not publish any ports.
HAProxy exports one port which gets distributed to all containers.

The application has to set the environment varialbe SERVICE_PORTS (for swarm). That’s all.

See this docker-comose (for stack):

version: '3'
    build: .
    image: rit_app
      - SERVICE_PORTS=80
      - 80
      - nw-rit
    image: dockercloud/haproxy
      - app
      - BALANCE=roundrobin
      - /var/run/docker.sock:/var/run/docker.sock
      - "8102:80"
      - nw-rit
        constraints: [node.role == manager]

How check the jdbc client version in your database?

On the java side you can check the JDBC Client Version very easy.

java -jar ./mwhome/.../ojdbc7.jar -getversion
Oracle JDBC 4.1 compiled with JDK7 on Mon_Jun_30_11:30:34_PDT_2014
#Default Connection Properties Resource
#Tue Apr 17 14:13:51 CEST 2018

But somethimes you may not have access to the application server (here Weblogic) or there are many version installed on the application side.
So the best way is to check in you Oracle Database who your client are.

Crypto-checksumming service for Linux: Version - Production
Unknown                                  Heterogeneous                               jdbcthin

This is a reliable way to find how (jdbcthin, oci, ..) and with what JDBC Version the client are connecting.

Oracle: udpate a XML value in place with sql

Oracle sql provides a simple way to update values in a xml document by sql.
The “updatexml” function can udpate any fields in by xpath.

update SCOTT.DEMO" d
where id=1234;

to update multiple values at once:


Very handy to update large documents.

Login into Oracle Database without password / Autologin

Here I try to explain most simple and short way to login with a oracle wallen / without password.

create wallet:

mkstore -wrl -createCredential mkstore -wrl -listCredential

configure client side sqlnet.ora:


configure tns alias in tnsnames.ora: =

If the oracle instant client is used the location of sqlnet.ora and tnsnames.ora needs to defined with the TNS_ADMIN environment variable .


Oracle on Docker (I): Backup / Restore Oracle RDBMS on Docker

Running Oracle on Docker is a great way for Testing Features or Development environments, specially for offline development on notebooks which require an oracle database.

If you have setup an oracle Image according oracle rdbms docker and choosen to create your db on docker volumes. And mounted backup1 volume at /backup.

docker volume create oracledb1
docker volume create backup1

Create an offline backup:

docker exec -u 0 -it ora122 bash
bash-4.2# chown oracle /backup

docker exec -ti ora122 sqlplus / as sysdba
SQL> alter database close;

Database altered.

docker exec -ti ora122 rman target /
backup database format '/backup/%U' tag=bk1;

Restore Database from Backup

docker exec -ti ora122 rman target /
RMAN> restore database from tag=BK1

RMAN> shutdown immediate

RMAN> startup mount

RMAN> alter database open resetlogs;