Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

.NET runtime - Exit with error code in compile initContainer #92

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions stable/dotnetcore/compile-function.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#!/bin/bash

Copy link
Contributor

@allantargino allantargino Sep 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lorenzo-ange, what if you use the following set attributes:

  • set -e to exit on the first error.
  • set -x to show each command before executing it.

This would avoiding multiple calls to the exit_on_error.

exit_on_error() {
exit_code=$?
last_command=$(fc -ln -1 | awk '{$1=$1};1')
if [ $exit_code -ne 0 ]; then
echo "\"${last_command}\" command failed with exit code ${exit_code}."
exit $exit_code
fi
}

# kubeless function directory
PROJECT_MOUNT=$1
echo Mount $PROJECT_MOUNT
Expand Down Expand Up @@ -28,4 +37,6 @@ fi

# compile
dotnet restore $USER_PROJ --packages $PACKAGES_DIR
exit_on_error
dotnet publish $USER_PROJ -o publish -c Release --no-restore
exit_on_error
2 changes: 1 addition & 1 deletion stable/dotnetcore/dotnetcore.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
version: "3.1",
images: [{
phase: "compilation",
image: "lorenzoangelini3/kubeless-compile-dotnetcore31@sha256:12a85136102b9df6b09138dadd3bf77af111dc992286a0fd8ab4b03fd897fcc5",
image: "lorenzoangelini3/kubeless-compile-dotnetcore31@sha256:c930e3c575af881d2ca537322ee7149e91c868b18b4036dae3f3624c3683ebc2",
command: "/app/compile-function.sh $KUBELESS_INSTALL_VOLUME"
}, {
phase: "runtime",
Expand Down