Skip to content

Commit 42ebac7

Browse files
authored
chore: backport PR from kubefleet 10/17/2025 (#1211)
2 parents a71b0f3 + 6472e49 commit 42ebac7

File tree

104 files changed

+6549
-1568
lines changed

Some content is hidden

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

104 files changed

+6549
-1568
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -57,34 +57,6 @@ 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@v6
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
@@ -129,13 +101,13 @@ jobs:
129101

130102
- name: Install Ginkgo CLI
131103
run: |
132-
go install github.com/onsi/ginkgo/v2/ginkgo@v2.19.1
104+
go install github.com/onsi/ginkgo/v2/ginkgo@v2.23.4
133105
134106
- name: Install Kind
135107
# Before updating the kind version to use, verify that the current kind image
136108
# is still supported by the version.
137109
run: |
138-
go install sigs.k8s.io/kind@v0.22.0
110+
go install sigs.k8s.io/kind@v0.30.0
139111
140112
- name: Run e2e tests
141113
run: |

.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/trivy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
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 }}

Makefile

Lines changed: 32 additions & 1 deletion
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
@@ -20,6 +20,30 @@ TARGET_ARCH ?= amd64
2020
# progress.
2121
BUILDKIT_PROGRESS_TYPE ?= auto
2222

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

@@ -311,6 +335,13 @@ push:
311335
# On some systems the emulation setup might not work at all (e.g., macOS on Apple Silicon -> Rosetta 2 will be used
312336
# by Docker Desktop as the default emulation option for AMD64 on ARM64 container compatibility).
313337
.PHONY: docker-buildx-builder
338+
# Note (chenyu1): the step below sets up emulation for building/running non-native binaries on the host. The original
339+
# setup assumes that the Makefile is always run on an x86_64 platform, and adds support for non-x86_64 hosts. Here
340+
# we keep the original setup if the build target is x86_64 platforms (default) for compatibility reasons, but will switch to
341+
# a more general setup for non-x86_64 hosts.
342+
#
343+
# On some systems the emulation setup might not work at all (e.g., macOS on Apple Silicon -> Rosetta 2 will be used
344+
# by Docker Desktop as the default emulation option for AMD64 on ARM64 container compatibility).
314345
docker-buildx-builder:
315346
@if ! docker buildx ls | grep $(BUILDX_BUILDER_NAME); then \
316347
if [ "$(TARGET_ARCH)" = "amd64" ] ; then \

apis/placement/v1beta1/clusterresourceplacement_types.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,11 @@ type RolloutStrategy struct {
539539
// DeleteStrategy configures the deletion behavior when the ClusterResourcePlacement is deleted.
540540
// +kubebuilder:validation:Optional
541541
DeleteStrategy *DeleteStrategy `json:"deleteStrategy,omitempty"`
542+
543+
// ReportBackStrategy describes how to report back the status of applied resources on the member cluster.
544+
// +kubebuilder:validation:Optional
545+
// +kubebuilder:validation:XValidation:rule="(self == null) || (self.type == 'Mirror' ? size(self.destination) != 0 : true)",message="when reportBackStrategy.type is 'Mirror', a destination must be specified"
546+
ReportBackStrategy *ReportBackStrategy `json:"reportBackStrategy,omitempty"`
542547
}
543548

544549
// ApplyStrategy describes when and how to apply the selected resource to the target cluster.
@@ -1480,6 +1485,66 @@ const (
14801485
DeletePropagationPolicyDelete DeletePropagationPolicy = "Delete"
14811486
)
14821487

