Skip to content

Commit

Permalink
Fix all client request that needs contexts (#1292)
Browse files Browse the repository at this point in the history
Signed-off-by: Jiaxin Shan <[email protected]>
  • Loading branch information
Jeffwan authored Jul 5, 2021
1 parent 840a41b commit d72641c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/tf-operator.v1/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func createClientSets(config *restclientset.Config) (
func checkCRDExists(clientset apiextensionclientset.Interface, namespace string) bool {
crd, err := clientset.ApiextensionsV1beta1().
CustomResourceDefinitions().
Get(v1.TFCRD, metav1.GetOptions{})
Get(context.TODO(), v1.TFCRD, metav1.GetOptions{})

if err != nil {
log.Error(err)
Expand Down
5 changes: 3 additions & 2 deletions pkg/common/util/v1/unstructured/informer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package unstructured

import (
"context"
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -50,10 +51,10 @@ func newFilteredUnstructuredInformer(resource schema.GroupVersionResource, clien
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return client.Resource(resource).Namespace(namespace).List(options)
return client.Resource(resource).Namespace(namespace).List(context.TODO(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
return client.Resource(resource).Namespace(namespace).Watch(options)
return client.Resource(resource).Namespace(namespace).Watch(context.TODO(), options)
},
},
&unstructured.Unstructured{},
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller.v1/tensorflow/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package tensorflow

import (
"context"
"fmt"
"time"

Expand Down Expand Up @@ -371,7 +372,7 @@ func (tc *TFController) GetJobFromInformerCache(namespace, name string) (metav1.
}

func (tc *TFController) GetJobFromAPIClient(namespace, name string) (metav1.Object, error) {
return tc.tfJobClientSet.KubeflowV1().TFJobs(namespace).Get(name, metav1.GetOptions{})
return tc.tfJobClientSet.KubeflowV1().TFJobs(namespace).Get(context.TODO(), name, metav1.GetOptions{})
}

func (tc *TFController) GetAPIGroupVersionKind() schema.GroupVersionKind {
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller.v1/tensorflow/job.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tensorflow

import (
"context"
"fmt"
"time"

Expand Down Expand Up @@ -43,7 +44,7 @@ func (tc *TFController) DeleteJob(job interface{}) error {
}

log := commonutil.LoggerForJob(tfJob)
if err := tc.tfJobClientSet.KubeflowV1().TFJobs(tfJob.Namespace).Delete(tfJob.Name, &metav1.DeleteOptions{}); err != nil {
if err := tc.tfJobClientSet.KubeflowV1().TFJobs(tfJob.Namespace).Delete(context.TODO(), tfJob.Name, metav1.DeleteOptions{}); err != nil {
tc.JobController.Recorder.Eventf(tfJob, v1.EventTypeWarning, FailedDeleteJobReason, "Error deleting: %v", err)
log.Errorf("failed to delete job %s/%s, %v", tfJob.Namespace, tfJob.Name, err)
return err
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller.v1/tensorflow/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package tensorflow

import (
"context"
"fmt"
"time"

Expand Down Expand Up @@ -235,7 +236,7 @@ func (tc *TFController) UpdateJobStatusInApiServer(job interface{}, jobStatus *c
tfJob = tfJob.DeepCopy()
tfJob.Status = *jobStatus.DeepCopy()

_, err := tc.tfJobClientSet.KubeflowV1().TFJobs(tfJob.Namespace).UpdateStatus(tfJob)
_, err := tc.tfJobClientSet.KubeflowV1().TFJobs(tfJob.Namespace).UpdateStatus(context.TODO(), tfJob, metav1.UpdateOptions{})
return err
}

Expand Down

0 comments on commit d72641c

Please sign in to comment.