Skip to content

Commit 6fddeef

Browse files
Merge branch 'main' into add-rp-e2e-test
2 parents 759517c + 0bdd1a2 commit 6fddeef

File tree

179 files changed

+31726
-4174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+31726
-4174
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
if: needs.detect-noop.outputs.noop != 'true'
3636
steps:
3737
- name: Set up Go
38-
uses: actions/setup-go@v5
38+
uses: actions/setup-go@v6
3939
with:
4040
go-version: ${{ env.GO_VERSION }}
4141

@@ -57,52 +57,29 @@ jobs:
5757
## Comma-separated list of files to upload
5858
files: ./it-coverage.xml;./ut-coverage.xml
5959

60-
e2e-tests-v1alpha1:
61-
runs-on: ubuntu-latest
62-
needs: [
63-
detect-noop,
64-
]
65-
if: needs.detect-noop.outputs.noop != 'true'
66-
steps:
67-
- name: Set up Go
68-
uses: actions/setup-go@v5
69-
with:
70-
go-version: ${{ env.GO_VERSION }}
71-
72-
- name: Check out code into the Go module directory
73-
uses: actions/checkout@v5
74-
75-
- name: Install Kind
76-
# Before updating the kind version to use, verify that the current kind image
77-
# is still supported by the version.
78-
run: |
79-
go install sigs.k8s.io/[email protected]
80-
81-
- name: Run e2e tests
82-
run: |
83-
OUTPUT_TYPE=type=docker make docker-build-member-agent docker-build-hub-agent docker-build-refresh-token e2e-tests-v1alpha1
84-
env:
85-
KUBECONFIG: '/home/runner/.kube/config'
86-
HUB_SERVER_URL: 'https://172.19.0.2:6443'
87-
8860
e2e-tests:
8961
strategy:
9062
fail-fast: false
9163
matrix:
92-
customized-settings: [default, joinleave, custom]
64+
customized-settings: [default, resourceplacement, joinleave, custom]
9365
include:
9466
- customized-settings: default
9567
# to shorten the test duration, set the resource snapshot creation interval to 0
9668
resource-snapshot-creation-minimum-interval: 0m
9769
resource-changes-collection-duration: 0m
70+
- customized-settings: resourceplacement
71+
# to shorten the test duration, set the resource snapshot creation interval to 0
72+
resource-snapshot-creation-minimum-interval: 0m
73+
resource-changes-collection-duration: 0m
9874
- customized-settings: joinleave
9975
# to shorten the test duration, set the resource snapshot creation interval to 0
10076
resource-snapshot-creation-minimum-interval: 0m
10177
resource-changes-collection-duration: 0m
10278
- customized-settings: custom
10379
resource-snapshot-creation-minimum-interval: 30s
10480
resource-changes-collection-duration: 15s
105-
runs-on: ubuntu-latest
81+
runs-on:
82+
labels: ubuntu-latest-16-cores
10683
needs: [
10784
detect-noop,
10885
]
@@ -116,7 +93,7 @@ jobs:
11693
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
11794

11895
- name: Set up Go
119-
uses: actions/setup-go@v5
96+
uses: actions/setup-go@v6
12097
with:
12198
go-version: ${{ env.GO_VERSION }}
12299

@@ -125,18 +102,20 @@ jobs:
125102

126103
- name: Install Ginkgo CLI
127104
run: |
128-
go install github.com/onsi/ginkgo/v2/ginkgo@v2.19.1
105+
go install github.com/onsi/ginkgo/v2/ginkgo@v2.23.4
129106

130107
- name: Install Kind
131108
# Before updating the kind version to use, verify that the current kind image
132109
# is still supported by the version.
133110
run: |
134-
go install sigs.k8s.io/kind@v0.22.0
111+
go install sigs.k8s.io/kind@v0.30.0
135112

