Skip to content

Commit 0af2749

Browse files
authored
feat: add rollout api (#34)
* feat: add rollout api * feat: update rollout api * update go mod * feat: rewrite backendRouting API * update backendrouting api * feat: add route-spec-backup and route-conditions annotations * feat: add canary workload in status * chore: add license header * ci: fix lint
1 parent 0f8134b commit 0af2749

40 files changed

+17732
-894
lines changed

.github/workflows/ci.yaml

Lines changed: 44 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -4,115 +4,61 @@ name: Check
44
on:
55
pull_request:
66
branches:
7-
- main
8-
- release-*
7+
- main
8+
- release-*
99
push:
1010
branches:
11-
- main
12-
- release-*
11+
- main
12+
- release-*
1313

1414
env:
15-
GO_VERSION: '1.19'
15+
GO_VERSION: '1.23'
1616

1717
jobs:
1818

1919
# Test:
2020
# name: Unit Test
21-
# runs-on: ubuntu-20.04
21+
# runs-on: ubuntu-latest
2222
# steps:
23-
# - uses: actions/checkout@v3
24-
# with:
25-
# submodules: true
26-
# - name: Fetch History
27-
# run: git fetch --prune --unshallow
28-
# - name: Setup Go
29-
# uses: actions/setup-go@v3
30-
# with:
31-
# go-version: ${{ env.GO_VERSION }}
32-
# - name: Cache Go Dependencies
33-
# uses: actions/cache@v2
34-
# with:
35-
# path: ~/go/pkg/mod
36-
# key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
37-
# restore-keys: ${{ runner.os }}-go-
38-
# - name: Run Unit Tests
39-
# run: |
40-
# make test
41-
# git status
42-
# # TODO: enable after public
43-
# # - name: Publish Unit Test Coverage
44-
# # uses: codecov/codecov-action@v3
45-
# # with:
46-
# # flags: unittests
47-
# # file: cover.out
48-
# - name: Check diff
49-
# run: '[[ -z $(git status -s) ]] || (printf "Existing modified/untracked files.\nPlease run \"make generate manifests fmt vet\" and push again.\n"; exit 1)'
23+
# - uses: actions/checkout@v4
24+
# - name: Set up Go
25+
# uses: actions/setup-go@v5
26+
# with:
27+
# go-version: ${{ env.GO_VERSION }}
28+
# check-latest: true
29+
# cache-dependency-path: "**/*.sum"
30+
# - name: Run Unit Tests
31+
# run: |
32+
# make test
33+
# git status
5034

5135
GolangLint:
5236
name: Golang Lint
5337
runs-on: ubuntu-latest
5438
steps:
55-
- name: Checkout
56-
uses: actions/checkout@v3
57-
with:
58-
fetch-depth: 0
59-
- name: Set up Go
60-
uses: actions/setup-go@v4
61-
with:
62-
go-version: ${{ env.GO_VERSION }}
63-
cache: false
64-
- name: golangci-lint
65-
uses: golangci/golangci-lint-action@v3
66-
with:
67-
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
68-
version: v1.53
69-
args: --timeout=30m
70-
71-
# Lints Pull Request commits with commitlint.
72-
#
73-
# Rules can be referenced:
74-
# https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
75-
# CommitLint:
76-
# name: Commit Lint
77-
# runs-on: ubuntu-latest
78-
# if: contains(fromJSON('["pull_request"]'), github.event_name)
79-
# steps:
80-
# - name: Checkout
81-
# uses: actions/checkout@v3
82-
# with:
83-
# fetch-depth: 0
84-
# - uses: wagoid/commitlint-github-action@v5
85-
86-
# Lints Pull Request title, because the title will be used as the
87-
# commit message in branch main.
88-
#
89-
# Configuration detail can be referenced:
90-
# https://github.com/marketplace/actions/pull-request-title-rules
91-
92-
# PullRequestTitleLint:
93-
# name: Pull Request Title Lint
94-
# runs-on: ubuntu-latest
95-
# if: contains(fromJSON('["pull_request"]'), github.event_name)
96-
# steps:
97-
# - uses: deepakputhraya/action-pr-title@master
98-
# with:
99-
# allowed_prefixes: 'build,chore,ci,docs,feat,fix,perf,refactor,revert,style,test' # title should start with the given prefix
100-
# disallowed_prefixes: 'WIP,[WIP]' # title should not start with the given prefix
101-
# prefix_case_sensitive: false # title prefix are case insensitive
102-
# min_length: 5 # Min length of the title
103-
# max_length: 80 # Max length of the title
104-
# github_token: ${{ github.token }} # Default: ${{ github.token }}
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
- name: Set up Go
42+
uses: actions/setup-go@v5
43+
with:
44+
go-version: ${{ env.GO_VERSION }}
45+
check-latest: true
46+
cache-dependency-path: "**/*.sum"
47+
- name: golangci-lint
48+
uses: golangci/golangci-lint-action@v7
49+
with:
50+
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
51+
version: v2.0.2
52+
args: --timeout=30m
10553

10654
LicenseCheck:
10755
name: License Check
10856
runs-on: ubuntu-latest
10957
env:
11058
TERM: xterm
11159
steps:
112-
- uses: actions/checkout@v3
113-
with:
114-
fetch-depth: 0
115-
- uses: apache/skywalking-eyes@main
60+
- uses: actions/checkout@v4
61+
- uses: apache/skywalking-eyes@main
11662

11763
# The TruffleHog OSS Github Action can be used to scan a range of commits for leaked credentials. The action will fail if any results are found.
11864
# More see: https://github.com/marketplace/actions/trufflehog-oss
@@ -121,30 +67,14 @@ jobs:
12167
name: Secret Scan
12268
runs-on: ubuntu-latest
12369
steps:
124-
- name: Checkout
125-
uses: actions/checkout@v3
126-
with:
127-
fetch-depth: 0
128-
- name: TruffleHog OSS
129-
uses: trufflesecurity/trufflehog@main
130-
with:
131-
path: ./
132-
base: ${{ github.event.repository.default_branch }}
133-
head: HEAD
134-
extra_args: --debug --json
135-
136-
# TODO: Uncomment when the repository is publicly.
137-
# DependencyReview:
138-
# permissions:
139-
# actions: read
140-
# contents: read
141-
# security-events: write
142-
# name: Dependency Review
143-
# runs-on: ubuntu-latest
144-
# steps:
145-
# - uses: actions/checkout@v3
146-
# with:
147-
# fetch-depth: 0
148-
# - uses: actions/dependency-review-action@v3
149-
# with:
150-
# fail-on-severity: critical
70+
- name: Checkout
71+
uses: actions/checkout@v3
72+
with:
73+
fetch-depth: 0
74+
- name: TruffleHog OSS
75+
uses: trufflesecurity/trufflehog@main
76+
with:
77+
path: ./
78+
base: ${{ github.event.repository.default_branch }}
79+
head: HEAD
80+
extra_args: --debug --json

.golangci.yaml

Lines changed: 77 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,78 @@
1-
run:
2-
skip-files:
3-
- ".*_test.go"
4-
skip-dirs:
5-
- vendor/
6-
1+
version: "2"
72
linters:
8-
disable:
9-
- errcheck
10-
- unused
3+
default: standard
4+
enable:
5+
- bodyclose
6+
- copyloopvar
7+
- ginkgolinter
8+
- testifylint
9+
- misspell
10+
- nakedret
11+
- unconvert
12+
- unparam
13+
- whitespace
14+
- gocritic
15+
- errorlint
16+
settings:
17+
govet:
18+
enable:
19+
- shadow
20+
misspell:
21+
locale: US
22+
staticcheck:
23+
checks:
24+
- "-QF1008"
25+
gocritic:
26+
enable-all: true
27+
disabled-checks:
28+
- emptyStringTest
29+
- ifElseChain
30+
- singleCaseSwitch
31+
- hugeParam
32+
- unnamedResult
33+
- whyNoLint
34+
- tooManyResultsChecker
35+
exclusions:
36+
generated: lax
37+
presets:
38+
- comments
39+
- common-false-positives
40+
- legacy
41+
- std-error-handling
42+
rules:
43+
- linters:
44+
- errcheck
45+
- unparam
46+
path: _test.go
47+
- linters:
48+
- govet
49+
text: declaration of "err" shadows declaration at line
50+
paths:
51+
- third_party$
52+
- builtin$
53+
- examples$
54+
formatters:
55+
enable:
56+
- gofumpt # drop in replacement for gofmt
57+
- gci # format imports
58+
settings:
59+
gci:
60+
custom-order: true
61+
sections:
62+
- standard
63+
- blank
64+
- dot
65+
- default
66+
- localmodule
67+
gofumpt:
68+
extra-rules: true
69+
exclusions:
70+
generated: lax
71+
paths:
72+
- third_party$
73+
- builtin$
74+
- examples$
75+
76+
run:
77+
allow-parallel-runners: true
78+
timeout: 10m

Makefile

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1+
SHELL = /usr/bin/env bash -o pipefail
2+
.SHELLFLAGS = -ec
3+
4+
.PHONY: fmt
5+
fmt: golangci
6+
$(GOLANGCI) fmt
7+
8+
.PHONY: lint
9+
lint: fmt
10+
$(GOLANGCI) run
11+
12+
manifests:
13+
@bash hack/make-rules/update-manifests.sh
14+
15+
generate:
16+
@bash hack/make-rules/update-codegen.sh
17+
18+
19+
##@ Build Dependencies
20+
21+
## Location to install dependencies to
122
LOCALBIN ?= $(shell pwd)/bin
2-
$(LOCALBIN):
3-
mkdir -p $(LOCALBIN)
4-
CONTROLLER_TOOLS_VERSION ?= v0.15.0
5-
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
6-
CODEGEN = $(LOCALBIN)/kube-codegen
7-
8-
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary. If wrong version is installed, it will be overwritten.
9-
$(CONTROLLER_GEN): $(LOCALBIN)
10-
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
11-
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
12-
13-
manifests: controller-gen
14-
@for dir in apps cluster; do \
15-
mkdir -p "config/crd/$$dir"; \
16-
$(CONTROLLER_GEN) rbac:roleName=manager-role crd:generateEmbeddedObjectMeta=true webhook paths="./$$dir/..." output:crd:artifacts:config="config/crd/$$dir"; \
17-
done
18-
19-
generate: codegen controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
20-
#@scripts/generate_client.sh
21-
# $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
22-
$(CODEGEN) code-gen --go-header-file=./hack/boilerplate.go.txt --code-generator-version=v0.27.16 --apis-path=./ --generators=deepcopy,register
23-
24-
codegen: $(CODEGEN) # Download kube-codegen locally if necessary. If wrong version is installed, it will be overwritten.
25-
$(CODEGEN):
26-
ifeq (, $(shell command -v $(CODEGEN)))
27-
@cd $(shell mktemp -d) && \
28-
git clone https://github.com/zoumo/kube-codegen.git && \
29-
cd kube-codegen && \
30-
GOBIN=$(LOCALBIN) go install ./cmd/kube-codegen
31-
endif
23+
24+
GOLANGCI ?= $(LOCALBIN)/golangci-lint
25+
26+
.PHONY: golangci
27+
golangci:
28+
@bash hack/make-rules/install-go-tools.sh golangci-lint

apps/v1alpha1/collaset_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ type PersistentVolumeClaimRetentionPolicy struct {
148148
// WhenDeleted specifies what happens to PVCs created from CollaSet
149149
// VolumeClaimTemplates when the CollaSet is deleted. The default policy
150150
// of `Delete` policy causes those PVCs to be deleted.
151-
//`Retain` causes PVCs to not be affected by StatefulSet deletion. The
151+
// `Retain` causes PVCs to not be affected by StatefulSet deletion. The
152152
// +optional
153153
WhenDeleted PersistentVolumeClaimRetentionPolicyType `json:"whenDeleted,omitempty"`
154154

apps/v1alpha1/podtransitionrule_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ type WebhookResponse struct {
305305
FinishedNames []string `json:"finishedNames,omitempty"`
306306
Message string `json:"message"`
307307
Poll bool `json:"poll"`
308-
// Deprecated, will replace by Poll
308+
// Deprecated: will replace by Poll
309309
Async bool `json:"async"`
310310
// if Async, use TraceId as TaskId
311311
TraceId string `json:"traceId"`

apps/v1alpha1/well_known_labels.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ const (
6464
PodPreparingDeleteLabel = "podopslifecycle.kusionstack.io/preparing-to-delete"
6565
)
6666

67-
var (
68-
WellKnownLabelPrefixesWithID = []string{PodOperatingLabelPrefix, PodOperationTypeLabelPrefix, PodPreCheckLabelPrefix, PodPreCheckedLabelPrefix,
69-
PodPreparingLabelPrefix, PodDoneOperationTypeLabelPrefix, PodUndoOperationTypeLabelPrefix, PodOperateLabelPrefix, PodOperatedLabelPrefix, PodPostCheckLabelPrefix,
70-
PodPostCheckedLabelPrefix, PodCompletingLabelPrefix}
71-
)
67+
var WellKnownLabelPrefixesWithID = []string{
68+
PodOperatingLabelPrefix, PodOperationTypeLabelPrefix, PodPreCheckLabelPrefix, PodPreCheckedLabelPrefix,
69+
PodPreparingLabelPrefix, PodDoneOperationTypeLabelPrefix, PodUndoOperationTypeLabelPrefix, PodOperateLabelPrefix, PodOperatedLabelPrefix, PodPostCheckLabelPrefix,
70+
PodPostCheckedLabelPrefix, PodCompletingLabelPrefix,
71+
}
7272

7373
// CollaSet labels
7474
const (

0 commit comments

Comments
 (0)