Skip to content
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
116 changes: 112 additions & 4 deletions .github/workflows/e2e-test-event-writer.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
name: Build E2E Test Event Writer
on:
pull_request:
push:
branches:
branches:
- main
- dev/**
- "dev/**"
merge_group:
types: [checks_requested]
workflow_dispatch:


permissions:
contents: read
id-token: write
packages: write

env:
EVENT_WRITER_PATH: "${{ github.workspace }}/test/e2e/tools/event-writer/"
EBPF_VERSION: "1.1.0"
XDP_SDK_VERSION: "1.3.0"

jobs:
retina-win-e2e-bpf-images:
name: Build E2E Test Event Writer
runs-on: windows-2022
timeout-minutes: 30

env:
IS_MERGE_GROUP: ${{ (github.event_name == 'merge_group') || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/dev/v0.0.33-windows' && github.repository == 'microsoft/retina') }}
Expand All @@ -32,4 +35,109 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
uses: actions/checkout@v4.2.2

- name: Azure Login
uses: azure/login@v2
if: ${{ env.IS_MERGE_GROUP == 'true' }}
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}

- name: Ensure Docker daemon is running
shell: pwsh
run: |
$timeout = 120
$timer = [Diagnostics.Stopwatch]::StartNew()
while ($timer.Elapsed.TotalSeconds -lt $timeout) {
$svc = Get-Service docker -ErrorAction SilentlyContinue
if ($svc -and $svc.Status -ne 'Running') {
Start-Service docker -ErrorAction SilentlyContinue
}
$result = docker info 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "Docker daemon is ready"
return
}
Write-Host "Waiting for Docker daemon to start..."
Start-Sleep -Seconds 5
}
throw "Docker daemon failed to start within $timeout seconds"

- name: Docker Login to ghcr.io
uses: docker/login-action@v3
if: ${{ env.IS_MERGE_GROUP != 'true' }}
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set MSBuild path
run: |
echo "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Install LLVM 18.1.8
shell: pwsh
run: |
# Install LLVM 18.1.8 to ensure consistent version across runners
try {
choco install llvm --version=18.1.8 --allow-downgrade -y --force
# Add installed LLVM to PATH first so it takes precedence
echo "C:\Program Files\LLVM\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Write-Host "Successfully installed LLVM 18.1.8"
} catch {
Write-Warning "Failed to install LLVM 18.1.8 via chocolatey: $($_.Exception.Message)"
Write-Host "Continuing with pre-installed LLVM version"
}

- name: Nuget Restore
shell: cmd
run: |
nuget restore .\event_writer.sln
working-directory: ${{ env.EVENT_WRITER_PATH }}

- name: Configure eBPF store
shell: cmd
run: |
.\export_program_info.exe --clear
.\export_program_info.exe
working-directory: ${{ env.EVENT_WRITER_PATH }}\packages\eBPF-for-Windows.x64.${{ env.EBPF_VERSION }}\build\native\bin

- name: Build Event-Writer
shell: cmd
run: |
msbuild /m /t:Clean /p:Configuration=Release /p:Platform=x64 /restore event_writer.sln
msbuild /m /p:Configuration=Release /p:Platform=x64 /restore /v:detailed event_writer.sln
working-directory: ${{ env.EVENT_WRITER_PATH }}

- name: Determine Docker tag
id: tag
shell: pwsh
run: |
$TAG = $(git tag --points-at HEAD)
if (-not $TAG) {
$TAG = $(git rev-parse --short HEAD)
}
echo "tag=$TAG" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append

- name: Build and push images
shell: pwsh
working-directory: ${{ env.EVENT_WRITER_PATH }}
run: |
$isMergeGroup = "${{ env.IS_MERGE_GROUP }}" -eq "true"
if (-not $isMergeGroup) {
$image = "ghcr.io/${{ github.repository }}/test/e2e-test-event-writer".ToLower()
} else {
$image = "${{ vars.ACR_NAME }}/${{ github.repository }}/test/e2e-test-event-writer".ToLower()
}

$tag = "${{ steps.tag.outputs.tag }}"
docker build -f "./Dockerfile" -t "${image}:${tag}" -t "${image}:latest" .

if ("${{ github.event_name }}" -ne "pull_request") {
docker push "${image}:${tag}"
docker push "${image}:latest"
} else {
Write-Host "Skipping image push for pull_request runs"
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ data:
metricsInterval: {{ .Values.metricsInterval }}
metricsIntervalDuration: {{ .Values.metricsIntervalDuration }}
enableTelemetry: {{ .Values.enableTelemetry }}
enablePodLevel: {{ .Values.enablePodLevel }}
enablePodLevel: {{ .Values.enablePodLevel_win }}
remoteContext: {{ .Values.remoteContext }}
enableAnnotations: {{ .Values.enableAnnotations }}
telemetryInterval: {{ .Values.daemonset.telemetryInterval }}
{{- end}}



Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ image:
enableConntrackMetrics: false
conntrackReportInterval: 30s
enablePodLevel: false
enablePodLevel_win: true
remoteContext: false
enableAnnotations: false
enableAnnotations: true
bypassLookupIPOfInterest: false
dataAggregationLevel: "low"
dataSamplingRate: 1
Expand Down Expand Up @@ -96,7 +97,7 @@ apiServer:
logLevel: debug

enabledPlugin_linux: '["dropreason","packetforward","linuxutil","dns"]'
enabledPlugin_win: '["hnsstats"]'
enabledPlugin_win: '["hnsstats", "ebpfwindows"]'

enableTelemetry: false

Expand Down Expand Up @@ -312,7 +313,7 @@ metrics:
tlsConfig: {}
## @param metrics.serviceMonitor.relabelings [array] Prometheus relabeling rules to apply to samples before scraping
##
relabelings:
relabelings:
- sourceLabels:
[__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
separator: ":"
Expand Down
43 changes: 43 additions & 0 deletions pkg/plugin/common/common_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

// package common contains common functions and types used by all Retina Windows plugins.
package common

import (
"errors"
"fmt"

"golang.org/x/sys/windows/registry"
)

const (
// KeyPath is the registry key path where the CiliumOnWindows value is stored.
// This key is used to determine if Cilium is enabled on Windows.
KeyPath = `SYSTEM\CurrentControlSet\Services\hns\State`
// CiliumOnWindows is the registry value name that indicates if Cilium is enabled on Windows.
// If this value is set to 1, Cilium is enabled on Windows. If this value is not set or set to 0, Cilium is not enabled.
ValueName = "CiliumOnWindows"
)

// IsCiliumOnWindowsEnabled checks if the CiliumOnWindows registry value is set to 1.
// Returns (true, nil) if set to 1, (false, nil) if not set or not exist, (false, err) for other errors.
func IsCiliumOnWindowsEnabled() (bool, error) {
k, err := registry.OpenKey(registry.LOCAL_MACHINE, KeyPath, registry.QUERY_VALUE)
if err != nil {
if errors.Is(err, registry.ErrNotExist) {
return false, nil
}
return false, fmt.Errorf("opening registry key: %w", err)
}
defer k.Close()

val, _, err := k.GetIntegerValue(ValueName)
if err != nil {
if errors.Is(err, registry.ErrNotExist) {
return false, nil
}
return false, fmt.Errorf("reading registry value: %w", err)
}
return val == 1, nil
}
Loading
Loading