Skip to content

Commit

Permalink
Merge branch 'unvariance:main' into feature/unvariance#9-resctrl_supp…
Browse files Browse the repository at this point in the history
…ort_checker
  • Loading branch information
darshan-dedhia authored Feb 25, 2025
2 parents 87b40e7 + 9807fc9 commit f1a3b44
Show file tree
Hide file tree
Showing 63 changed files with 7,177 additions and 564 deletions.
3 changes: 2 additions & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"ms-vscode.cpptools",
"ms-vscode.makefile-tools",
"ms-azuretools.vscode-docker",
"ms-vscode.cmake-tools"
"ms-vscode.cmake-tools",
"golang.go"
]
}
},
Expand Down
33 changes: 0 additions & 33 deletions .github/workflows/Prometheus Integration Test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci-cpi-count.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}
context: cmd/cpi-count
context: .
file: cmd/cpi-count/Dockerfile
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/cpi-count:cache # Need to add the repository name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: CI Collector Workflow
run-name: Building Collector by @${{ github.actor }}
name: CI Prometheus Metrics Workflow
run-name: Building Prometheus Metrics by @${{ github.actor }}

on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'cmd/collector/**'
- 'cmd/prometheus_metrics/**'
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -33,7 +33,7 @@ jobs:
id: docker-metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/collector
images: ghcr.io/${{ github.repository }}/prometheus-metrics
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}
Expand All @@ -44,9 +44,8 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker-metadata.outputs.tags }}
labels: ${{ steps.docker-metadata.outputs.labels }}
context: cmd/collector
file: cmd/collector/Dockerfile
context: .
file: cmd/prometheus_metrics/Dockerfile
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/collector:cache
cache-to: type=registry,image-manifest=true,oci-mediatypes=true,ref=ghcr.io/${{ github.repository }}/collector:cache,mode=max

cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/prometheus-metrics:cache
cache-to: type=registry,image-manifest=true,oci-mediatypes=true,ref=ghcr.io/${{ github.repository }}/prometheus-metrics:cache,mode=max
27 changes: 27 additions & 0 deletions .github/workflows/prometheus-metrics-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Prometheus Metrics Integration Test