136113
- name: Run e2e tests
137114
run: |
138115
if [ "${{ matrix.customized-settings }}" = "default" ]; then
139-
make e2e-tests LABEL_FILTER="!custom && !joinleave"
116+
make e2e-tests LABEL_FILTER="!custom && !joinleave && !resourceplacement"
117+
elif [ "${{ matrix.customized-settings }}" = "resourceplacement" ]; then
118+
make e2e-tests LABEL_FILTER="!custom && resourceplacement"
140119
elif [ "${{ matrix.customized-settings }}" = "joinleave" ]; then
141120
make e2e-tests LABEL_FILTER="!custom && joinleave"
142121
else

.github/workflows/code-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Setup Go
41-
uses: actions/setup-go@v5
41+
uses: actions/setup-go@v6
4242
with:
4343
go-version: ${{ env.GO_VERSION }}
4444

@@ -59,7 +59,7 @@ jobs:
5959

6060
steps:
6161
- name: Set up Go ${{ env.GO_VERSION }}
62-
uses: actions/setup-go@v5
62+
uses: actions/setup-go@v6
6363
with:
6464
go-version: ${{ env.GO_VERSION }}
6565

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@v3
45+
uses: github/codeql-action/init@v4
4646
with:
4747
languages: ${{ matrix.language }}
4848
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -56,7 +56,7 @@ jobs:
5656
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5757
# If this step fails, then you should remove it and run the build manually (see below)
5858
- name: Autobuild
59-
uses: github/codeql-action/autobuild@v3
59+
uses: github/codeql-action/autobuild@v4
6060

6161
# ℹ️ Command-line programs to run using the OS shell.
6262
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -69,4 +69,4 @@ jobs:
6969
# ./location_of_script_within_repo/buildscript.sh
7070

7171
- name: Perform CodeQL Analysis
72-
uses: github/codeql-action/analyze@v3
72+
uses: github/codeql-action/analyze@v4

.github/workflows/codespell.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Harden Runner
15-
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
15+
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
1616
with:
1717
egress-policy: audit
1818

.github/workflows/trivy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ jobs:
3939
runs-on: ubuntu-latest #Latest tag points to the latest LTS release of Ubuntu per docker hub
4040
steps:
4141
- name: Set up Go ${{ env.GO_VERSION }}
42-
uses: actions/setup-go@v5
42+
uses: actions/setup-go@v6
4343
with:
4444
go-version: ${{ env.GO_VERSION }}
4545

4646
- name: Checkout code
4747
uses: actions/checkout@v5
4848

4949
- name: Login to ${{ env.REGISTRY }}
50-
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1
50+
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef
5151
with:
5252
registry: ${{ env.REGISTRY }}
5353
username: ${{ github.actor }}

.github/workflows/upgrade.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
if: needs.detect-noop.outputs.noop != 'true'
4040
steps:
4141
- name: Set up Go
42-
uses: actions/setup-go@v5
42+
uses: actions/setup-go@v6
4343
with:
4444
go-version: ${{ env.GO_VERSION }}
4545

@@ -122,7 +122,7 @@ jobs:
122122
if: needs.detect-noop.outputs.noop != 'true'
123123
steps:
124124
- name: Set up Go
125-
uses: actions/setup-go@v5
125+
uses: actions/setup-go@v6
126126
with:
127127
go-version: ${{ env.GO_VERSION }}
128128

@@ -205,7 +205,7 @@ jobs:
205205
if: needs.detect-noop.outputs.noop != 'true'
206206
steps:
207207
- name: Set up Go
208-
uses: actions/setup-go@v5
208+
uses: actions/setup-go@v6
209209
with:
210210
go-version: ${{ env.GO_VERSION }}
211211

Makefile

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
REGISTRY ?= ghcr.io
2-
KIND_IMAGE ?= kindest/node:v1.31.0
2+
KIND_IMAGE ?= kindest/node:v1.33.4
33
ifndef TAG
44
TAG ?= $(shell git rev-parse --short=7 HEAD)
55
endif
@@ -11,6 +11,30 @@ HUB_AGENT_IMAGE_NAME ?= hub-agent
1111
MEMBER_AGENT_IMAGE_NAME ?= member-agent
1212
REFRESH_TOKEN_IMAGE_NAME := refresh-token
1313

