Skip to content

Commit

Permalink
Merge master into branch
Browse files Browse the repository at this point in the history
  • Loading branch information
BeegiiK committed Dec 23, 2024
2 parents f4d9f66 + e9ac2e5 commit 853c0e7
Show file tree
Hide file tree
Showing 134 changed files with 2,587 additions and 1,014 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
if: env.IS_NOT_MERGE_GROUP
uses: golangci/golangci-lint-action@v6
with:
version: v1.55
version: v1.62
args: --concurrency 4 --verbose --config=.golangci.yaml --timeout=25m
only-new-issues: true
skip-cache: true
34 changes: 34 additions & 0 deletions .github/workflows/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,37 @@ jobs:
run: |
set -euo pipefail
go test -v ./test/e2e/. -timeout 60m -tags=e2e -count=1 -args -image-tag=$(make version) -image-registry=${{ vars.ACR_NAME }} -image-namespace=${{ github.repository}}
perf:
if: ${{ github.event_name == 'merge_group' && success('manifests')}}
name: Retina Performance Test
runs-on: ubuntu-latest
needs: [manifests]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: go version

- name: Az CLI login
uses: azure/login@v2
if: ${{ github.event_name == 'merge_group' }}
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION }}

- name: Run Perf Tests
env:
AZURE_APP_INSIGHTS_KEY: ${{ secrets.AZURE_APP_INSIGHTS_KEY }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION }}
AZURE_LOCATION: ${{ vars.AZURE_LOCATION }}
shell: bash
run: |
set -euo pipefail
go test -v ./test/e2e/. -timeout 2h -tags=perf -count=1 -args -image-tag=$(make version) -image-registry=${{ vars.ACR_NAME }} -image-namespace=${{ github.repository }}
13 changes: 3 additions & 10 deletions .github/workflows/perf.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: Network Performance Measurement

on:
workflow_run:
workflows: [Build Images]
types:
- completed
schedule:
# It runs on 17th minute of every 12 hours
- cron: '17 */12 * * *'
Expand All @@ -20,7 +16,6 @@ permissions:

jobs:
perf_test:
if: ${{ github.event != 'workflow_run' || github.event_name == 'merge_group' }}
name: Retina Performance Test
runs-on: ubuntu-latest

Expand Down Expand Up @@ -49,11 +44,9 @@ jobs:
shell: bash
run: |
set -euo pipefail
if [ "${{ github.event }}" == "workflow_dispatch" ]; then
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
TAG=${{ github.event.inputs.tag }}
elif [ "${{ github.event_name }}" == "merge_group" ]; then
TAG=$(make version)
else
TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
fi
go test -v ./test/e2e/. -timeout 2h -tags=perf -count=1 -args -image-tag=$TAG -image-registry=${{ vars.ACR_NAME }} -image-namespace=${{ github.repository }}
go test -v ./test/e2e/. -timeout 2h -tags=perf -count=1 -args -image-tag=$TAG -image-registry=ghcr.io -image-namespace=${{ github.repository }}
58 changes: 16 additions & 42 deletions .github/workflows/scale-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ on:
required: true
type: string
cluster_name:
description: "AKS Cluster Name"
description: "AKS Cluster Name (nodes to receive traffic pods should be labeled with scale-test=true)"
required: true
type: string
location:
description: "Azure Location"
image_namespace:
description: "Image Namespace (if not set, default namespace will be used)"
type: string
image_tag:
description: "Image Tag (if not set, default for this commit will be used)"
type: string
default: ${{ vars.AZURE_LOCATION }}
num_deployments:
description: "Number of Traffic Deployments"
default: 1000
Expand All @@ -27,20 +29,8 @@ on:
description: "Number of Network Policies"
default: 1000
type: number
num_unique_labels_per_pod:
description: "Number of Unique Labels per Pod"
default: 2
type: number
num_unique_labels_per_deployment:
description: "Number of Unique Labels per Deployment"
default: 2
type: number
num_shared_labels_per_pod:
description: "Number of Shared Labels per Pod"
default: 3
type: number
delete_labels:
description: "Delete Labels"
cleanup:
description: "Clean up environment after test"
default: true
type: boolean