on:
push:
branches: [ "main" ]
paths:
- cmd/prometheus_metrics/**
pull_request:
branches: [ "main" ]
paths:
- cmd/prometheus_metrics/**

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.9'

- name: Test
working-directory: ./cmd/prometheus_metrics/
run: go test -v
200 changes: 200 additions & 0 deletions .github/workflows/test-ebpf-collector.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: Test eBPF Collector
on:
workflow_dispatch: # Manual trigger for testing
inputs:
instance-type:
description: 'EC2 instance type to use'
required: false
default: 'c5.9xlarge'
type: string
push:
branches:
- main
paths:
- cmd/collector/**
- .github/workflows/test-ebpf-collector.yaml

permissions:
id-token: write # Required for requesting the JWT

jobs:
start-runner:
name: Start EC2 runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: github-runner-session

- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/[email protected]
with:
mode: start
github-token: ${{ secrets.REPO_ADMIN_TOKEN }}
ec2-image-id: ami-0cb91c7de36eed2cb # Ubuntu 24.04 LTS in us-east-2
ec2-instance-type: ${{ inputs.instance-type || 'm5zn.6xlarge' }} # or c5.9xlarge
market-type: spot
subnet-id: ${{ secrets.AWS_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_SECURITY_GROUP_ID }}
aws-resource-tags: >
[
{"Key": "Name", "Value": "github-runner"},
{"Key": "Repository", "Value": "${{ github.repository }}"},
{"Key": "Workflow", "Value": "${{ github.workflow }}"},
{"Key": "RunId", "Value": "${{ github.run_id }}"},
{"Key": "RunNumber", "Value": "${{ github.run_number }}"},
{"Key": "SHA", "Value": "${{ github.sha }}"},
{"Key": "Branch", "Value": "${{ github.ref_name }}"},
{"Key": "Actor", "Value": "${{ github.actor }}"}
]
test-ebpf:
needs: start-runner
runs-on: ${{ needs.start-runner.outputs.label }}
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Disable IPv6
run: |
# Disable IPv6 via sysctl
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
# Force apt to use IPv4
echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4
- name: Install dependencies
run: |
# Update all archive URLs to use HTTPS in both old and new locations
sudo find /etc/apt/sources.list /etc/apt/sources.list.d/ -type f -exec sed -i 's/http:/https:/g' {} +
sudo apt-get update
sudo apt-get install -y build-essential linux-headers-$(uname -r) \
golang-go llvm clang libbpf-dev git vim curl kmod unzip
- name: Install pqrs
run: |
# Download latest pqrs release
curl -L -o pqrs.zip https://github.com/manojkarthick/pqrs/releases/download/v0.3.2/pqrs-0.3.2-x86_64-unknown-linux-gnu.zip
unzip pqrs.zip
sudo mv pqrs-0.3.2-x86_64-unknown-linux-gnu/bin/pqrs /usr/local/bin/
rm pqrs.zip
- name: Build kernel module
working-directory: module
run: |
# Try to compile and capture the warning message
make 2>&1 | tee compile_output.txt || true
# Extract gcc version from the warning message
KERNEL_GCC_VERSION=$(grep "The kernel was built by:" compile_output.txt | grep -oP 'gcc-\K\d+' || echo "")
echo "Detected kernel compiler version: ${KERNEL_GCC_VERSION}"
# Install specific gcc version if detected
if [ ! -z "$KERNEL_GCC_VERSION" ]; then
echo "Installing gcc-${KERNEL_GCC_VERSION}"
sudo apt-get install -y gcc-${KERNEL_GCC_VERSION}
# Configure as default gcc
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${KERNEL_GCC_VERSION} 100
sudo update-alternatives --set gcc /usr/bin/gcc-${KERNEL_GCC_VERSION}
else
echo "Warning: Could not detect kernel compiler version"
fi
# Verify gcc version
gcc --version
# Now try the actual build
make
ls -l build/collector.ko
- name: Build collector
working-directory: cmd/collector
run: |
export HOME=/tmp
echo "HOME: $HOME"
export GOCACHE=$HOME/golang/pkg/mod
echo "GOCACHE: $GOCACHE"
mkdir -p $GOCACHE
go env -w GOMODCACHE=$GOCACHE
# Set up asm link for go2bpf
arch=$(uname -m) && \
case ${arch} in \
aarch64) ln -sf /usr/include/aarch64-linux-gnu/asm /usr/include/asm ;; \
x86_64) ln -sf /usr/include/x86_64-linux-gnu/asm /usr/include/asm ;; \
*) echo "Unsupported architecture: ${arch}" && exit 1 ;; \
esac
go generate
go build -v
ls -l collector
- name: Load kernel module
working-directory: module
run: |
sudo insmod build/collector.ko
lsmod | grep collector
- name: Run eBPF collector
working-directory: cmd/collector
run: |
sudo ./collector
- name: Upload parquet file
uses: actions/upload-artifact@v4
with:
name: metrics-parquet
path: cmd/collector/metrics.parquet
if-no-files-found: error

- name: Verify parquet output
working-directory: cmd/collector
run: |
# Print parquet file contents as CSV
echo "Parquet file contents:"
pqrs cat --csv metrics.parquet
# Verify file exists and has content
if [ ! -s metrics.parquet ]; then
echo "Error: metrics.parquet is empty or does not exist"
exit 1
fi
- name: Unload kernel module
working-directory: module
run: |
sudo rmmod collector
! lsmod | grep collector
stop-runner:
name: Stop EC2 runner
needs: [start-runner, test-ebpf]
runs-on: ubuntu-latest
if: always()
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: github-runner-session

- name: Stop EC2 runner
uses: machulav/[email protected]
with:
mode: stop
github-token: ${{ secrets.REPO_ADMIN_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
Loading

0 comments on commit f1a3b44

Please sign in to comment.