1488+
type ReportBackStrategyType string
1489+
1490+
const (
1491+
// ReportBackStrategyTypeDisabled disables status back-reporting from the member clusters.
1492+
ReportBackStrategyTypeDisabled ReportBackStrategyType = "Disabled"
1493+
1494+
// ReportBackStrategyTypeMirror enables status back-reporting by
1495+
// copying the status fields verbatim to some destination on the hub cluster side.
1496+
ReportBackStrategyTypeMirror ReportBackStrategyType = "Mirror"
1497+
)
1498+
1499+
type ReportBackDestination string
1500+
1501+
const (
1502+
// ReportBackDestinationOriginalResource implies the status fields will be copied verbatim to the
1503+
// the original resource on the hub cluster side. This is only performed when the placement object has a
1504+
// scheduling policy that selects exactly one member cluster (i.e., a pickFixed scheduling policy with
1505+
// exactly one cluster name, or a pickN scheduling policy with the numberOfClusters field set to 1).
1506+
ReportBackDestinationOriginalResource ReportBackDestination = "OriginalResource"
1507+
1508+
// ReportBackDestinationWorkAPI implies the status fields will be copied verbatim via the Work API
1509+
// on the hub cluster side. Users may look up the status of a specific resource applied to a specific
1510+
// member cluster by inspecting the corresponding Work object on the hub cluster side.
1511+
ReportBackDestinationWorkAPI ReportBackDestination = "WorkAPI"
1512+
)
1513+
1514+
// ReportBackStrategy describes how to report back the resource status from member clusters.
1515+
type ReportBackStrategy struct {
1516+
// Type dictates the type of the report back strategy to use.
1517+
//
1518+
// Available options include:
1519+
//
1520+
// * Disabled: status back-reporting is disabled. This is the default behavior.
1521+
//
1522+
// * Mirror: status back-reporting is enabled by copying the status fields verbatim to
1523+
// a destination on the hub cluster side; see the Destination field for more information.
1524+
//
1525+
// +kubebuilder:default=Disabled
1526+
// +kubebuilder:validation:Enum=Disabled;Mirror
1527+
// +kubebuilder:validation:Required
1528+
Type ReportBackStrategyType `json:"type"`
1529+
1530+
// Destination dictates where to copy the status fields to when the report back strategy type is Mirror.
1531+
//
1532+
// Available options include:
1533+
//
1534+
// * OriginalResource: the status fields will be copied verbatim to the original resource on the hub cluster side.
1535+
// This is only performed when the placement object has a scheduling policy that selects exactly one member cluster
1536+
// (i.e., a pickFixed scheduling policy with exactly one cluster name, or a pickN scheduling policy with the numberOfClusters
1537+
// field set to 1).
1538+
//
1539+
// * WorkAPI: the status fields will be copied verbatim via the Work API on the hub cluster side. Users may look up
1540+
// the status of a specific resource applied to a specific member cluster by inspecting the corresponding Work object
1541+
// on the hub cluster side. This is the default behavior.
1542+
//
1543+
// +kubebuilder:validation:Enum=OriginalResource;WorkAPI
1544+
// +kubebuilder:validation:Optional
1545+
Destination *ReportBackDestination `json:"destination,omitempty"`
1546+
}
1547+
14831548
// ClusterResourcePlacementList contains a list of ClusterResourcePlacement.
14841549
// +kubebuilder:resource:scope="Cluster"
14851550
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

apis/placement/v1beta1/commons.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ const (
4747
ClusterStagedUpdateStrategyKind = "ClusterStagedUpdateStrategy"
4848
// ClusterApprovalRequestKind is the kind of the ClusterApprovalRequest.
4949
ClusterApprovalRequestKind = "ClusterApprovalRequest"
50+
// StagedUpdateRunKind is the kind of the StagedUpdateRun.
51+
StagedUpdateRunKind = "StagedUpdateRun"
52+
// StagedUpdateStrategyKind is the kind of the StagedUpdateStrategy.
53+
StagedUpdateStrategyKind = "StagedUpdateStrategy"
54+
// ApprovalRequestKind is the kind of the ApprovalRequest.
55+
ApprovalRequestKind = "ApprovalRequest"
5056
// ClusterResourcePlacementEvictionKind is the kind of the ClusterResourcePlacementEviction.
5157
ClusterResourcePlacementEvictionKind = "ClusterResourcePlacementEviction"
5258
// ClusterResourcePlacementDisruptionBudgetKind is the kind of the ClusterResourcePlacementDisruptionBudget.
@@ -145,9 +151,9 @@ const (
145151
// This is used to remember if an "unscheduled" binding was moved from a "bound" state or a "scheduled" state.
146152
PreviousBindingStateAnnotation = FleetPrefix + "previous-binding-state"
147153

148-
// ClusterStagedUpdateRunFinalizer is used by the ClusterStagedUpdateRun controller to make sure that the ClusterStagedUpdateRun
154+
// UpdateRunFinalizer is used by the UpdateRun controller to make sure that the UpdateRun
149155
// object is not deleted until all its dependent resources are deleted.
150-
ClusterStagedUpdateRunFinalizer = FleetPrefix + "stagedupdaterun-finalizer"
156+
UpdateRunFinalizer = FleetPrefix + "stagedupdaterun-finalizer"
151157

152158
// TargetUpdateRunLabel indicates the target update run on a staged run related object.
153159
TargetUpdateRunLabel = FleetPrefix + "targetupdaterun"

0 commit comments

Comments
 (0)