Expand All @@ -54,10 +44,6 @@ on:
description: "AKS Cluster Name"
required: true
type: string
location:
description: "Azure Location"
type: string
default: ${{ vars.AZURE_LOCATION }}
num_deployments:
description: "Number of Traffic Deployments"
default: 1000
Expand All @@ -70,20 +56,8 @@ on:
description: "Number of Network Policies"
default: 1000
type: number
num_unique_labels_per_pod:
description: "Number of Unique Labels per Pod"
default: 2
type: number
num_unique_labels_per_deployment:
description: "Number of Unique Labels per Deployment"
default: 2
type: number
num_shared_labels_per_pod:
description: "Number of Shared Labels per Pod"
default: 3
type: number
delete_labels:
description: "Delete Labels"
cleanup:
description: "Clean up environment after test"
default: true
type: boolean

Expand Down Expand Up @@ -116,17 +90,17 @@ jobs:
- name: Run Scale Test
env:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION }}
AZURE_LOCATION: ${{ input.location }}
AZURE_RESOURCE_GROUP: ${{ inputs.resource_group }}
CLUSTER_NAME: ${{ inputs.cluster_name }}
NUM_DEPLOYMENTS: ${{ inputs.num_deployments }}
NUM_REPLICAS: ${{ inputs.num_replicas }}
NUM_NETPOLS: ${{ inputs.num_netpol }}
NUM_UNIQUE_LABELS_PER_POD: ${{ inputs.num_unique_labels_per_pod }}
NUM_SHARED_LABELS_PER_POD: ${{ inputs.num_shared_labels_per_pod }}
NUM_UNIQUE_LABELS_PER_DEPLOYMENT: ${{ inputs.num_unique_labels_per_deployment }}
DELETE_LABELS: ${{ inputs.delete_labels }}
CLEANUP: ${{ inputs.cleanup }}
IMAGE_REGISTRY: ${{ inputs.image_namespace == '' && vars.ACR_NAME || inputs.image_namespace }}
IMAGE_NAMESPACE: ${{ github.repository }}
TAG: ${{ inputs.image_tag }}
AZURE_APP_INSIGHTS_KEY: ${{ secrets.AZURE_APP_INSIGHTS_KEY }}
shell: bash
run: |
set -euo pipefail
go test -v ./test/e2e/. -timeout 300m -tags=scale -count=1 -args -image-tag=$(make version) -image-registry=${{vars.ACR_NAME}} -image-namespace=${{github.repository}}
go test -v ./test/e2e/. -timeout 300m -tags=scale -count=1 -args -image-tag=$( [[ $TAG == "" ]] && make version || echo $TAG ) -create-infra=false -delete-infra=false
64 changes: 64 additions & 0 deletions .github/workflows/update-hubble.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Update Hubble