14+
TARGET_OS ?= linux
15+
TARGET_ARCH ?= amd64
16+
AUTO_DETECT_ARCH ?= TRUE
17+
18+
# Auto-detect system architecture if it is allowed and the necessary commands are available on the system.
19+
ifeq ($(AUTO_DETECT_ARCH), TRUE)
20+
ARCH_CMD_INSTALLED := $(shell command -v arch 2>/dev/null)
21+
ifdef ARCH_CMD_INSTALLED
22+
TARGET_ARCH := $(shell arch)
23+
# The arch command may return arch strings that are aliases of expected TARGET_ARCH values;
24+
# do the mapping here.
25+
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),x86_64))
26+
TARGET_ARCH := amd64
27+
else ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),aarch64 arm))
28+
TARGET_ARCH := arm64
29+
endif
30+
$(info Auto-detected system architecture: $(TARGET_ARCH))
31+
endif
32+
endif
33+
34+
# Note (chenyu1): switch to the `plain` progress type to see the full outputs in the docker build
35+
# progress.
36+
BUILDKIT_PROGRESS_TYPE ?= auto
37+
1438
KUBECONFIG ?= $(HOME)/.kube/config
1539
HUB_SERVER_URL ?= https://172.19.0.2:6443
1640

@@ -137,6 +161,8 @@ test: manifests generate fmt vet local-unit-test integration-test## Run tests.
137161
## workaround to bypass the pkg/controllers/workv1alpha1 tests failure
138162
## rollout controller tests need a bit longer to complete, so we increase the timeout
139163
##
164+
# Set up the timeout parameters as some of the test lengths have exceeded the default 10 minute mark.
165+
# TO-DO (chenyu1): enable parallelization for single package integration tests.
140166
.PHONY: local-unit-test
141167
local-unit-test: $(ENVTEST) ## Run tests.
142168
export CGO_ENABLED=1 && \
@@ -285,9 +311,22 @@ push:
285311

286312
# By default, docker buildx create will pull image moby/buildkit:buildx-stable-1 and hit the too many requests error
287313
.PHONY: docker-buildx-builder
314+
# Note (chenyu1): the step below sets up emulation for building/running non-native binaries on the host. The original
315+
# setup assumes that the Makefile is always run on an x86_64 platform, and adds support for non-x86_64 hosts. Here
316+
# we keep the original setup if the build target is x86_64 platforms (default) for compatibility reasons, but will switch to
317+
# a more general setup for non-x86_64 hosts.
318+
#
319+
# On some systems the emulation setup might not work at all (e.g., macOS on Apple Silicon -> Rosetta 2 will be used
320+
# by Docker Desktop as the default emulation option for AMD64 on ARM64 container compatibility).
288321
docker-buildx-builder:
289322
@if ! docker buildx ls | grep $(BUILDX_BUILDER_NAME); then \
290-
docker run --rm --privileged mcr.microsoft.com/mirror/docker/multiarch/qemu-user-static:$(QEMU_VERSION) --reset -p yes; \
323+
if [ "$(TARGET_ARCH)" = "amd64" ] ; then \
324+
echo "The target is an x86_64 platform; setting up emulation for other known architectures"; \
325+
docker run --rm --privileged mcr.microsoft.com/mirror/docker/multiarch/qemu-user-static:$(QEMU_VERSION) --reset -p yes; \
326+
else \
327+
echo "Setting up emulation for known architectures"; \
328+
docker run --rm --privileged tonistiigi/binfmt --install all; \
329+
fi ;\
291330
docker buildx create --driver-opt image=mcr.microsoft.com/oss/v2/moby/buildkit:$(BUILDKIT_VERSION) --name $(BUILDX_BUILDER_NAME) --use; \
292331
docker buildx inspect $(BUILDX_BUILDER_NAME) --bootstrap; \
293332
fi
@@ -297,27 +336,36 @@ docker-build-hub-agent: docker-buildx-builder
297336
docker buildx build \
298337
--file docker/$(HUB_AGENT_IMAGE_NAME).Dockerfile \
299338
--output=$(OUTPUT_TYPE) \
300-
--platform="linux/amd64" \
339+
--platform=$(TARGET_OS)/$(TARGET_ARCH) \
301340
--pull \
302-
--tag $(REGISTRY)/$(HUB_AGENT_IMAGE_NAME):$(HUB_AGENT_IMAGE_VERSION) .
341+
--tag $(REGISTRY)/$(HUB_AGENT_IMAGE_NAME):$(HUB_AGENT_IMAGE_VERSION) \
342+
--progress=$(BUILDKIT_PROGRESS_TYPE) \
343+
--build-arg GOARCH=$(TARGET_ARCH) \
344+
--build-arg GOOS=$(TARGET_OS) .
303345

