Skip to content

Commit

Permalink
Merge branch 'master' into header-based-traffic-alb
Browse files Browse the repository at this point in the history
  • Loading branch information
perenesenko committed Jul 28, 2022
2 parents 8962a07 + 3329626 commit bd971dd
Show file tree
Hide file tree
Showing 69 changed files with 1,941 additions and 1,161 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
with:
config-inline: |
[worker.oci]
Expand Down Expand Up @@ -79,14 +79,14 @@ jobs:
echo "::set-output name=platform-matrix::$PLATFORM_MATRIX"
- name: Build and push (controller-image)
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
platforms: ${{ steps.platform-matrix.outputs.platform-matrix }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.controller-meta.outputs.tags }}

- name: Build and push (plugin-image)
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
target: kubectl-argo-rollouts
platforms: ${{ steps.platform-matrix.outputs.platform-matrix }}
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/e2e-test-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test Results

on:
workflow_run:
workflows: ["E2E Tests", "Go"]
types:
- completed
permissions: {}

jobs:
test-results:
name: "${{ github.event.workflow.name }} Test Results"
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion != 'skipped'
permissions:
checks: write
pull-requests: write
actions: read
steps:
- name: Download and Extract Artifacts
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
mkdir -p artifacts && cd artifacts
artifacts_url=${{ github.event.workflow_run.artifacts_url }}
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
do
IFS=$'\t' read name url <<< "$artifact"
gh api $url > "$name.zip"
unzip -d "$name" "$name.zip"
done
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
check_name: "${{ github.event.workflow.name }} Published Test Results"
commit: ${{ github.event.workflow_run.head_sha }}
event_file: artifacts/Event File/event.json
event_name: ${{ github.event.workflow_run.event }}
files: "artifacts/**/*.xml"
compare_to_earlier_commit: false
test_changes_limit: 0
fail_on: "errors"
21 changes: 20 additions & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,23 @@ concurrency:
cancel-in-progress: true

jobs:
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v2
with:
name: Event File
path: ${{ github.event_path }}
test-e2e:
name: Run end-to-end tests
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18
- uses: actions/checkout@v2
- name: Setup k3s
run: |
Expand Down Expand Up @@ -58,6 +67,16 @@ jobs:
- name: Run e2e tests
run: make test-e2e
if: ${{ !(github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled) }}
- name: Output Rerun Overview
run: |
[[ -f rerunreport.txt ]] && cat rerunreport.txt || echo "No rerun report found"
- name: Upload E2E Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: E2E Test Results
path: |
junit.xml
- name: Upload e2e-controller logs
uses: actions/upload-artifact@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18
- name: build
run: |
pip install mkdocs mkdocs_material
Expand Down
23 changes: 20 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ on:
- "master"
env:
# Golang version to use across CI steps
GOLANG_VERSION: '1.17'
GOLANG_VERSION: '1.18'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
event_file:
name: "Event File"
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v2
with:
name: Event File
path: ${{ github.event_path }}
lint-go:
name: Lint Go code
runs-on: ubuntu-latest
Expand All @@ -29,7 +38,7 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2
version: v1.47.2
args: --timeout 5m
build:
name: Build
Expand Down Expand Up @@ -58,7 +67,15 @@ jobs:
run: make controller plugin

- name: Test
run: go test -failfast -covermode=count -coverprofile=coverage.out ./...
run: make test-unit

- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Results
path: |
junit.xml
- name: Generate code coverage artifacts
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.18

- name: Generate release artifacts
run: |
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Initial stage which pulls prepares build dependencies and CLI tooling we need for our final image
# Also used as the image in CI jobs so needs all dependencies
####################################################################################################
FROM --platform=$BUILDPLATFORM golang:1.17 as builder
FROM --platform=$BUILDPLATFORM golang:1.18 as builder

RUN apt-get update && apt-get install -y \
wget \
Expand All @@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install golangci-lint
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.0 && \
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.47.2 && \
golangci-lint linters

COPY .golangci.yml ${GOPATH}/src/dummy/.golangci.yml
Expand Down Expand Up @@ -40,7 +40,7 @@ RUN NODE_ENV='production' yarn build
####################################################################################################
# Rollout Controller Build stage which performs the actual build of argo-rollouts binaries
####################################################################################################
FROM --platform=$BUILDPLATFORM golang:1.17 as argo-rollouts-build
FROM --platform=$BUILDPLATFORM golang:1.18 as argo-rollouts-build

WORKDIR /go/src/github.com/argoproj/argo-rollouts

