Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: driver versioning #76

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
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
29 changes: 29 additions & 0 deletions driver-describe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

set -exo pipefail
# This script outputs a version string (along the lines of git-describe)
# to identify the driver version currently in use, starting from tags
# in falcosecurity/libs (or its fork draios/agent-libs).

# to be called from that directory

git version >/dev/null || (echo "Please install git" && exit 1)

[[ -e .git && -e driver/ ]] || (echo "Please run this script from the root folder of the agent-libs git workspace" && exit 1)

LAST_COMMIT=$(git log -1 --pretty=format:"%h")
# TODO find a better name for tag prefix
LAST_TAG=$(git describe --tags --abbrev=0 --match "driver-*" || echo "")
if [[ -n "$LAST_TAG" ]]; then
LAST_VERSION=$(echo $LAST_TAG | cut -c 8-) # TODO beware of driver- prefix
# Check the number of commits which *actually* changed _something_ in driver/
N_COMMITS=$(git log --oneline ...${LAST_TAG} -- driver/ | wc -l)
if [[ ${N_COMMITS} -gt 0 ]]; then
echo "${LAST_VERSION}-${N_COMMITS}-${LAST_COMMIT}"
else
echo "${LAST_VERSION}"
fi
else
# We couldn't find a tag, let's make something up
echo "0.0.0-0-${LAST_COMMIT}"
fi
9 changes: 8 additions & 1 deletion sysdig-probe-loader
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,14 @@ if [ "${SCRIPT_NAME}" = "sysdig-probe-loader" ]; then
PACKAGE_NAME="sysdig"
elif [ "${SCRIPT_NAME}" = "sysdigcloud-probe-loader" ]; then
EXEPATH=$(dirname "$(readlink -f "${0}")")
# If we were give a SYSDIG_VERSION (which is, indeed, a DRIVER_VERSION), we can just accept it.
# Otherwise, we look for one.
if [ -z "$SYSDIG_VERSION" ]; then
# Look for an explicit driver version requirement, if we have one
SYSDIG_VERSION=$(sed -n -e 's/driver version: \(.*\)/\1/p' /opt/draios/etc/.agent_build)
fi
if [ -z "$SYSDIG_VERSION" ]; then
# As a fallback, look for the exact version (this should be the case up to 12.11.0)
SYSDIG_VERSION=$("${EXEPATH}"/dragent --version)
fi
PROBE_NAME="sysdigcloud-probe"
Expand Down Expand Up @@ -770,4 +777,4 @@ if [ $? -eq 1 ]; then
exit 1
fi
echo "Probe loaded"
exit 0
exit 0