Skip to content

Commit d1e5173

Browse files
committed
Change LastRemediationStatus.RetryCount from int32 to *int32
1 parent 7738bdf commit d1e5173

File tree

7 files changed

+22
-7
lines changed

7 files changed

+22
-7
lines changed

api/controlplane/kubeadm/v1beta1/conversion_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ func hubKubeadmControlPlaneStatus(in *controlplanev1.KubeadmControlPlaneStatus,
245245
if in.Replicas == nil {
246246
in.Replicas = ptr.To(int32(0))
247247
}
248+
249+
if in.LastRemediation.RetryCount == nil {
250+
in.LastRemediation.RetryCount = ptr.To(int32(0)) // RetryCount is a required field and nil does not round trip
251+
}
248252
}
249253

250254
func spokeKubeadmControlPlaneStatus(in *KubeadmControlPlaneStatus, c randfill.Continue) {

api/controlplane/kubeadm/v1beta1/zz_generated.conversion.go

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/controlplane/kubeadm/v1beta2/kubeadm_control_plane_types.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,8 @@ type LastRemediationStatus struct {
814814
// retryCount used to keep track of remediation retry for the last remediated machine.
815815
// A retry happens when a machine that was created as a replacement for an unhealthy machine also fails.
816816
// +required
817-
RetryCount int32 `json:"retryCount"`
817+
// +kubebuilder:validation:Minimum=0
818+
RetryCount *int32 `json:"retryCount,omitempty"`
818819
}
819820

820821
// +kubebuilder:object:root=true

api/controlplane/kubeadm/v1beta2/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/kubeadm/config/crd/bases/controlplane.cluster.x-k8s.io_kubeadmcontrolplanes.yaml

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

controlplane/kubeadm/internal/controllers/remediation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ type RemediationData struct {
668668
Machine string `json:"machine"`
669669

670670
// timestamp is when last remediation happened. It is represented in RFC3339 form and is in UTC.
671-
Timestamp metav1.Time `json:"timestamp,omitempty,omitzero"`
671+
Timestamp metav1.Time `json:"timestamp"`
672672

673673
// retryCount used to keep track of remediation retry for the last remediated machine.
674674
// A retry happens when a machine that was created as a replacement for an unhealthy machine also fails.
@@ -698,6 +698,6 @@ func (r *RemediationData) ToStatus() controlplanev1.LastRemediationStatus {
698698
return controlplanev1.LastRemediationStatus{
699699
Machine: r.Machine,
700700
Time: r.Timestamp,
701-
RetryCount: int32(r.RetryCount),
701+
RetryCount: ptr.To(int32(r.RetryCount)),
702702
}
703703
}

controlplane/kubeadm/internal/controllers/status_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,7 @@ func TestKubeadmControlPlaneReconciler_setLastRemediation(t *testing.T) {
20772077

20782078
g.Expect(controlPlane.KCP.Status.LastRemediation.Machine).To(Equal(r1.Machine))
20792079
g.Expect(controlPlane.KCP.Status.LastRemediation.Time.Time).To(BeTemporally("==", r1.Timestamp.Time), cmp.Diff(controlPlane.KCP.Status.LastRemediation.Time.Time, r1.Timestamp.Time))
2080-
g.Expect(controlPlane.KCP.Status.LastRemediation.RetryCount).To(Equal(int32(r1.RetryCount)))
2080+
g.Expect(*controlPlane.KCP.Status.LastRemediation.RetryCount).To(Equal(int32(r1.RetryCount)))
20812081
})
20822082
t.Run("Remediation completed, get data from past remediation", func(t *testing.T) {
20832083
g := NewWithT(t)
@@ -2108,7 +2108,7 @@ func TestKubeadmControlPlaneReconciler_setLastRemediation(t *testing.T) {
21082108

21092109
g.Expect(controlPlane.KCP.Status.LastRemediation.Machine).To(Equal(r2.Machine))
21102110
g.Expect(controlPlane.KCP.Status.LastRemediation.Time.Time).To(BeTemporally("==", r2.Timestamp.Time), cmp.Diff(controlPlane.KCP.Status.LastRemediation.Time.Time, r2.Timestamp.Time))
2111-
g.Expect(controlPlane.KCP.Status.LastRemediation.RetryCount).To(Equal(int32(r2.RetryCount)))
2111+
g.Expect(*controlPlane.KCP.Status.LastRemediation.RetryCount).To(Equal(int32(r2.RetryCount)))
21122112
})
21132113
}
21142114

0 commit comments

Comments
 (0)