@@ -267,7 +267,7 @@ func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName
267
267
deployment , err := c .deploymentsLister .Deployments (foo .Namespace ).Get (deploymentName )
268
268
// If the resource doesn't exist, we'll create it
269
269
if errors .IsNotFound (err ) {
270
- deployment , err = c .kubeclientset .AppsV1 ().Deployments (foo .Namespace ).Create (context . TODO () , newDeployment (foo ), metav1.CreateOptions {FieldManager : FieldManager })
270
+ deployment , err = c .kubeclientset .AppsV1 ().Deployments (foo .Namespace ).Create (ctx , newDeployment (foo ), metav1.CreateOptions {FieldManager : FieldManager })
271
271
}
272
272
273
273
// If an error occurs during Get/Create, we'll requeue the item so we can
@@ -290,7 +290,7 @@ func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName
290
290
// should update the Deployment resource.
291
291
if foo .Spec .Replicas != nil && * foo .Spec .Replicas != * deployment .Spec .Replicas {
292
292
logger .V (4 ).Info ("Update deployment resource" , "currentReplicas" , * foo .Spec .Replicas , "desiredReplicas" , * deployment .Spec .Replicas )
293
- deployment , err = c .kubeclientset .AppsV1 ().Deployments (foo .Namespace ).Update (context . TODO () , newDeployment (foo ), metav1.UpdateOptions {FieldManager : FieldManager })
293
+ deployment , err = c .kubeclientset .AppsV1 ().Deployments (foo .Namespace ).Update (ctx , newDeployment (foo ), metav1.UpdateOptions {FieldManager : FieldManager })
294
294
}
295
295
296
296
// If an error occurs during Update, we'll requeue the item so we can
@@ -302,7 +302,7 @@ func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName
302
302
303
303
// Finally, we update the status block of the Foo resource to reflect the
304
304
// current state of the world
305
- err = c .updateFooStatus (foo , deployment )
305
+ err = c .updateFooStatus (ctx , foo , deployment )
306
306
if err != nil {
307
307
return err
308
308
}
@@ -311,7 +311,7 @@ func (c *Controller) syncHandler(ctx context.Context, objectRef cache.ObjectName
311
311
return nil
312
312
}
313
313
314
- func (c * Controller ) updateFooStatus (foo * samplev1alpha1.Foo , deployment * appsv1.Deployment ) error {
314
+ func (c * Controller ) updateFooStatus (ctx context. Context , foo * samplev1alpha1.Foo , deployment * appsv1.Deployment ) error {
315
315
// NEVER modify objects from the store. It's a read-only, local cache.
316
316
// You can use DeepCopy() to make a deep copy of original object and modify this copy
317
317
// Or create a copy manually for better performance
@@ -321,7 +321,7 @@ func (c *Controller) updateFooStatus(foo *samplev1alpha1.Foo, deployment *appsv1
321
321
// we must use Update instead of UpdateStatus to update the Status block of the Foo resource.
322
322
// UpdateStatus will not allow changes to the Spec of the resource,
323
323
// which is ideal for ensuring nothing other than resource status has been updated.
324
- _ , err := c .sampleclientset .SamplecontrollerV1alpha1 ().Foos (foo .Namespace ).UpdateStatus (context . TODO () , fooCopy , metav1.UpdateOptions {FieldManager : FieldManager })
324
+ _ , err := c .sampleclientset .SamplecontrollerV1alpha1 ().Foos (foo .Namespace ).UpdateStatus (ctx , fooCopy , metav1.UpdateOptions {FieldManager : FieldManager })
325
325
return err
326
326
}
327
327
0 commit comments