Skip to content

Commit eea6d33

Browse files
authored
Merge branch 'kubernetes-sigs:main' into main
2 parents 0159fc5 + 08b15d9 commit eea6d33

File tree

171 files changed

+14402
-3488
lines changed

Some content is hidden

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

171 files changed

+14402
-3488
lines changed

.golangci-kal.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ linters:
1818
- "conditions" # Ensure conditions have the correct json tags and markers.
1919
- "conflictingmarkers"
2020
- "duplicatemarkers" # Ensure there are no exact duplicate markers. for types and fields.
21-
#- "forbiddenmarkers" # Ensure that types and fields do not contain any markers that are forbidden.
21+
- "forbiddenmarkers" # Ensure that types and fields do not contain any markers that are forbidden.
2222
- "integers" # Ensure only int32 and int64 are used for integers.
2323
- "jsontags" # Ensure every field has a json tag.
2424
- "maxlength" # Ensure all strings and arrays have maximum lengths/maximum items.
@@ -53,6 +53,12 @@ linters:
5353
- ["default", "kubebuilder:default"]
5454
- ["required", "kubebuilder:validation:Required", "k8s:required"]
5555
description: "A field with a default value cannot be required"
56+
forbiddenmarkers:
57+
markers:
58+
# We don't want to do any defaulting (including OpenAPI) anymore on API fields because we prefer
59+
# to have a clear signal on user intent. This also allows us to easily change the default behavior if necessary.
60+
- identifier: "kubebuilder:default"
61+
- identifier: "default"
5662
conditions:
5763
isFirstField: Warn # Require conditions to be the first field in the status struct.
5864
usePatchStrategy: Forbid # Forbid patchStrategy markers on the Conditions field.
@@ -158,6 +164,16 @@ linters:
158164
linters:
159165
- kubeapilinter
160166

167+
# Excludes for existing default markers
168+
- path: "api/core/v1beta2/clusterclass_types.go"
169+
text: 'forbiddenmarkers: field Reason has forbidden marker "kubebuilder:default=FieldValueInvalid"'
170+
linters:
171+
- kubeapilinter
172+
- path: "api/core/v1beta2/clusterclass_types.go"
173+
text: 'forbiddenmarkers: field Reason has forbidden marker "default=ref\(sigs.k8s.io/cluster-api/api/core/v1beta2.FieldValueInvalid\)"'
174+
linters:
175+
- kubeapilinter
176+
161177
# TODO: Excludes that should be removed once the corresponding issues in KAL are fixed
162178
# KAL incorrectly reports that the Taints field doesn't have to be a pointer (it has to be to preserve []).
163179
# See: https://github.com/kubernetes-sigs/kube-api-linter/issues/116

Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ SHELL:=/usr/bin/env bash
2323
#
2424
# Go.
2525
#
26-
GO_VERSION ?= 1.24.8
26+
GO_VERSION ?= 1.24.9
2727
GO_DIRECTIVE_VERSION ?= 1.24.0
2828
GO_CONTAINER_IMAGE ?= docker.io/library/golang:$(GO_VERSION)
2929

@@ -943,9 +943,16 @@ test-infrastructure: $(SETUP_ENVTEST) ## Run unit and integration tests with rac
943943
# Note: Fuzz tests are not executed with race detector because they would just time out.
944944
# To achieve that, all files with fuzz tests have the "!race" build tag, to still run fuzz tests
945945
# we have an additional `go test` run that focuses on "TestFuzzyConversion".
946-
cd test/infrastructure; KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./... $(TEST_ARGS)
946+
cd test/infrastructure; KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -race ./... $(TEST_ARGS)
947947
$(MAKE) test-infrastructure-conversions TEST_ARGS="$(TEST_ARGS)"
948948

949+
.PHONY: test-infrastructure-no-race
950+
test-infrastructure-no-race: $(SETUP_ENVTEST) ## Run unit and integration tests with no race detector for docker infrastructure provider
951+
# Note: Fuzz tests are not executed with race detector because they would just time out.
952+
# To achieve that, all files with fuzz tests have the "!race" build tag, to still run fuzz tests
953+
# we have an additional `go test` run that focuses on "TestFuzzyConversion".
954+
cd test/infrastructure; KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./... $(TEST_ARGS)
955+
949956
.PHONY: test-infrastructure-conversions
950957
test-infrastructure-conversions: $(SETUP_ENVTEST) ## Run conversions test for docker infrastructure provider
951958
cd test/infrastructure; KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -run "^TestFuzzyConversion$$" ./... $(TEST_ARGS)
@@ -956,7 +963,7 @@ test-infrastructure-verbose: ## Run unit and integration tests with race detecto
956963

