Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6be5b58
Add agent-managed firewall with nftables
rkoster Jan 30, 2026
124865a
Add unit tests for firewall package with dependency injection
rkoster Jan 30, 2026
0a2a73f
Fix comments: firewall-allow is for BOSH jobs, not monit
rkoster Jan 30, 2026
2a57ce4
Use LinuxOptions.EnableNATSFirewall instead of reading OS file
rkoster Jan 30, 2026
30083bf
Move NATS firewall to mbus hook for DNS re-resolution on reconnect
rkoster Jan 30, 2026
2d4846c
Add DROP rule to block non-agent processes from director NATS
rkoster Jan 30, 2026
52acc03
Add CLI fallback for nftables in nested containers
rkoster Jan 30, 2026
8aac7ab
Fix cgroupv2 socket matching: use level 1 and trim leading slash
rkoster Jan 30, 2026
d710ff5
Fall back to UID matching on hybrid cgroup systems
rkoster Jan 30, 2026
c8381c2
Use packet marks for cross-table firewall coordination
rkoster Jan 30, 2026
44e4aed
Fix NATS firewall test for hybrid cgroup and nested container environ…
rkoster Jan 30, 2026
154a760
Run nats firewall tests in order (ipv4 first)
rkoster Jan 30, 2026
e147ca4
Add Noble (systemd) support to integration test framework
rkoster Jan 30, 2026
d211046
Add Noble support to CI integration test script
rkoster Jan 30, 2026
2ae2aa3
Fix NATS firewall test for Noble (pure cgroupv2 with systemd)
rkoster Jan 30, 2026
ba03b76
Clean up log file and nftables before NATS firewall test
rkoster Jan 30, 2026
5ece036
Wait for nftables rules directly instead of log messages
rkoster Jan 30, 2026
27f6349
Fix systemd agent start/stop for integration tests
rkoster Jan 30, 2026
56772d1
Use systemctl restart for systemd integration tests
rkoster Jan 30, 2026
5c48e63
Add debug logging for cgroup path and BeforeConnect
rkoster Jan 30, 2026
922efcf
Add debug output to NATS firewall test after 30s timeout
rkoster Jan 30, 2026
c3813ed
Fix CleanupDataDir to create /var/log/audit for Noble
rkoster Jan 30, 2026
f5a5759
Fix build errors and remove CLI firewall fallback
rkoster Feb 2, 2026
8e2168f
Fix errcheck lint errors in integration tests
rkoster Feb 2, 2026
e9b0554
Add linux build tags to Linux-only fakes
rkoster Feb 2, 2026
3052386
Add port range validation to fix CodeQL integer conversion warning
rkoster Feb 2, 2026
a6faa6e
Fix nftables cgroup v2 socket matching - use UID fallback
rkoster Feb 2, 2026
391d370
Fix nftables cgroup v2 socket matching using cgroup inode ID
rkoster Feb 2, 2026
ada24e8
Remove UID fallback for hybrid cgroup systems
rkoster Feb 2, 2026
ffe8e6c
Add Garden container firewall integration tests
rkoster Feb 2, 2026
7b500e9
Replace Skip() with Expect() in garden firewall tests to fail fast
rkoster Feb 3, 2026
8e30313
Move Garden firewall tests to separate suite to preserve Garden durin…
rkoster Feb 3, 2026
d262967
Add nft-dump utility for firewall test verification
rkoster Feb 3, 2026
d719003
Auto-build nft-dump binary when not found
rkoster Feb 3, 2026
7a6d95c
Fix intermittent cleanup failures for /var/tmp on Noble
rkoster Feb 3, 2026
79b9668
Add cgroup debugging and try child cgroup approach for firewall test
rkoster Feb 3, 2026
09177a2
Fix pgrep pattern to find bosh-agent process
rkoster Feb 3, 2026
5216420
Make /var/tmp cleanup non-fatal since we recreate it immediately after
rkoster Feb 3, 2026
2d8b61c
Skip empty loop device names in ResetDeviceMap
rkoster Feb 3, 2026
687bf7f
Add gardeninstaller package for Garden integration tests
rkoster Feb 3, 2026
fefc2f0
Enhance gardeninstaller with direct store mode and nested container s…
rkoster Feb 4, 2026
9db3be3
Refactor Driver abstraction with Bootstrap lifecycle for nested Garde…
rkoster Feb 4, 2026
dea25a1
Enable nested Garden firewall tests with containerd mode and cgroup s…
rkoster Feb 4, 2026
867fa5e
WIP: netcat tunnel approach for nested Garden connectivity
rkoster Feb 4, 2026
ae490c5
Replace netcat tunnel with NetIn port forwarding for nested Garden tests
rkoster Feb 4, 2026
f4af27c
Fix nftables monit firewall rules and add block rule for non-agent co…
rkoster Feb 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions agent/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ func (boot bootstrap) Run() (err error) { //nolint:gocyclo
return bosherr.WrapError(err, "Setting up networking")
}

