Skip to content

Commit cd3f61e

Browse files
committedOct 18, 2023
change: when stopping upstream/downstream, also close grpc connections
Signed-off-by: Thorsten Klein <[email protected]>
1 parent 6bafc07 commit cd3f61e

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed
 

‎helper/server/downstream.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ import (
44
"archive/tar"
55
"compress/gzip"
66
"context"
7-
"github.com/loft-sh/devspace/helper/util/pingtimeout"
8-
"github.com/loft-sh/devspace/pkg/util/fsutil"
9-
logpkg "github.com/loft-sh/devspace/pkg/util/log"
107
"io"
118
"log"
129
"os"
@@ -15,6 +12,10 @@ import (
1512
"sync"
1613
"time"
1714

15+
"github.com/loft-sh/devspace/helper/util/pingtimeout"
16+
"github.com/loft-sh/devspace/pkg/util/fsutil"
17+
logpkg "github.com/loft-sh/devspace/pkg/util/log"
18+
1819
"github.com/loft-sh/devspace/helper/server/ignoreparser"
1920
"github.com/loft-sh/devspace/helper/util/stderrlog"
2021
"github.com/loft-sh/notify"

‎pkg/devspace/sync/downstream.go

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/loft-sh/devspace/helper/server/ignoreparser"
1515
"github.com/loft-sh/devspace/helper/util"
1616
"github.com/loft-sh/devspace/pkg/util/fsutil"
17+
"google.golang.org/grpc"
1718

1819
"github.com/fujiwara/shapeio"
1920
"github.com/pkg/errors"
@@ -27,6 +28,7 @@ type downstream struct {
2728
client remote.DownstreamClient
2829

2930
ignoreMatcher ignoreparser.IgnoreParser
31+
conn *grpc.ClientConn
3032

3133
unarchiver *Unarchiver
3234
}
@@ -71,6 +73,7 @@ func newDownstream(reader io.ReadCloser, writer io.WriteCloser, sync *Sync) (*do
7173
client: remote.NewDownstreamClient(conn),
7274
ignoreMatcher: ignoreMatcher,
7375
unarchiver: NewUnarchiver(sync, false, sync.log),
76+
conn: conn,
7477
}, nil
7578
}
7679

‎pkg/devspace/sync/sync.go

+6
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,9 @@ func (s *Sync) Stop(fatalError error) {
415415
if s.upstream.reader != nil {
416416
s.upstream.reader.Close()
417417
}
418+
if s.upstream.conn != nil {
419+
s.upstream.conn.Close()
420+
}
418421
}
419422

420423
if s.downstream != nil {
@@ -424,6 +427,9 @@ func (s *Sync) Stop(fatalError error) {
424427
if s.downstream.reader != nil {
425428
s.downstream.reader.Close()
426429
}
430+
if s.downstream.conn != nil {
431+
s.downstream.conn.Close()
432+
}
427433
}
428434

429435
if fatalError != nil {

‎pkg/devspace/sync/upstream.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ import (
2222
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
2323
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine"
2424
"github.com/loft-sh/devspace/pkg/util/fsutil"
25+
"google.golang.org/grpc"
2526

26-
"github.com/loft-sh/utils/pkg/command"
2727
"github.com/loft-sh/notify"
28+
"github.com/loft-sh/utils/pkg/command"
2829

2930
"github.com/bmatcuk/doublestar"
3031
"github.com/fujiwara/shapeio"
@@ -57,6 +58,8 @@ type upstream struct {
5758
initialSyncChanges []string
5859
initialSyncCompleted bool
5960
initialSyncTouchOnce sync.Once
61+
62+
conn *grpc.ClientConn
6063
}
6164

6265
const (
@@ -111,6 +114,8 @@ func newUpstream(reader io.ReadCloser, writer io.WriteCloser, sync *Sync) (*upst
111114
client: remote.NewUpstreamClient(conn),
112115

113116
ignoreMatcher: ignoreMatcher,
117+
118+
conn: conn,
114119
}, nil
115120
}
116121

0 commit comments

Comments
 (0)
Please sign in to comment.