Laur IVAN

HTTP 400 Bad Request with docker-maven-plugin

Posted by in IT

TL;DR: Check your Dockerfile (try to build it manually) before anything else! Today I was struggling with a 400 error: Exception caught: Request error: POST https://192.168.99.101:2376/build?t=localhost:5000/eris-django:2.0.1-ivanlla: 400: HTTP 400 Bad Request -> [Help 1] when building an image with the docker-maven-plugin. After installing and uninstalling docker, cleaning up certificates etc, I figured out my setup had nothing to do with it. Instead, there was a configuration error or the docker file. More specific, I was using alpine and I forgot the RUN prefix to a command. I’ve tried to dun…read more

Initialise Python with GoCD

Posted by in IT, Tutorial

Following the deployment of a python-aware agent, we can start creating a pipeline. The first stage would be to: Clean up any previous data Create a virtual environment for python Install all dependencies from a requirements.txt file in our project Note: we assume the global pipeline settings and the Materials are properly set up (e.g. out project will be checked out in ./project). Since the above operations must be executed in order, I’ve set up a Setup stage with a job named virtualenv. The job has three tasks: rm virtualenv…read more

Create a Python-friendly GoCD Agent in Docker

Posted by in IT, Tutorial

I’ve got two requirements to make GoCD useful: Run both the server and agent(s) in Docker Make it python-friendly Fortunately, GoCD offers Docker images (and Dockerfiles) for both, so it’s just a matter of extending it:

Unfortunately, pip is not quite adequate, so we re-install it from source. In the Dockerfile we add:

Now we have a fully functional Docker file capable of building python applications and we can actually build the image. In the directory where we have the Dockerfile, execute:

Then, you can run it…read more

Allow Docker Container Access Behind Proxy

Posted by in IT, Tutorial

In the previous post, I’ve described how to build an image when you’re behind a proxy. Now, if your container needs access to the internet for e.g. downloading python dependencies, you’ll need to give it explicitly. The way to do it is via -e parameter (environment) of docker run. You can either make it verbose, or you can build an alias:

Then, you can just execute:

HTH, A little experiment: If you find this post and ad below useful, please check the ad out :-)

Don’t Symlink Indices in ElasticSearch!

Posted by in IT

The other day I’ve been trying to improve the downtime when updating an index in elasticsearch (ES) and I’ve decided the best approach would be to create a new index and do a symlink to the active one, keeping the valid index. so, my structure would be:

Note: this is likely not a best practice :) This would allow me to build an index with other means, and only do a stop/change link/restart cycle which would be much quicker :) This is simplified, of course, but you get the…read more

Show What’s on Swap in Linux

Posted by in IT, Tutorial

If you find your machine running sluggish, it might be the case that you have too many things running and it’s hitting the swap. You can check how bad (or good) things are with htop, but it won’t tell you which process is sitting on swap. To find out, I’ve cooked up a tiny script:

It will look in /proc/[PID]/status and get the VmSwap field. Then, it’ll print it out along with the PID and the command line (from ps -ax). Note: This is a rather crude script and…read more

Fix Jenkins POM Freezer
“Wrong Relative POM” Error

Posted by in IT, Tutorial

If you get a build error in Jenkins like:

Then you have a POM freezing issue with the parent POM. I.e., the Jenkins plugin has failed to freeze the POM version from a 1.0-SNAPSHOT to an actual 1.0-6034-79. A cause can be the plugin expects a certain sequence of tags in the POM and doesn’t find it. In my case, the initial configuration was:

and the expected configuration would be something like

Note the sequence group – artifactId – version. HTH, A little experiment: If you find…read more

Clean Up Your Zookeeper History

Posted by in IT

TL;DR: Use zkCleanup.sh -n 5 command: By default, Zookeeper does not delete any of its history to allow recovery. This however can lead to disk space issues over long-ish periods of time. Therefore, it is advisable to clean up once in a while. Update: I found out that /usr/share/zookeeper/bin contains a script named zkCleanup.sh. You can use it to remove the old logs:

It basiacally executes the command line below:

The manual way My configuration is: The database is located on /var/lib/zookeeper

zookeeper.jar and slf4j-api.jar in /usr/share/java…read more

Match String on Multiple Columns

Posted by in Software

TL;DR: Use concatenation, Luke! I had to search a name for an user in a table containing the first and last names in separate columns. After a while I got tired on looking up the first_name and last_name columns one at a time and I decided to try and search both. The result is something like:

I have to do the LOWER() call because the names are provided by user input. At first I’ve been worried about performance, but since this is not a recurrent query, it’s acceptable (0.25s…read more

Make a Shell Script with Arguments (Native)

Posted by in Software, Tutorial

I was building a bash script and I needed several arguments to make it more versatile (e.g. dry-run). The list of parameters was: help as -h or –help dry run ad -d or –dry-run to go through the motions without actually executing commands keep last N images ad -k num or –keep num to keep last N images (default 5) As one can see, none of the parameters are compulsory and have default values:

The snipped taking care of my input parameters is:

The idea is that we…read more