if err = boot.platform.SetupFirewall(settings.GetMbusURL()); err != nil {
return bosherr.WrapError(err, "Setting up firewall")
}

if err = boot.platform.SetupRawEphemeralDisks(settings.RawEphemeralDiskSettings()); err != nil {
return bosherr.WrapError(err, "Setting up raw ephemeral disk")
}
Expand Down
205 changes: 205 additions & 0 deletions bin/compile-garden-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
#!/bin/bash
# Script to compile a garden-runc release using Docker and bosh-agent compile
# Based on https://bosh.io/docs/compiled-releases/#bosh-agent-compile
#
# Usage:
# ./bin/compile-garden-release.sh [RELEASE_DIR] [OUTPUT_DIR]
#
# Arguments:
# RELEASE_DIR - Path to garden-runc-release source (default: ~/workspace/garden-runc-release)
# OUTPUT_DIR - Output directory for compiled tarball (default: ./compiled-releases)
#
# Environment variables:
# STEMCELL_OS - Stemcell OS to compile for (default: ubuntu-noble)
# STEMCELL_VERSION - Stemcell version (default: latest)

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_DIR="$(dirname "$SCRIPT_DIR")"

# Arguments
RELEASE_DIR="${1:-${HOME}/workspace/garden-runc-release}"
OUTPUT_DIR="${2:-${REPO_DIR}/compiled-releases}"

# Stemcell configuration
STEMCELL_OS="${STEMCELL_OS:-ubuntu-noble}"
STEMCELL_VERSION="${STEMCELL_VERSION:-latest}"

# GitHub Container Registry image for stemcells
# See: https://github.com/orgs/cloudfoundry/packages?repo_name=bosh-linux-stemcell-builder
STEMCELL_IMAGE="ghcr.io/cloudfoundry/${STEMCELL_OS}-stemcell:${STEMCELL_VERSION}"

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color

log_info() { echo -e "${GREEN}[INFO]${NC} $*" >&2; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*" >&2; }
log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }

# Check prerequisites
check_prerequisites() {
if ! command -v docker &> /dev/null; then
log_error "docker is required but not found"
exit 1
fi

if ! command -v bosh &> /dev/null; then
log_error "bosh CLI is required but not found"
exit 1
fi

if [[ ! -d "$RELEASE_DIR" ]]; then
log_error "Release directory not found: $RELEASE_DIR"
log_info "Clone it with: git clone --recurse-submodules https://github.com/rkoster/garden-runc-release -b noble-nested-warden"
exit 1
fi
}

# Create source release tarball
create_source_release() {
local release_tarball

log_info "Creating source release tarball from $RELEASE_DIR..."
cd "$RELEASE_DIR"

# Get release name and version info
local release_name
release_name=$(grep '^name:' config/final.yml 2>/dev/null | awk '{print $2}' || echo "garden-runc")

local commit_hash
commit_hash=$(git rev-parse --short HEAD)

# Create dev release with a predictable version
local version="0+dev.${commit_hash}"
release_tarball="${RELEASE_DIR}/dev_releases/${release_name}/${release_name}-${version}.tgz"

# Check if we already have a recent dev release
if [[ -f "$release_tarball" ]]; then
log_info "Using existing dev release: $release_tarball"
else
log_info "Creating dev release (version: ${version})..."
bosh create-release --force --tarball="${release_tarball}" --version="${version}"
fi

echo "$release_tarball"
}