957964
.PHONY: test-infrastructure-junit
958965
test-infrastructure-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run unit and integration tests with race detector and generate a junit report for docker infrastructure provider
959-
cd test/infrastructure; set +o errexit; (KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -json ./... $(TEST_ARGS); echo $$? > $(ARTIFACTS)/junit.infra_docker.exitcode) | tee $(ARTIFACTS)/junit.infra_docker.stdout
966+
cd test/infrastructure; set +o errexit; (KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -race -json ./... $(TEST_ARGS); echo $$? > $(ARTIFACTS)/junit.infra_docker.exitcode) | tee $(ARTIFACTS)/junit.infra_docker.stdout
960967
$(GOTESTSUM) --junitfile $(ARTIFACTS)/junit.infra_docker.xml --raw-command cat $(ARTIFACTS)/junit.infra_docker.stdout
961968
exit $$(cat $(ARTIFACTS)/junit.infra_docker.exitcode)
962969
cd test/infrastructure; set +o errexit; (KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -run "^TestFuzzyConversion$$" -json ./... $(TEST_ARGS); echo $$? > $(ARTIFACTS)/junit-fuzz.infra_docker.exitcode) | tee $(ARTIFACTS)/junit-fuzz.infra_docker.stdout

Tiltfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def load_provider_tilt_files():
172172

173173
tilt_helper_dockerfile_header = """
174174
# Tilt image
175-
FROM golang:1.24.8 as tilt-helper
175+
FROM golang:1.24.9 as tilt-helper
176176
# Install delve. Note this should be kept in step with the Go release minor version.
177177
RUN go install github.com/go-delve/delve/cmd/dlv@v1.24
178178
# Support live reloading with Tilt
@@ -183,7 +183,7 @@ RUN wget --output-document /restart.sh --quiet https://raw.githubusercontent.com
183183
"""
184184