Expand Down
17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DEV_IMAGE=false
# E2E variables
E2E_INSTANCE_ID ?= argo-rollouts-e2e
E2E_TEST_OPTIONS ?=
E2E_PARALLEL ?= 4
E2E_PARALLEL ?= 1
E2E_WAIT_TIMEOUT ?= 120

override LDFLAGS += \
Expand Down Expand Up @@ -79,9 +79,13 @@ install-go-tools-local: go-mod-vendor
install-protoc-local:
./hack/installers/install-protoc.sh

.PHONY: install-devtools-local
install-devtools-local:
./hack/installers/install-dev-tools.sh

# Installs all tools required to build and test locally
.PHONY: install-tools-local
install-tools-local: install-go-tools-local install-protoc-local
install-tools-local: install-go-tools-local install-protoc-local install-devtools-local

TYPES := $(shell find pkg/apis/rollouts/v1alpha1 -type f -name '*.go' -not -name openapi_generated.go -not -name '*generated*' -not -name '*test.go')
APIMACHINERY_PKGS=k8s.io/apimachinery/pkg/util/intstr,+k8s.io/apimachinery/pkg/api/resource,+k8s.io/apimachinery/pkg/runtime/schema,+k8s.io/apimachinery/pkg/runtime,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/api/core/v1,k8s.io/api/batch/v1
Expand Down Expand Up @@ -212,8 +216,13 @@ start-e2e:
go run ./cmd/rollouts-controller/main.go --instance-id ${E2E_INSTANCE_ID} --loglevel debug --kloglevel 6

.PHONY: test-e2e
test-e2e:
go test -timeout 30m -v -count 1 --tags e2e -p ${E2E_PARALLEL} --short ./test/e2e ${E2E_TEST_OPTIONS}
test-e2e: install-devtools-local
${DIST_DIR}/gotestsum --rerun-fails-report=rerunreport.txt --junitfile=junit.xml --format=testname --packages="./test/e2e" --rerun-fails=5 -- -timeout 60m -count 1 --tags e2e -p ${E2E_PARALLEL} -parallel ${E2E_PARALLEL} -v --short ./test/e2e ${E2E_TEST_OPTIONS}

.PHONY: test-unit
test-unit: install-devtools-local
${DIST_DIR}/gotestsum --junitfile=junit.xml --format=testname --packages="./..." -- -covermode=count -coverprofile=coverage.out ./...