304346
.PHONY: docker-build-member-agent
305347
docker-build-member-agent: docker-buildx-builder
306348
docker buildx build \
307349
--file docker/$(MEMBER_AGENT_IMAGE_NAME).Dockerfile \
308350
--output=$(OUTPUT_TYPE) \
309-
--platform="linux/amd64" \
351+
--platform=$(TARGET_OS)/$(TARGET_ARCH) \
310352
--pull \
311-
--tag $(REGISTRY)/$(MEMBER_AGENT_IMAGE_NAME):$(MEMBER_AGENT_IMAGE_VERSION) .
353+
--tag $(REGISTRY)/$(MEMBER_AGENT_IMAGE_NAME):$(MEMBER_AGENT_IMAGE_VERSION) \
354+
--progress=$(BUILDKIT_PROGRESS_TYPE) \
355+
--build-arg GOARCH=$(TARGET_ARCH) \
356+
--build-arg GOOS=$(TARGET_OS) .
312357

313358
.PHONY: docker-build-refresh-token
314359
docker-build-refresh-token: docker-buildx-builder
315360
docker buildx build \
316361
--file docker/$(REFRESH_TOKEN_IMAGE_NAME).Dockerfile \
317362
--output=$(OUTPUT_TYPE) \
318-
--platform="linux/amd64" \
363+
--platform=$(TARGET_OS)/$(TARGET_ARCH) \
319364
--pull \
320-
--tag $(REGISTRY)/$(REFRESH_TOKEN_IMAGE_NAME):$(REFRESH_TOKEN_IMAGE_VERSION) .
365+
--tag $(REGISTRY)/$(REFRESH_TOKEN_IMAGE_NAME):$(REFRESH_TOKEN_IMAGE_VERSION) \
366+
--progress=$(BUILDKIT_PROGRESS_TYPE) \
367+
--build-arg GOARCH=$(TARGET_ARCH) \
368+
--build-arg GOOS=${TARGET_OS} .
321369

322370
## -----------------------------------
323371
## Cleanup

apis/cluster/v1beta1/membercluster_types.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,30 @@ type MemberClusterSpec struct {
7474
// +kubebuilder:validation:MaxItems=100
7575
// +optional
7676
Taints []Taint `json:"taints,omitempty"`
77+
78+
// DeleteOptions for deleting the MemberCluster.
79+
// +optional
80+
DeleteOptions *DeleteOptions `json:"deleteOptions,omitempty"`
81+
}
82+
83+
// DeleteValidationMode identifies the type of validation when deleting a MemberCluster.
84+
// +enum
85+
type DeleteValidationMode string
86+
87+
const (
88+
// DeleteValidationModeSkip skips the validation when deleting a MemberCluster.
89+
DeleteValidationModeSkip = "Skip"
90+
91+
// DeleteValidationModeStrict performs strict validation when deleting a MemberCluster.
92+
DeleteValidationModeStrict = "Strict"
93+
)
94+
95+
type DeleteOptions struct {
96+
// Mode of validation. Can be "Skip", or "Strict". Default is Strict.
97+
// +kubebuilder:validation:Enum=Skip;Strict
98+
// +kubebuilder:default=Strict
99+
// +kubebuilder:validation:Optional
100+
ValidationMode DeleteValidationMode `json:"validationMode,omitempty"`
77101
}
78102

79103
// PropertyName is the name of a cluster property; it should be a Kubernetes label name.

apis/cluster/v1beta1/zz_generated.deepcopy.go

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/placement/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)