diff --git a/pkg/attacher/attach.go b/pkg/attacher/attach.go index d44facc8..b0cf8304 100644 --- a/pkg/attacher/attach.go +++ b/pkg/attacher/attach.go @@ -12,7 +12,7 @@ import ( "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes/scheme" tcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" - "k8s.io/kubernetes/pkg/kubectl/util/term" + "k8s.io/kubectl/pkg/util/term" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -58,7 +58,7 @@ func (a *Attacher) Attach(selector, namespace string) { Jitter: 0.0, Steps: 100, }, func() (bool, error) { - pl, err := a.CoreV1Client.Pods(namespace).List(metav1.ListOptions{ + pl, err := a.CoreV1Client.Pods(namespace).List(context.Background(), metav1.ListOptions{ LabelSelector: selector, }) diff --git a/pkg/logs/logs.go b/pkg/logs/logs.go index 94406c0f..5f152824 100644 --- a/pkg/logs/logs.go +++ b/pkg/logs/logs.go @@ -1,6 +1,8 @@ package logs import ( + "context" + "github.com/iovisor/kubectl-trace/pkg/meta" tcorev1 "k8s.io/client-go/kubernetes/typed/core/v1" @@ -34,7 +36,7 @@ const ( ) func (l *Logs) Run(jobID types.UID, namespace string, follow bool, timestamps bool) error { - pl, err := l.coreV1Client.Pods(namespace).List(metav1.ListOptions{ + pl, err := l.coreV1Client.Pods(namespace).List(context.Background(), metav1.ListOptions{ LabelSelector: fmt.Sprintf("%s=%s", meta.TraceIDLabelKey, jobID), }) @@ -70,7 +72,7 @@ func (l *Logs) Run(jobID types.UID, namespace string, follow bool, timestamps bo } func consumeRequest(request *rest.Request, out io.Writer) error { - readCloser, err := request.Stream() + readCloser, err := request.Stream(context.Background()) if err != nil { return err } diff --git a/pkg/tracejob/job.go b/pkg/tracejob/job.go index cd529f92..313b8856 100644 --- a/pkg/tracejob/job.go +++ b/pkg/tracejob/job.go @@ -1,6 +1,7 @@ package tracejob import ( + "context" "fmt" "io" "io/ioutil" @@ -86,7 +87,7 @@ func (t *TraceJobClient) findJobsWithFilter(nf TraceJobFilter) ([]batchv1.Job, e return []batchv1.Job{}, nil } - jl, err := t.JobClient.List(selectorOptions) + jl, err := t.JobClient.List(context.Background(), selectorOptions) if err != nil { return nil, err @@ -100,7 +101,7 @@ func (t *TraceJobClient) findConfigMapsWithFilter(nf TraceJobFilter) ([]apiv1.Co return []apiv1.ConfigMap{}, nil } - cm, err := t.ConfigClient.List(selectorOptions) + cm, err := t.ConfigClient.List(context.Background(), selectorOptions) if err != nil { return nil, err @@ -152,7 +153,7 @@ func (t *TraceJobClient) DeleteJobs(nf TraceJobFilter) error { dp := metav1.DeletePropagationForeground for _, j := range jl { - err := t.JobClient.Delete(j.Name, &metav1.DeleteOptions{ + err := t.JobClient.Delete(context.Background(), j.Name, metav1.DeleteOptions{ GracePeriodSeconds: int64Ptr(0), PropagationPolicy: &dp, }) @@ -170,7 +171,7 @@ func (t *TraceJobClient) DeleteJobs(nf TraceJobFilter) error { } for _, c := range cl { - err := t.ConfigClient.Delete(c.Name, nil) + err := t.ConfigClient.Delete(context.Background(), c.Name, metav1.DeleteOptions{}) if err != nil { return err } @@ -469,10 +470,10 @@ func (t *TraceJobClient) CreateJob(nj TraceJob) (*batchv1.Job, error) { ReadOnly: true, }) } - if _, err := t.ConfigClient.Create(cm); err != nil { + if _, err := t.ConfigClient.Create(context.Background(), cm, metav1.CreateOptions{}); err != nil { return nil, err } - return t.JobClient.Create(job) + return t.JobClient.Create(context.Background(), job, metav1.CreateOptions{}) } func int32Ptr(i int32) *int32 { return &i }