Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions api/controlplane/kubeadm/v1beta1/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,22 @@ func Convert_v1beta2_ContractVersionedObjectReference_To_v1_ObjectReference(_ *c
return nil
}

func Convert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus(in *LastRemediationStatus, out *controlplanev1.LastRemediationStatus, s apimachineryconversion.Scope) error {
if err := autoConvert_v1beta1_LastRemediationStatus_To_v1beta2_LastRemediationStatus(in, out, s); err != nil {
return err
}
out.Time = in.Timestamp
return nil
}

func Convert_v1beta2_LastRemediationStatus_To_v1beta1_LastRemediationStatus(in *controlplanev1.LastRemediationStatus, out *LastRemediationStatus, s apimachineryconversion.Scope) error {
if err := autoConvert_v1beta2_LastRemediationStatus_To_v1beta1_LastRemediationStatus(in, out, s); err != nil {
return err
}
out.Timestamp = in.Time
return nil
}

func convertToContractVersionedObjectReference(ref *corev1.ObjectReference) (*clusterv1.ContractVersionedObjectReference, error) {
var apiGroup string
if ref.APIVersion != "" {
Expand Down
54 changes: 30 additions & 24 deletions api/controlplane/kubeadm/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,9 @@ type LastRemediationStatus struct {
// +kubebuilder:validation:MaxLength=253
Machine string `json:"machine"`

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

// retryCount used to keep track of remediation retry for the last remediated machine.
// A retry happens when a machine that was created as a replacement for an unhealthy machine also fails.
Expand Down
2 changes: 1 addition & 1 deletion api/controlplane/kubeadm/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions controlplane/kubeadm/internal/controllers/remediation.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ func (r *KubeadmControlPlaneReconciler) checkRetryLimits(log logr.Logger, machin
// Once we get here we already know that there was a last remediation for the Machine.
// If the current remediation is happening before minHealthyPeriod is expired, then KCP considers this
// as a remediation for the same previously unhealthy machine.
// NOTE: If someone/something changes the RemediationForAnnotation on Machines (e.g. changes the Timestamp),
// NOTE: If someone/something changes the RemediationForAnnotation on Machines (e.g. changes the lastRemediation time),
// this could potentially lead to executing more retries than expected, but this is considered acceptable in such a case.
var retryForSameMachineInProgress bool
if lastRemediationTime.Add(minHealthyPeriod).After(reconciliationTime) {
Expand Down Expand Up @@ -700,7 +700,7 @@ func (r *RemediationData) Marshal() (string, error) {
func (r *RemediationData) ToStatus() *controlplanev1.LastRemediationStatus {
return &controlplanev1.LastRemediationStatus{
Machine: r.Machine,
Timestamp: r.Timestamp,
Time: r.Timestamp,
RetryCount: int32(r.RetryCount),
}
}
4 changes: 2 additions & 2 deletions controlplane/kubeadm/internal/controllers/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2053,7 +2053,7 @@ func TestKubeadmControlPlaneReconciler_setLastRemediation(t *testing.T) {

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

g.Expect(controlPlane.KCP.Status.LastRemediation).ToNot(BeNil())
g.Expect(controlPlane.KCP.Status.LastRemediation.Machine).To(Equal(r2.Machine))
g.Expect(controlPlane.KCP.Status.LastRemediation.Timestamp.Time).To(BeTemporally("==", r2.Timestamp.Time), cmp.Diff(controlPlane.KCP.Status.LastRemediation.Timestamp.Time, r2.Timestamp.Time))
g.Expect(controlPlane.KCP.Status.LastRemediation.Time.Time).To(BeTemporally("==", r2.Timestamp.Time), cmp.Diff(controlPlane.KCP.Status.LastRemediation.Time.Time, r2.Timestamp.Time))
g.Expect(controlPlane.KCP.Status.LastRemediation.RetryCount).To(Equal(int32(r2.RetryCount)))
})
}
Expand Down