Thursday, May 11, 2023

AWS Log insights stdout F

 Make sure you replace the following lines:

  • Parser              docker
With the following:

  • multiline.parser    docker, cri

This is due Kubernetes migrating from docker to containerd.


Wednesday, January 25, 2023

Kubernetes pods stuck in terminating state

 First try to do the following:

kubectl delete pod -n <namespace>  <pod name> --force --grace-period=0


If that does not work then edit the pod, like:

kubectl edit pod -n <namespace>  <pod name>


And remove the finalizers section and save

finalizers:
- <something here>

Wednesday, December 21, 2022

Kubernetes Grafana Dashboards

 I was trying to install Prometheus and Grafana in one of my Kube clusters. So I download Prometheus and Grafana helm repos, to my surprise most of the predefined dashboards that I found were not working, so I spent hours figuring out why; there were some missing metrics and components not installed by default. At the end, I was able to make some of those work.


For days, I thought that there was not a prebuilt Grafana/Prometheus dashboard solution until I took a look into Rancher, in their documentation they make a reference to Kube-Prometheus-Stack.  Not sure why I did not find this helm chart before, it already contains a full set of Grafana dashboards that will help you monitoring Kubernetes (pods, workloads, namespaces, etc). 


Here is the link to the Helm Chart.

Tuesday, February 9, 2021

User defined Java Class getRow null

 I have been working with Pentaho Kettle, and I needed to add some scripts, I decided to use Java since you can import some extra libraries, which is not allowed on Javascript component (or I haven't found how). 


I read the documentation and I implemented the processRows method, while testing I realized that getRow method was returning 'null' every time, at the beginning I thought it was related to the input type so I tried a couple, json, csv, excel, etc, and I always had the same result.


What was the solution? I was missing `putRow(...)` line, I am not sure what internally does but after adding it then getRow() started sending objects instead of null. I mean it makes kind of sense since if you miss putRow then whatever you do inside this component will not propagate further, I just wish it was documented somewhere.


So your code should look like this:



public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException

{

// you need this

Object[] r = getRow();

// this

r = createOutputRow(r, data.outputRowMeta.size());

// and this to send the row on to the next step.

putRow(data.outputRowMeta, r);



return true;

}



Wednesday, December 4, 2019

jenkins-log.txt Permission denied

I started getting the error below, after recreating Jenkins setup thru helm charts. At the beginning I thought I had missed to install a plugin, or installed one that corrupted Jenkins pipelines. So after starting from scratch I could not find why it was working before and then got broken.

sh: 1: cannot create /home/jenkins/agent/workspace/myproject/durable-48fa5881/jenkins-log.txt: Permission denied

So after reading a thread on Jenkins blog; I realized that "Jenkins" user is being used by Jenkins, and I was using "myuser" in my pod. So, I changed everything in my Dockerfile to match Jenkins slave image, like the following:

RUN groupadd --gid 10000 jenkins && useradd --gid 10000 --uid 10000 jenkins --shell /bin/bash
RUN mkdir /home/jenkins && chown -R jenkins:jenkins /home/jenkins
USER jenkins
WORKDIR /home/jenkins

After that, the permission denied error went away. I am still wondering how this was working before...


Tuesday, June 25, 2019

sbt-native-packager /opt/docker permission denied

I was getting all sorts of issues when trying to create files or directories below "/opt/docker" path. I tried adding:

import com.typesafe.sbt.packager.docker.DockerChmodType
dockerChmodType := DockerChmodType.UserGroupWriteExecute

It did not work, I was still getting errors, permission denied, while trying to write PID file to "/opt/docker/PID_FILE".

The solution is adding the following:

javaOptions in Universal ++= Seq(
  // Since play uses separate pidfile we have to provide it with a proper path  // name of the pid file must be play.pid  s"-Dpidfile.path=/var/run/play.pid")

Basically indicating Play framework to write PID file in another location, then:

dockerCommands ++= Seq(
  ExecCmd("RUN", "mkdir", "-p", s"/var/run/")
)

It would create another directory. Then, execute:

sbt dist && sbt docker:publishLocal

Finally you can write the following in a bash file:

dir=$(pwd)
docker run -v $dir/my_play_project:/var/run -v \ 
$dir/my_play_project/logs:/opt/docker/logs -p 9000:9000 \ 
 my_play_project:1.0


Sunday, December 27, 2015

NullPointer Exception while testing with Scala Futures...

So I was trying to unit testing Scala Futures, and I was getting NullPointerException out of nowhere. I was frustrated since the stacktrace didn't much more information, not a minimal clue of what was missing. It was until I payed attention to some other examples when I realized that I was missing something important:
import ExecutionContext.Implicits.global
I do not know why it wasn't detected at compile time, or why the exception was only coming as NullPointerException without any other hint. My test is something like this:

"Some test" should {
    "execute this" in {   
      val client = mock[AClass]
      val host = new BClass(client) 
      doReturn(Future {x}).when(client).aMethod(any[String], any[String]) // This was throwing a NPE
      val response = host.anyMethod(cI, mA, bL)
      Await.result(response, Duration(30, SECONDS)) 
      there was one(client). aMethod(any[String], any[String])
    }
  }