Skip to content

Commit 0738a91

Browse files
committed
Fix incorrect machineinformer callback
1 parent 52f840e commit 0738a91

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

pkg/controller/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func NewController(
125125
// MachineDeployment Controller Informers
126126
_, _ = machineInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
127127
UpdateFunc: controller.updateMachineToMachineDeployment,
128-
DeleteFunc: controller.deleteMachineDeployment,
128+
DeleteFunc: controller.deleteMachineToMachineDeployment,
129129
})
130130

131131
_, _ = machineSetInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{

pkg/controller/deployment.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (dc *controller) deleteMachineDeployment(obj interface{}) {
7575
}
7676
d, ok = tombstone.Obj.(*v1alpha1.MachineDeployment)
7777
if !ok {
78-
utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a Machine Deployment %#v", obj))
78+
utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a MachineDeployment %#v", obj))
7979
return
8080
}
8181
}
@@ -199,12 +199,12 @@ func (dc *controller) deleteMachineSetToDeployment(obj interface{}) {
199199
if !ok {
200200
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
201201
if !ok {
202-
utilruntime.HandleError(fmt.Errorf("Couldn't get object from tombstone %#v", obj))
202+
utilruntime.HandleError(fmt.Errorf("couldn't get object from tombstone %#v", obj))
203203
return
204204
}
205205
machineSet, ok = tombstone.Obj.(*v1alpha1.MachineSet)
206206
if !ok {
207-
utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a MachineSet %#v", obj))
207+
utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a MachineSet %#v", obj))
208208
return
209209
}
210210
}
@@ -249,7 +249,8 @@ func (dc *controller) updateMachineToMachineDeployment(old, cur any) {
249249
}
250250

251251
// deleteMachine will enqueue a Recreate Deployment once all of its Machines have stopped running.
252-
func (dc *controller) deleteMachineToMachineDeployment(ctx context.Context, obj interface{}) {
252+
func (dc *controller) deleteMachineToMachineDeployment(obj interface{}) {
253+
ctx := context.Background()
253254
machine, ok := obj.(*v1alpha1.Machine)
254255

255256
// When a delete is dropped, the relist will notice a Machine in the store not
@@ -259,12 +260,12 @@ func (dc *controller) deleteMachineToMachineDeployment(ctx context.Context, obj
259260
if !ok {
260261
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
261262
if !ok {
262-
utilruntime.HandleError(fmt.Errorf("Couldn't get object from tombstone %#v", obj))
263+
utilruntime.HandleError(fmt.Errorf("couldn't get object from tombstone %#v", obj))
263264
return
264265
}
265266
machine, ok = tombstone.Obj.(*v1alpha1.Machine)
266267
if !ok {
267-
utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a machine %#v", obj))
268+
utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a machine %#v", obj))
268269
return
269270
}
270271
}
@@ -292,7 +293,7 @@ func (dc *controller) deleteMachineToMachineDeployment(ctx context.Context, obj
292293
func (dc *controller) enqueueMachineDeployment(deployment *v1alpha1.MachineDeployment) {
293294
key, err := KeyFunc(deployment)
294295
if err != nil {
295-
utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %v", deployment, err))
296+
utilruntime.HandleError(fmt.Errorf("couldn't get key for object %#v: %v", deployment, err))
296297
return
297298
}
298299

@@ -302,7 +303,7 @@ func (dc *controller) enqueueMachineDeployment(deployment *v1alpha1.MachineDeplo
302303
func (dc *controller) enqueueRateLimited(deployment *v1alpha1.MachineDeployment) {
303304
key, err := KeyFunc(deployment)
304305
if err != nil {
305-
utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %v", deployment, err))
306+
utilruntime.HandleError(fmt.Errorf("couldn't get key for object %#v: %v", deployment, err))
306307
return
307308
}
308309

@@ -313,7 +314,7 @@ func (dc *controller) enqueueRateLimited(deployment *v1alpha1.MachineDeployment)
313314
func (dc *controller) enqueueMachineDeploymentAfter(deployment *v1alpha1.MachineDeployment, after time.Duration) {
314315
key, err := KeyFunc(deployment)
315316
if err != nil {
316-
utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %v", deployment, err))
317+
utilruntime.HandleError(fmt.Errorf("couldn't get key for object %#v: %v", deployment, err))
317318
return
318319
}
319320

pkg/controller/deployment_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ var _ = Describe("machineDeployment", func() {
886886

887887
defer trackers.Stop()
888888
waitForCacheSync(stop, c)
889-
c.deleteMachineToMachineDeployment(context.Background(), testMachine)
889+
c.deleteMachineToMachineDeployment(testMachine)
890890

891891
waitForCacheSync(stop, c)
892892
Expect(c.machineDeploymentQueue.Len()).To(Equal(queueLength))
@@ -1359,7 +1359,7 @@ var _ = Describe("machineDeployment", func() {
13591359

13601360
defer trackers.Stop()
13611361
waitForCacheSync(stop, c)
1362-
actualMachineSets, err := c.getMachineSetsForMachineDeployment(context.Background(), testMachineDeployment)
1362+
actualMachineSets, err := c.getMachineSetsForMachineDeployment(context.TODO(), testMachineDeployment)
13631363

13641364
waitForCacheSync(stop, c)
13651365
if expectedErr != nil {
@@ -2088,7 +2088,7 @@ var _ = Describe("machineDeployment", func() {
20882088

20892089
defer trackers.Stop()
20902090
waitForCacheSync(stop, c)
2091-
c.terminateMachineSets(context.Background(), testMachineSets, testMachineDeployment)
2091+
c.terminateMachineSets(context.TODO(), testMachineSets, testMachineDeployment)
20922092

20932093
waitForCacheSync(stop, c)
20942094
actualMachineSets, _ := c.controlMachineClient.MachineSets(testNamespace).List(context.Background(), metav1.ListOptions{})
@@ -2158,7 +2158,7 @@ var _ = Describe("machineDeployment", func() {
21582158

21592159
defer trackers.Stop()
21602160
waitForCacheSync(stop, c)
2161-
c.deleteMachineDeploymentFinalizers(context.Background(), testMachineDeployment)
2161+
c.deleteMachineDeploymentFinalizers(context.TODO(), testMachineDeployment)
21622162

21632163
waitForCacheSync(stop, c)
21642164
actualMachineDeployment, _ := c.controlMachineClient.MachineDeployments(testNamespace).Get(context.Background(), testMachineDeployment.Name, metav1.GetOptions{})

pkg/controller/machineset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ func (c *controller) prepareMachineForDeletion(ctx context.Context, targetMachin
702702

703703
machineSetKey, err := KeyFunc(machineSet)
704704
if err != nil {
705-
utilruntime.HandleError(fmt.Errorf("Couldn't get key for %v %#v: %v", machineSet.Kind, machineSet, err))
705+
utilruntime.HandleError(fmt.Errorf("couldn't get key for %v %#v: %v", machineSet.Kind, machineSet, err))
706706
return
707707
}
708708

pkg/controller/machineset_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ var _ = Describe("machineset", func() {
727727
activeMachines := []*machinev1.Machine{testActiveMachine1, testActiveMachine2}
728728

729729
testMachineSet.TypeMeta = metav1.TypeMeta{}
730-
Err := c.manageReplicas(context.Background(), activeMachines, testMachineSet)
730+
Err := c.manageReplicas(context.TODO(), activeMachines, testMachineSet)
731731
waitForCacheSync(stop, c)
732732

733733
Expect(Err).Should(BeNil())
@@ -747,7 +747,7 @@ var _ = Describe("machineset", func() {
747747
waitForCacheSync(stop, c)
748748

749749
activeMachines := []*machinev1.Machine{testActiveMachine1, testActiveMachine2}
750-
Expect(c.manageReplicas(context.Background(), activeMachines, testMachineSet)).NotTo(HaveOccurred())
750+
Expect(c.manageReplicas(context.TODO(), activeMachines, testMachineSet)).NotTo(HaveOccurred())
751751
waitForCacheSync(stop, c)
752752
// TODO: Could not use Listers here, need to check more.
753753
machines, err := c.controlMachineClient.Machines(testNamespace).List(context.Background(), metav1.ListOptions{})
@@ -837,7 +837,7 @@ var _ = Describe("machineset", func() {
837837
Expect(len(machines.Items)).To(Equal(int(testMachineSet.Spec.Replicas + 1)))
838838

839839
activeMachines := []*machinev1.Machine{testActiveMachine1, testActiveMachine2, testActiveMachine3, testActiveMachine4}
840-
Err := c.manageReplicas(context.Background(), activeMachines, testMachineSet)
840+
Err := c.manageReplicas(context.TODO(), activeMachines, testMachineSet)
841841
waitForCacheSync(stop, c)
842842
machines, _ = c.controlMachineClient.Machines(testNamespace).List(context.Background(), metav1.ListOptions{})
843843
Expect(len(machines.Items)).To(Equal(int(testMachineSet.Spec.Replicas)))

0 commit comments

Comments
 (0)