# Compile release using Docker and bosh-agent compile
compile_release() {
local source_tarball="$1"
local source_filename
source_filename=$(basename "$source_tarball")

log_info "Compiling release using Docker..."
log_info " Stemcell image: $STEMCELL_IMAGE"
log_info " Source tarball: $source_tarball"
log_info " Output dir: $OUTPUT_DIR"

# Create output directory
mkdir -p "$OUTPUT_DIR"

# Create a temporary directory for the compilation
local work_dir
work_dir=$(mktemp -d)
trap "rm -rf '$work_dir'" EXIT

# Copy source tarball to work directory
cp "$source_tarball" "${work_dir}/${source_filename}"

# Pull the stemcell image (if not already cached)
log_info "Pulling stemcell image (if needed)..."
if ! docker pull "$STEMCELL_IMAGE"; then
log_error "Failed to pull stemcell image: $STEMCELL_IMAGE"
log_info "Available Noble stemcell images:"
log_info " ghcr.io/cloudfoundry/ubuntu-noble-stemcell:latest"
log_info " ghcr.io/cloudfoundry/ubuntu-jammy-stemcell:latest"
exit 1
fi

# Run bosh-agent compile in Docker
# The bosh-agent binary is at /var/vcap/bosh/bin/bosh-agent in the stemcell image
log_info "Running bosh-agent compile..."
docker run --rm \
--privileged \
--security-opt seccomp=unconfined \
--security-opt apparmor=unconfined \
-v "${work_dir}:/releases" \
"$STEMCELL_IMAGE" \
/var/vcap/bosh/bin/bosh-agent compile \
--output-directory=/releases \
"/releases/${source_filename}"

# Find the compiled release
local compiled_tarball
compiled_tarball=$(find "$work_dir" -name "*.tgz" ! -name "$source_filename" -type f | head -1)

if [[ -z "$compiled_tarball" ]]; then
log_error "No compiled release found in $work_dir"
ls -la "$work_dir"
exit 1
fi

local compiled_filename
compiled_filename=$(basename "$compiled_tarball")

# Move compiled release to output directory
mv "$compiled_tarball" "${OUTPUT_DIR}/${compiled_filename}"

log_info "Compiled release created: ${OUTPUT_DIR}/${compiled_filename}"
echo "${OUTPUT_DIR}/${compiled_filename}"
}

# Verify the compiled release
verify_release() {
local compiled_tarball="$1"

log_info "Verifying compiled release..."

# Check that it contains compiled_packages
if tar -tzf "$compiled_tarball" 2>/dev/null | grep -q "compiled_packages/"; then
log_info " Release contains compiled packages"
else
log_error " Release does not contain compiled packages!"
exit 1
fi

# List the compiled packages
log_info "Compiled packages:"
tar -tzf "$compiled_tarball" 2>/dev/null | grep "compiled_packages/" | head -20 | while read -r pkg; do
echo " $pkg"
done
}

# Main
main() {
log_info "Garden-runc Release Compiler"
log_info "============================"
log_info ""

check_prerequisites

# Create source release
local source_tarball
source_tarball=$(create_source_release)

# Compile
local compiled_tarball
compiled_tarball=$(compile_release "$source_tarball")

# Verify
verify_release "$compiled_tarball"

log_info ""
log_info "Success! Compiled release is at:"
log_info " $compiled_tarball"
log_info ""
log_info "Use this tarball with the gardeninstaller package:"
log_info " export GARDEN_RELEASE_TARBALL=$compiled_tarball"
log_info " go test ./integration/garden/..."
}

main "$@"
7 changes: 6 additions & 1 deletion ci/tasks/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ pushd "${bosh_agent_dir}"
popd

echo -e "\n Installing agent..."
${ssh_command} "sudo sv stop agent" >/dev/null 2>&1
# Stop agent using appropriate service manager (systemd for Noble, runit for Jammy)
if ${ssh_command} "grep -qi noble /etc/lsb-release" 2>/dev/null; then
${ssh_command} "sudo systemctl stop bosh-agent" >/dev/null 2>&1 || true
else
${ssh_command} "sudo sv stop agent" >/dev/null 2>&1 || true
fi
copy_to_remote_host "${bosh_agent_dir}/out/bosh-agent" /var/vcap/bosh/bin/bosh-agent

echo -e "\n Shutting down rsyslog..."
Expand Down
Loading