185185
tilt_dockerfile_header = """
186-
FROM golang:1.24.8 as tilt
186+
FROM golang:1.24.9 as tilt
187187
WORKDIR /
188188
COPY --from=tilt-helper /process.txt .
189189
COPY --from=tilt-helper /start.sh .

api/core/v1beta1/conversion.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ func (src *Cluster) ConvertTo(dstRaw conversion.Hub) error {
7373
return err
7474
}
7575

76+
dst.Spec.Topology.ControlPlane.HealthCheck.Checks.UnhealthyMachineConditions = restored.Spec.Topology.ControlPlane.HealthCheck.Checks.UnhealthyMachineConditions
77+
for i, md := range restored.Spec.Topology.Workers.MachineDeployments {
78+
dst.Spec.Topology.Workers.MachineDeployments[i].HealthCheck.Checks.UnhealthyMachineConditions = md.HealthCheck.Checks.UnhealthyMachineConditions
79+
}
80+
7681
// Recover intent for bool values converted to *bool.
7782
clusterv1.Convert_bool_To_Pointer_bool(src.Spec.Paused, ok, restored.Spec.Paused, &dst.Spec.Paused)
7883

@@ -145,6 +150,11 @@ func (src *ClusterClass) ConvertTo(dstRaw conversion.Hub) error {
145150
return err
146151
}
147152

153+
dst.Spec.ControlPlane.HealthCheck.Checks.UnhealthyMachineConditions = restored.Spec.ControlPlane.HealthCheck.Checks.UnhealthyMachineConditions
154+
for i, md := range restored.Spec.Workers.MachineDeployments {
155+
dst.Spec.Workers.MachineDeployments[i].HealthCheck.Checks.UnhealthyMachineConditions = md.HealthCheck.Checks.UnhealthyMachineConditions
156+
}
157+
148158
// Recover intent for bool values converted to *bool.
149159
for i, patch := range dst.Spec.Patches {
150160
for j, definition := range patch.Definitions {
@@ -513,6 +523,8 @@ func (src *MachineHealthCheck) ConvertTo(dstRaw conversion.Hub) error {
513523
return err
514524
}
515525

526+
dst.Spec.Checks.UnhealthyMachineConditions = restored.Spec.Checks.UnhealthyMachineConditions
527+
516528
clusterv1.Convert_int32_To_Pointer_int32(src.Status.ExpectedMachines, ok, restored.Status.ExpectedMachines, &dst.Status.ExpectedMachines)
517529
clusterv1.Convert_int32_To_Pointer_int32(src.Status.CurrentHealthy, ok, restored.Status.CurrentHealthy, &dst.Status.CurrentHealthy)
518530
clusterv1.Convert_int32_To_Pointer_int32(src.Status.RemediationsAllowed, ok, restored.Status.RemediationsAllowed, &dst.Status.RemediationsAllowed)

api/core/v1beta2/cluster_types.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,16 @@ type ControlPlaneTopologyHealthCheckChecks struct {
725725
// +kubebuilder:validation:MinItems=1
726726
// +kubebuilder:validation:MaxItems=100
727727
UnhealthyNodeConditions []UnhealthyNodeCondition `json:"unhealthyNodeConditions,omitempty"`
728+
729+
// unhealthyMachineConditions contains a list of the machine conditions that determine
730+
// whether a machine is considered unhealthy. The conditions are combined in a
731+
// logical OR, i.e. if any of the conditions is met, the machine is unhealthy.
732+
//
733+
// +optional
734+
// +listType=atomic
735+
// +kubebuilder:validation:MinItems=1
736+
// +kubebuilder:validation:MaxItems=100
737+
UnhealthyMachineConditions []UnhealthyMachineCondition `json:"unhealthyMachineConditions,omitempty"`
728738
}
729739

730740
// ControlPlaneTopologyHealthCheckRemediation configures if and how remediations are triggered if a control plane Machine is unhealthy.
@@ -975,6 +985,16 @@ type MachineDeploymentTopologyHealthCheckChecks struct {
975985
// +kubebuilder:validation:MinItems=1
976986
// +kubebuilder:validation:MaxItems=100
977987
UnhealthyNodeConditions []UnhealthyNodeCondition `json:"unhealthyNodeConditions,omitempty"`
988+
989+
// unhealthyMachineConditions contains a list of the machine conditions that determine
990+
// whether a machine is considered unhealthy. The conditions are combined in a
991+
// logical OR, i.e. if any of the conditions is met, the machine is unhealthy.
992+
//
993+
// +optional
994+
// +listType=atomic
995+
// +kubebuilder:validation:MinItems=1
996+
// +kubebuilder:validation:MaxItems=100
997+
UnhealthyMachineConditions []UnhealthyMachineCondition `json:"unhealthyMachineConditions,omitempty"`
978998
}
979999

9801000
// MachineDeploymentTopologyHealthCheckRemediation configures if and how remediations are triggered if a MachineDeployment Machine is unhealthy.

api/core/v1beta2/clusterclass_types.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,16 @@ type ControlPlaneClassHealthCheckChecks struct {
281281
// +kubebuilder:validation:MinItems=1
282282
// +kubebuilder:validation:MaxItems=100
283283
UnhealthyNodeConditions []UnhealthyNodeCondition `json:"unhealthyNodeConditions,omitempty"`
284+
285+
// unhealthyMachineConditions contains a list of the machine conditions that determine
286+
// whether a machine is considered unhealthy. The conditions are combined in a
287+
// logical OR, i.e. if any of the conditions is met, the machine is unhealthy.
288+
//
289+
// +optional
290+
// +listType=atomic
291+
// +kubebuilder:validation:MinItems=1
292+
// +kubebuilder:validation:MaxItems=100
293+
UnhealthyMachineConditions []UnhealthyMachineCondition `json:"unhealthyMachineConditions,omitempty"`
284294
}
285295

286296
// ControlPlaneClassHealthCheckRemediation configures if and how remediations are triggered if a control plane Machine is unhealthy.
@@ -542,6 +552,16 @@ type MachineDeploymentClassHealthCheckChecks struct {
542552
// +kubebuilder:validation:MinItems=1
543553
// +kubebuilder:validation:MaxItems=100
544554
UnhealthyNodeConditions []UnhealthyNodeCondition `json:"unhealthyNodeConditions,omitempty"`
555+
556+
// unhealthyMachineConditions contains a list of the machine conditions that determine
557+
// whether a machine is considered unhealthy. The conditions are combined in a
558+
// logical OR, i.e. if any of the conditions is met, the machine is unhealthy.
559+
//
560+
// +optional
561+
// +listType=atomic
562+
// +kubebuilder:validation:MinItems=1
563+
// +kubebuilder:validation:MaxItems=100
564+
UnhealthyMachineConditions []UnhealthyMachineCondition `json:"unhealthyMachineConditions,omitempty"`
545565
}
546566

547567
// MachineDeploymentClassHealthCheckRemediation configures if and how remediations are triggered if a MachineDeployment Machine is unhealthy.

api/core/v1beta2/machine_types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ const (
8787

8888
// ManagedNodeAnnotationDomain is one of the CAPI managed Node annotation domains.
8989
ManagedNodeAnnotationDomain = "node.cluster.x-k8s.io"
90+
91+
// PendingAcknowledgeMoveAnnotation is an internal annotation added by the MS controller to a machine when being
92+
// moved from the oldMS to the newMS. The annotation is removed as soon as the MS controller get the acknowledgment about the
93+
// replica being accounted from the corresponding MD.
94+
// Note: The annotation is added when reconciling the oldMS, and it is removed when reconciling the newMS.
95+
// Note: This annotation is used in pair with AcknowledgedMoveAnnotation on MachineSets.
96+
PendingAcknowledgeMoveAnnotation = "in-place-updates.internal.cluster.x-k8s.io/pending-acknowledge-move"
97+
98+
// UpdateInProgressAnnotation is an internal annotation added to machines by the controller owning the Machine when in-place update
99+
// is started, e.g. by the MachineSet controller; the annotation will be removed by the Machine controller when in-place update is completed.
100+
UpdateInProgressAnnotation = "in-place-updates.internal.cluster.x-k8s.io/update-in-progress"
90101
)
91102

92103
// Machine's Available condition and corresponding reasons.
@@ -276,6 +287,10 @@ const (
276287
// defined by a MachineHealthCheck object.
277288
MachineHealthCheckUnhealthyNodeReason = "UnhealthyNode"
278289

290+
// MachineHealthCheckUnhealthyMachineReason surfaces when the machine does not pass the health checks
291+
// defined by a MachineHealthCheck object.
292+
MachineHealthCheckUnhealthyMachineReason = "UnhealthyMachine"
293+
279294
// MachineHealthCheckNodeStartupTimeoutReason surfaces when the node hosted on the machine does not appear within
280295
// the timeout defined by a MachineHealthCheck object.
281296
MachineHealthCheckNodeStartupTimeoutReason = "NodeStartupTimeout"

api/core/v1beta2/machinehealthcheck_types.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ type MachineHealthCheckChecks struct {
111111
// +kubebuilder:validation:MinItems=1
112112
// +kubebuilder:validation:MaxItems=100
113113
UnhealthyNodeConditions []UnhealthyNodeCondition `json:"unhealthyNodeConditions,omitempty"`
114+
115+
// unhealthyMachineConditions contains a list of the machine conditions that determine
116+
// whether a machine is considered unhealthy. The conditions are combined in a
117+
// logical OR, i.e. if any of the conditions is met, the machine is unhealthy.
118+
//
119+
// +optional
120+
// +listType=atomic
121+
// +kubebuilder:validation:MinItems=1
122+
// +kubebuilder:validation:MaxItems=100
123+
UnhealthyMachineConditions []UnhealthyMachineCondition `json:"unhealthyMachineConditions,omitempty"`
114124
}
115125

116126
// MachineHealthCheckRemediation configures if and how remediations are triggered if a Machine is unhealthy.
@@ -227,7 +237,33 @@ type UnhealthyNodeCondition struct {
227237

228238
// timeoutSeconds is the duration that a node must be in a given status for,
229239
// after which the node is considered unhealthy.
230-
// For example, with a value of "1h", the node must match the status
240+
// For example, with a value of "3600", the node must match the status
241+
// for at least 1 hour before being considered unhealthy.
242+
// +required
243+
// +kubebuilder:validation:Minimum=0
244+
TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"`
245+
}
246+
247+
// UnhealthyMachineCondition represents a Machine condition type and value with a timeout
248+
// specified as a duration. When the named condition has been in the given
249+
// status for at least the timeout value, a machine is considered unhealthy.
250+
type UnhealthyMachineCondition struct {
251+
// type of Machine condition
252+
// +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$`
253+
// +kubebuilder:validation:MinLength=1
254+
// +kubebuilder:validation:MaxLength=316
255+
// +kubebuilder:validation:XValidation:rule="!(self in ['Ready','Available','HealthCheckSucceeded','OwnerRemediated','ExternallyRemediated'])",message="type must not be one of: Ready, Available, HealthCheckSucceeded, OwnerRemediated, ExternallyRemediated"
256+
// +required
257+
Type string `json:"type,omitempty"`
258+
259+
// status of the condition, one of True, False, Unknown.
260+
// +required
261+
// +kubebuilder:validation:Enum=True;False;Unknown
262+
Status metav1.ConditionStatus `json:"status,omitempty"`
263+
264+
// timeoutSeconds is the duration that a machine must be in a given status for,
265+
// after which the machine is considered unhealthy.
266+
// For example, with a value of "3600", the machine must match the status
231267
// for at least 1 hour before being considered unhealthy.
232268
// +required
233269
// +kubebuilder:validation:Minimum=0

api/core/v1beta2/machineset_types.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@ const (
3333
// MachineSetFinalizer is the finalizer used by the MachineSet controller to
3434
// ensure ordered cleanup of corresponding Machines when a Machineset is being deleted.
3535
MachineSetFinalizer = "cluster.x-k8s.io/machineset"
36+
37+
// MachineSetMoveMachinesToMachineSetAnnotation is an internal annotation added by the MD controller to the oldMS
38+
// when it should scale down by moving machines that can be updated in-place to the newMS instead of deleting them.
39+
// The annotation value is the newMS name.
40+
// Note: This annotation is used in pair with MachineSetReceiveMachinesFromMachineSetsAnnotation to perform a two-ways check before moving a machine from oldMS to newMS:
41+
//
42+
// "oldMS must have: move to newMS" and "newMS must have: receive replicas from oldMS"
43+
MachineSetMoveMachinesToMachineSetAnnotation = "in-place-updates.internal.cluster.x-k8s.io/move-machines-to-machineset"
44+
45+
// MachineSetReceiveMachinesFromMachineSetsAnnotation is an internal annotation added by the MD controller to the newMS
46+
// when it should receive replicas from oldMSs as a first step of an in-place upgrade operation
47+
// The annotation value is a comma separated list of oldMSs.
48+
// Note: This annotation is used in pair with MachineSetMoveMachinesToMachineSetAnnotation to perform a two-ways check before moving a machine from oldMS to newMS:
49+
//
50+
// "oldMS must have: move to newMS" and "newMS must have: receive replicas from oldMS"
51+
MachineSetReceiveMachinesFromMachineSetsAnnotation = "in-place-updates.internal.cluster.x-k8s.io/receive-machines-from-machinesets"
52+
53+
// AcknowledgedMoveAnnotation is an internal annotation with a list of machines added by the MD controller
54+
// to a MachineSet when it acknowledges a machine pending acknowledge after being moved from an oldMS.
55+
// The annotation value is a comma separated list of Machines already acknowledged; a machine is dropped
56+
// from this annotation as soon as pending-acknowledge-move is removed from the machine; the annotation is dropped when empty.
57+
// Note: This annotation is used in pair with PendingAcknowledgeMoveAnnotation on Machines.
58+
AcknowledgedMoveAnnotation = "in-place-updates.internal.cluster.x-k8s.io/acknowledged-move"
3659
)
3760

3861
// MachineSetSpec defines the desired state of MachineSet.

api/core/v1beta2/v1beta1_condition_consts.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ const (
157157

158158
// UnhealthyNodeConditionV1Beta1Reason is the reason used when a machine's node has one of the MachineHealthCheck's unhealthy conditions.
159159
UnhealthyNodeConditionV1Beta1Reason = "UnhealthyNode"
160+
161+
// UnhealthyMachineConditionV1Beta1Reason is the reason used when a machine has one of the MachineHealthCheck's unhealthy conditions.
162+
// When both machine and node issues are detected, this reason takes precedence over node-related reasons
163+
// (NodeNotFoundV1Beta1Reason, NodeStartupTimeoutV1Beta1Reason, UnhealthyNodeConditionV1Beta1Reason).
164+
UnhealthyMachineConditionV1Beta1Reason = "UnhealthyMachine"
160165
)
161166

162167
const (

0 commit comments

Comments
 (0)