Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Satisfy fake clients requirement of finalizers with DeletionTimeStamp
Fake client won't create objects after kubernetes-sigs/controller-runtime#2316 if they have DeletionTimeStamp without finalizers

Signed-off-by: Waleed Malik <[email protected]>
  • Loading branch information
ahmedwaleedmalik committed Aug 16, 2023
commit 6eafbb2eef05f6661f37cdc14d5395281172b53b
8 changes: 8 additions & 0 deletions pkg/controller/machine/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ func TestController_GetNode(t *testing.T) {
}
client := fakectrlruntimeclient.NewClientBuilder().
WithScheme(scheme.Scheme).
WithObjects(nodes...).
Build()

reconciler := Reconciler{client: client}
Expand Down Expand Up @@ -334,6 +335,7 @@ func durationPtr(d time.Duration) *time.Duration {
func TestControllerShouldEvict(t *testing.T) {
threeHoursAgo := metav1.NewTime(time.Now().Add(-3 * time.Hour))
now := metav1.Now()
finalizer := "test"

tests := []struct {
name string
Expand All @@ -353,6 +355,7 @@ func TestControllerShouldEvict(t *testing.T) {
machine: &clusterv1alpha1.Machine{
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: &threeHoursAgo,
Finalizers: []string{finalizer},
},
Status: clusterv1alpha1.MachineStatus{
NodeRef: &corev1.ObjectReference{Name: "existing-node"},
Expand All @@ -365,6 +368,7 @@ func TestControllerShouldEvict(t *testing.T) {
machine: &clusterv1alpha1.Machine{
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: &now,
Finalizers: []string{finalizer},
},
Status: clusterv1alpha1.MachineStatus{
NodeRef: nil,
Expand All @@ -377,6 +381,7 @@ func TestControllerShouldEvict(t *testing.T) {
machine: &clusterv1alpha1.Machine{
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: &now,
Finalizers: []string{finalizer},
},
Status: clusterv1alpha1.MachineStatus{
NodeRef: &corev1.ObjectReference{Name: "non-existing-node"},
Expand All @@ -393,6 +398,7 @@ func TestControllerShouldEvict(t *testing.T) {
machine: &clusterv1alpha1.Machine{
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: &now,
Finalizers: []string{finalizer},
},
Status: clusterv1alpha1.MachineStatus{
NodeRef: &corev1.ObjectReference{Name: "existing-node"},
Expand All @@ -413,6 +419,7 @@ func TestControllerShouldEvict(t *testing.T) {
machine: &clusterv1alpha1.Machine{
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: &now,
Finalizers: []string{finalizer},
},
Status: clusterv1alpha1.MachineStatus{
NodeRef: &corev1.ObjectReference{Name: "existing-node"},
Expand All @@ -433,6 +440,7 @@ func TestControllerShouldEvict(t *testing.T) {
machine: &clusterv1alpha1.Machine{
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: &now,
Finalizers: []string{finalizer},
},
Status: clusterv1alpha1.MachineStatus{
NodeRef: &corev1.ObjectReference{Name: "existing-node"},
Expand Down