How to exit a fluentd process? - fluentd

I have a custom fluentd plugin written in ruby. If there is an error I want to exit the process but it seems to keep going.
For example:
log.error("error, exit code")
The programs logs an error but keeps moving forward. Same behavior when I tried raise and exit. How do I exit completely?

Related

For Kubernetes pods how to find cause of exit code 2

I have pods that are of kind Cronjob running in parallel. They complete task and run again after fixed interval of 20 minutes as per cron expression. I noticed that some pods are restarting 2-3 times before completing task.
I checked details in kubectl describe pod command and found that pod exit code 2 when it restart due to some error:
Last State: Terminated
Reason: Error
Exit Code: 2
I searched about exit code 2 and found that it is misuse of a shell builtin commands. How I can find which shell builtin is misused. How to debug cause of exit code 2.
Thanks in advance.
An exit code of 2 indicates either that the application chose to return that error code, or (by convention) there was a misuse of a shell built-in. Check your pod’s command specification to ensure that the command is correct. If you think it is correct, try running the image locally with a shell and run the command directly.
Refer to this link for more information.
You can get logs with
kubectl logs my-pod
Post output here if you can't fix it.

How to gain visibility of the output of a bash script executed from a Dockerfile?

I received this error message which means something is erroring inside a bash script executed by the Dockerfile.
As an example, if something inside test.sh errors:
RUN test.sh
# 16 ERROR: executor failed running [/bin/sh -c test.sh]: exit code: 127
Question
What is the recommended way to gain visibility over the exact error message (i.e. to find out what's gone wrong) and to diagnose which line(s) of a bash script executed from a Dockerfile are problematic? Can docker be made to provide the output of the bash script so the exact error message is provided? Rather than just the somewhat cryptic:
executor failed running exit code: 127
as seen here.
What I know so far
One way to diagnose which line(s) is playing up is to survey the script, assess which line(s) might be causing problems, and comment out the suspect line and everything after it. If the error goes away, you've found the (first) line that is a problem, and it can be addressed. Rinse and repeat until the script is error-free. But this seems more manual than one would hope.

Azure DevOps: docker-compose over SSH normal messages interpreted as error

docker-compose, normal messages interpreted as errors in Azure DevOps
I have Release pipeline in Azure DevOps where I'm connecting to to server trough SSH and running docker-compose up command along with others.
Problem is that normal messages are interpreted as errors so release fails even when everything was successful.
After this release everything is up and running.
Does anyone know why these messages were interpreted as errors?
I found out that docker writes those messages to stderr instead of stdout. In Azure DevOps pipeline in SSH task there is option Fail on STDERR which is checked by default. When I uncheck this option release no longer fails on this step even messages are marked as error.
What really bothers me is that now even when some real error occurs, it will be ignored. I really don't know why they designed is like this, but that's for another topic.
Links: https://github.com/docker/compose/issues/5296
Before it should be fixed on Azure Devops side (imho), as a workaround the issue can be solved with redirect the STDERR and STDOUT to variable and handle the exit code of docker-compose command
Example:
# Suppress STDERR messages,
OUTPUT_MESSAGE=$(sudo docker-compose up --force-recreate -d 2>&1)
#Handle exit code
if [ $? -eq 0 ]
then
echo $OUTPUT_MESSAGE
echo "Deployed successfully"
exit 0
else
echo "Deployment failed"
echo $OUTPUT_MESSAGE
exit 1
fi

Stop nolio deployment on command line script fail

I've tried to search for this but i couldn't fine anything. I have a Nolio flow that has a command line action to deploy a solution with psake. The command line is run like this:
psake.cmd .\deploy.ps1 -parameters #{env='Environment'} if ($psake.build_success -eq $false) { exit 1 } else { exit 0 }
But if the script deploy.ps1 fails the nolio deployments hangs and need to be stopped manually.
Is there a way to make the deployment stop automatically when the script fails?
I found a solution for this. Nolio offers an action called "ROC - Fail Deployment Step". I achieved what i wanted by deselecting the pause on failure and adding this action after the script execution and setting the operation on link to "On failed"

Compile time error for plist entry

I need to generate a build error if a plist entry is not present. How can I approach it ? Any information on this would helpful.
You need to write a script that checks the .plist file as part of the build.
See Running a Script While Building a Product.
If the script terminates with a non-zero exit code (i.e. exit 1) then the build will fail.
MAC OS X's has already a built in tool for your issue :- /usr/libexec/PlistBuddy
For success, it returns exit code is 0
For failure, it returns exit code is nonzero
For regular output is sent to stdout, error messages is sent to stderr

Resources