.PHONY: coverage
coverage: test
Expand Down
8 changes: 4 additions & 4 deletions analysis/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ func TestAssessRunStatusErrorMessageAnalysisPhaseFail(t *testing.T) {

func TestAssessRunStatusErrorMessageAnalysisPhaseFailInDryRunMode(t *testing.T) {
status, message, dryRunSummary := StartAssessRunStatusErrorMessageAnalysisPhaseFail(t, true)
assert.Equal(t, v1alpha1.AnalysisPhaseSuccessful, status)
assert.Equal(t, v1alpha1.AnalysisPhaseRunning, status)
assert.Equal(t, "", message)
expectedDryRunSummary := v1alpha1.RunSummary{
Count: 2,
Expand Down Expand Up @@ -1545,7 +1545,7 @@ func TestAssessRunStatusErrorMessageFromProvider(t *testing.T) {
func TestAssessRunStatusErrorMessageFromProviderInDryRunMode(t *testing.T) {
providerMessage := "Provider Error"
status, message, dryRunSummary := StartAssessRunStatusErrorMessageFromProvider(t, providerMessage, true)
assert.Equal(t, v1alpha1.AnalysisPhaseSuccessful, status)
assert.Equal(t, v1alpha1.AnalysisPhaseRunning, status)
assert.Equal(t, "", message)
expectedDryRunSummary := v1alpha1.RunSummary{
Count: 2,
Expand Down Expand Up @@ -1587,7 +1587,7 @@ func TestAssessRunStatusMultipleFailures(t *testing.T) {

func TestAssessRunStatusMultipleFailuresInDryRunMode(t *testing.T) {
status, message, dryRunSummary := StartAssessRunStatusMultipleFailures(t, true)
assert.Equal(t, v1alpha1.AnalysisPhaseSuccessful, status)
assert.Equal(t, v1alpha1.AnalysisPhaseRunning, status)
assert.Equal(t, "", message)
expectedDryRunSummary := v1alpha1.RunSummary{
Count: 2,
Expand Down Expand Up @@ -1623,7 +1623,7 @@ func TestAssessRunStatusWorstMessageInReconcileAnalysisRun(t *testing.T) {

func TestAssessRunStatusWorstMessageInReconcileAnalysisRunInDryRunMode(t *testing.T) {
newRun := StartAssessRunStatusWorstMessageInReconcileAnalysisRun(t, true)
assert.Equal(t, v1alpha1.AnalysisPhaseSuccessful, newRun.Status.Phase)
assert.Equal(t, v1alpha1.AnalysisPhaseRunning, newRun.Status.Phase)
assert.Equal(t, "", newRun.Status.Message)
expectedDryRunSummary := v1alpha1.RunSummary{
Count: 2,
Expand Down
11 changes: 10 additions & 1 deletion analysis/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package analysis
import (
"time"

unstructuredutil "github.com/argoproj/argo-rollouts/utils/unstructured"

log "github.com/sirupsen/logrus"
batchv1 "k8s.io/api/batch/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -117,7 +119,14 @@ func NewController(cfg ControllerConfig) *Controller {
UpdateFunc: func(old, new interface{}) {
controller.enqueueAnalysis(new)
},
DeleteFunc: controller.enqueueAnalysis,
DeleteFunc: func(obj interface{}) {
controller.enqueueAnalysis(obj)
if ar := unstructuredutil.ObjectToAnalysisRun(obj); ar != nil {
logCtx := logutil.WithAnalysisRun(ar)
logCtx.Info("analysis run deleted")
controller.metricsServer.Remove(ar.Namespace, ar.Name, logutil.AnalysisRunKey)
}
},
})
return controller
}
Expand Down
8 changes: 5 additions & 3 deletions controller/metrics/analysis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"

"github.com/ghodss/yaml"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -162,7 +164,7 @@ func testAnalysisRunDescribe(t *testing.T, fakeAnalysisRun string, expectedRespo
registry.MustRegister(NewAnalysisRunCollector(serverCfg.AnalysisRunLister, serverCfg.AnalysisTemplateLister, serverCfg.ClusterAnalysisTemplateLister))
mux := http.NewServeMux()
mux.Handle(MetricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
testHttpResponse(t, mux, expectedResponse)
testHttpResponse(t, mux, expectedResponse, assert.Contains)
}

func TestIncAnalysisRunReconcile(t *testing.T) {
Expand All @@ -184,7 +186,7 @@ analysis_run_reconcile_count{name="ar-test",namespace="ar-namespace"} 1`
},
}
metricsServ.IncAnalysisRunReconcile(ar, time.Millisecond)
testHttpResponse(t, metricsServ.Handler, expectedResponse)
testHttpResponse(t, metricsServ.Handler, expectedResponse, assert.Contains)
}

func TestAnalysisTemplateDescribe(t *testing.T) {
Expand All @@ -206,5 +208,5 @@ analysis_template_metric_info{metric="web-metric-2",name="http-benchmark-test",n
registry.MustRegister(NewAnalysisRunCollector(serverCfg.AnalysisRunLister, serverCfg.AnalysisTemplateLister, serverCfg.ClusterAnalysisTemplateLister))
mux := http.NewServeMux()
mux.Handle(MetricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
testHttpResponse(t, mux, expectedResponse)
testHttpResponse(t, mux, expectedResponse, assert.Contains)
}
4 changes: 3 additions & 1 deletion controller/metrics/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package metrics
import (
"testing"

"github.com/stretchr/testify/assert"

"github.com/argoproj/pkg/kubeclientmetrics"
)

Expand All @@ -24,5 +26,5 @@ func TestIncKubernetesRequest(t *testing.T) {
Verb: kubeclientmetrics.Unknown,
StatusCode: 200,
})
testHttpResponse(t, metricsServ.Handler, expectedKubernetesRequest)
testHttpResponse(t, metricsServ.Handler, expectedKubernetesRequest, assert.Contains)
}
6 changes: 4 additions & 2 deletions controller/metrics/experiment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"

"github.com/ghodss/yaml"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -133,7 +135,7 @@ func testExperimentDescribe(t *testing.T, fakeExperiment string, expectedRespons
registry.MustRegister(NewExperimentCollector(config.ExperimentLister))
mux := http.NewServeMux()
mux.Handle(MetricsPath, promhttp.HandlerFor(registry, promhttp.HandlerOpts{}))
testHttpResponse(t, mux, expectedResponse)
testHttpResponse(t, mux, expectedResponse, assert.Contains)
}

func TestIncExperimentReconcile(t *testing.T) {
Expand All @@ -156,5 +158,5 @@ experiment_reconcile_count{name="ex-test",namespace="ex-namespace"} 1`
},
}
metricsServ.IncExperimentReconcile(ex, time.Millisecond)
testHttpResponse(t, metricsServ.Handler, expectedResponse)
testHttpResponse(t, metricsServ.Handler, expectedResponse, assert.Contains)
}
Loading

0 comments on commit bd971dd

Please sign in to comment.