on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
update-hubble:
name: Update Hubble to latest version
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Get latest Hubble version
id: get_version
run: |
latest_version=$(curl -s https://api.github.com/repos/cilium/hubble/releases/latest | jq -r .tag_name)
echo "Latest Hubble version: $latest_version"
echo "version=$latest_version" >> $GITHUB_ENV
- name: Get current Hubble version from Dockerfile
id: get_current_version
run: |
current_version=$(grep -oP '(?<=ARG HUBBLE_VERSION=).*' controller/Dockerfile)
echo "Current Hubble version: $current_version"
echo "current_version=$current_version" >> $GITHUB_ENV
- name: Check if update is needed
id: check_update
run: |
if [ "${{ env.version }}" == "${{ env.current_version }}" ]; then
echo "Hubble version is up to date. No update needed."
echo "update_needed=false" >> $GITHUB_ENV
else
echo "Hubble version needs to be updated."
echo "update_needed=true" >> $GITHUB_ENV
fi
- name: Update Dockerfile and Makefile with latest Hubble version
if: env.update_needed == 'true'
run: |
sed -i "s/^ARG HUBBLE_VERSION=.*/ARG HUBBLE_VERSION=${{ env.version }}/" controller/Dockerfile
sed -i "s/^HUBBLE_VERSION ?=.*/HUBBLE_VERSION ?= ${{ env.version }}/" Makefile
- name: Create pull request
if: env.update_needed == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: deps/update-hubble-to-${{ env.version }}
title: "deps: bump Hubble version from ${{ env.current_version }} to ${{ env.version }}"
body: "This PR bumps the Hubble version from ${{ env.current_version }} to ${{ env.version }}."
commit-message: "deps: bump Hubble version from ${{ env.current_version }} to ${{ env.version }}"
labels: "area/dependencies"
sign-commits: true
signoff: true
delete-branch: true
6 changes: 3 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ issues:
- path: pkg/metrics/types_windows.go
linters:
- revive
- gomnd
- mnd
- var-naming
- path: pkg/metrics/types_linux.go
linters:
- revive
- gomnd
- mnd
- var-naming
linters:
presets:
Expand All @@ -31,7 +31,7 @@ linters:
- gocritic
- gocyclo
- gofmt
- gomnd
- mnd
- goprintffuncname
- gosimple
- lll
Expand Down
4 changes: 2 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 1
version: 2

before:
hooks:
Expand All @@ -22,7 +22,7 @@ builds:
- windows
- darwin
ldflags:
- -X github.com/microsoft/retina/cli/cmd.Version=v{{.Version}}
- -X github.com/microsoft/retina/internal/buildinfo.Version=v{{.Version}}
main: cli/main.go

archives:
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PLATFORM ?= $(OS)/$(ARCH)
PLATFORMS ?= linux/amd64 linux/arm64 windows/amd64
OS_VERSION ?= ltsc2019

HUBBLE_VERSION ?= v1.16.3
HUBBLE_VERSION ?= v1.16.3 # This may be modified via the update-hubble GitHub Action

CONTAINER_BUILDER ?= docker
CONTAINER_RUNTIME ?= docker
Expand Down Expand Up @@ -341,6 +341,9 @@ kapinger-image:
$(IMAGE_REGISTRY)/$(KAPINGER_IMAGE):$(TAG)-linux-amd64 \
$(IMAGE_REGISTRY)/$(KAPINGER_IMAGE):$(TAG)-linux-arm64

toolbox:
docker buildx build --builder retina --platform linux/amd64 -t $(IMAGE_REGISTRY)/toolbox:$(TAG) -f ./hack/tools/toolbox/Dockerfile ./hack/tools/ --push

proto-gen: ## generate protobuf code
docker build --platform=linux/amd64 \
-t $(IMAGE_REGISTRY)/$(RETINA_PROTO_IMAGE):$(RETINA_PLATFORM_TAG) \
Expand Down
4 changes: 2 additions & 2 deletions cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# mcr.microsoft.com/oss/go/microsoft/golang:1.23.1-cbl-mariner2.0
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:8ac5373de7fde69d08c52e4a1ba40e976a543b3e93196f7fe07c3f91853865f3 AS builder
# mcr.microsoft.com/oss/go/microsoft/golang:1.23.4-cbl-mariner2.0
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:88225e171f29fe5f1f6ffca8eb659535b19b253354e43e1f4fc8a9bc67615ca1 AS builder


ARG VERSION
Expand Down
13 changes: 9 additions & 4 deletions cli/cmd/capture/capture.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import (
"k8s.io/cli-runtime/pkg/genericclioptions"
)

var name string
var opts = struct {
genericclioptions.ConfigFlags
Name *string
}{
Name: new(string),
}

const defaultName = "retina-capture"

Expand All @@ -20,7 +25,7 @@ var capture = &cobra.Command{

func init() {
cmd.Retina.AddCommand(capture)
configFlags = genericclioptions.NewConfigFlags(true)
configFlags.AddFlags(capture.PersistentFlags())
capture.PersistentFlags().StringVar(&name, "name", defaultName, "The name of the Retina Capture")
opts.ConfigFlags = *genericclioptions.NewConfigFlags(true)
opts.AddFlags(capture.PersistentFlags())
capture.PersistentFlags().StringVar(opts.Name, "name", defaultName, "The name of the Retina Capture")
}
Loading

0 comments on commit 853c0e7

Please sign in to comment.