Skip to content

Commit

Permalink
Revert "Refactor how contexts are passed." (#787)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronH88 authored Jun 7, 2023
1 parent 4b4c4ab commit 4addde8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:

- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.52
lint-receptorctl:
name: lint-receptorctl
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions pkg/controlsvc/controlsvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (s *Server) RunControlSession(conn net.Conn) {
cc, err = ct.InitFromJSON(jsonData)
}
if err == nil {
ctx, cancel := context.WithCancel(s.nc.Context())
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cfr, err = cc.ControlFunc(ctx, s.nc, cfo)
}
Expand Down Expand Up @@ -435,7 +435,7 @@ func (cfg cmdlineConfigUnix) Run() error {
return err
}
}
err = MainInstance.RunControlSvc(netceptor.MainInstance.Context(), cfg.Service, tlscfg, cfg.Filename,
err = MainInstance.RunControlSvc(context.Background(), cfg.Service, tlscfg, cfg.Filename,
os.FileMode(cfg.Permissions), cfg.TCPListen, tcptls)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/netceptor/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ type Conn struct {

// Dial returns a stream connection compatible with Go's net.Conn.
func (s *Netceptor) Dial(node string, service string, tlscfg *tls.Config) (*Conn, error) {
return s.DialContext(s.Context(), node, service, tlscfg)
return s.DialContext(context.Background(), node, service, tlscfg)
}

// DialContext is like Dial but uses a context to allow timeout or cancellation.
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (cfg NodeCfg) Init() error {
}
}

workceptor.MainInstance, err = workceptor.New(netceptor.MainInstance.Context(), netceptor.MainInstance, cfg.DataDir)
workceptor.MainInstance, err = workceptor.New(context.Background(), netceptor.MainInstance, cfg.DataDir)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/workceptor/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ func (kw *kubeUnit) Restart() error {
if err != nil {
kw.w.nc.Logger.Warning("Pod %s could not be deleted: %s", ked.PodName, err.Error())
} else {
err := kw.clientset.CoreV1().Pods(ked.KubeNamespace).Delete(kw.ctx, ked.PodName, metav1.DeleteOptions{})
err := kw.clientset.CoreV1().Pods(ked.KubeNamespace).Delete(context.Background(), ked.PodName, metav1.DeleteOptions{})
if err != nil {
kw.w.nc.Logger.Warning("Pod %s could not be deleted: %s", ked.PodName, err.Error())
}
Expand All @@ -1341,7 +1341,7 @@ func (kw *kubeUnit) Cancel() error {
kw.cancel()
kw.UpdateBasicStatus(WorkStateCanceled, "Canceled", -1)
if kw.pod != nil {
err := kw.clientset.CoreV1().Pods(kw.pod.Namespace).Delete(kw.ctx, kw.pod.Name, metav1.DeleteOptions{})
err := kw.clientset.CoreV1().Pods(kw.pod.Namespace).Delete(context.Background(), kw.pod.Name, metav1.DeleteOptions{})
if err != nil {
kw.w.nc.Logger.Error("Error deleting pod %s: %s", kw.pod.Name, err)
}
Expand Down

0 comments on commit 4addde8

Please sign in to comment.