Skip to content

Commit 7411836

Browse files
authored
Merge pull request #12452 from sbueringer/pr-kcp-time-rename
⚠️ Rename LastRemediationStatus.Timestamp to Time in KCP
2 parents 07f2337 + 2e7b335 commit 7411836

File tree

7 files changed

+57
-35
lines changed

7 files changed

+57
-35
lines changed

api/controlplane/kubeadm/v1beta1/conversion.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,22 @@ func Convert_v1beta2_ContractVersionedObjectReference_To_v1_ObjectReference(_ *c
352352
return nil
353353
}
354354

355+
func Convert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus(in *LastRemediationStatus, out *controlplanev1.LastRemediationStatus, s apimachineryconversion.Scope) error {
356+
if err := autoConvert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus(in, out, s); err != nil {
357+
return err
358+
}
359+
out.Time = in.Timestamp
360+
return nil
361+
}
362+
363+
func Convert_v1beta2_LastRemediationStatus_To_v1beta1_LastRemediationStatus(in *controlplanev1.LastRemediationStatus, out *LastRemediationStatus, s apimachineryconversion.Scope) error {
364+
if err := autoConvert_v1beta2_LastRemediationStatus_To_v1beta1_LastRemediationStatus(in, out, s); err != nil {
365+
return err
366+
}
367+
out.Timestamp = in.Time
368+
return nil
369+
}
370+
355371
func convertToContractVersionedObjectReference(ref *corev1.ObjectReference) (*clusterv1.ContractVersionedObjectReference, error) {
356372
var apiGroup string
357373
if ref.APIVersion != "" {

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

Lines changed: 30 additions & 24 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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,9 +772,9 @@ type LastRemediationStatus struct {
772772
// +kubebuilder:validation:MaxLength=253
773773
Machine string `json:"machine"`
774774

775-
// timestamp is when last remediation happened. It is represented in RFC3339 form and is in UTC.
775+
// time is when last remediation happened. It is represented in RFC3339 form and is in UTC.
776776
// +required
777-
Timestamp metav1.Time `json:"timestamp"`
777+
Time metav1.Time `json:"time"`
778778

779779
// retryCount used to keep track of remediation retry for the last remediated machine.
780780
// A retry happens when a machine that was created as a replacement for an unhealthy machine also fails.

api/controlplane/kubeadm/v1beta2/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.

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

Lines changed: 4 additions & 4 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
@@ -514,7 +514,7 @@ func (r *KubeadmControlPlaneReconciler) checkRetryLimits(log logr.Logger, machin
514514
// Once we get here we already know that there was a last remediation for the Machine.
515515
// If the current remediation is happening before minHealthyPeriod is expired, then KCP considers this
516516
// as a remediation for the same previously unhealthy machine.
517-
// NOTE: If someone/something changes the RemediationForAnnotation on Machines (e.g. changes the Timestamp),
517+
// NOTE: If someone/something changes the RemediationForAnnotation on Machines (e.g. changes the lastRemediation time),
518518
// this could potentially lead to executing more retries than expected, but this is considered acceptable in such a case.
519519
var retryForSameMachineInProgress bool
520520
if lastRemediationTime.Add(minHealthyPeriod).After(reconciliationTime) {
@@ -700,7 +700,7 @@ func (r *RemediationData) Marshal() (string, error) {
700700
func (r *RemediationData) ToStatus() *controlplanev1.LastRemediationStatus {
701701
return &controlplanev1.LastRemediationStatus{
702702
Machine: r.Machine,
703-
Timestamp: r.Timestamp,
703+
Time: r.Timestamp,
704704
RetryCount: int32(r.RetryCount),
705705
}
706706
}

controlplane/kubeadm/internal/controllers/status_test.go

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

20542054
g.Expect(controlPlane.KCP.Status.LastRemediation).ToNot(BeNil())
20552055
g.Expect(controlPlane.KCP.Status.LastRemediation.Machine).To(Equal(r1.Machine))
2056-
g.Expect(controlPlane.KCP.Status.LastRemediation.Timestamp.Time).To(BeTemporally("==", r1.Timestamp.Time), cmp.Diff(controlPlane.KCP.Status.LastRemediation.Timestamp.Time, r1.Timestamp.Time))
2056+
g.Expect(controlPlane.KCP.Status.LastRemediation.Time.Time).To(BeTemporally("==", r1.Timestamp.Time), cmp.Diff(controlPlane.KCP.Status.LastRemediation.Time.Time, r1.Timestamp.Time))
20572057
g.Expect(controlPlane.KCP.Status.LastRemediation.RetryCount).To(Equal(int32(r1.RetryCount)))
20582058
})
20592059
t.Run("Remediation completed, get data from past remediation", func(t *testing.T) {
@@ -2085,7 +2085,7 @@ func TestKubeadmControlPlaneReconciler_setLastRemediation(t *testing.T) {
20852085

20862086
g.Expect(controlPlane.KCP.Status.LastRemediation).ToNot(BeNil())
20872087
g.Expect(controlPlane.KCP.Status.LastRemediation.Machine).To(Equal(r2.Machine))
2088-
g.Expect(controlPlane.KCP.Status.LastRemediation.Timestamp.Time).To(BeTemporally("==", r2.Timestamp.Time), cmp.Diff(controlPlane.KCP.Status.LastRemediation.Timestamp.Time, r2.Timestamp.Time))
2088+
g.Expect(controlPlane.KCP.Status.LastRemediation.Time.Time).To(BeTemporally("==", r2.Timestamp.Time), cmp.Diff(controlPlane.KCP.Status.LastRemediation.Time.Time, r2.Timestamp.Time))
20892089
g.Expect(controlPlane.KCP.Status.LastRemediation.RetryCount).To(Equal(int32(r2.RetryCount)))
20902090
})
20912091
}

0 commit comments

Comments
 (0)