Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vpn-server close err #1227

Merged
merged 3 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions internal/vpn/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ func (c *Client) serveConn(conn net.Conn) error {

if _, err := io.Copy(tun, conn); err != nil {
fmt.Printf("Error resending traffic from TUN %s to VPN server: %v\n", tun.Name(), err)
// when the vpn-server is closed we get the error EOF
if err.Error() == io.EOF.Error() {
c.setAppError(errVPNServerClosed)
}
}
}()
go func() {
Expand Down
1 change: 1 addition & 0 deletions internal/vpn/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
errHandshakeStatusBadRequest = errors.New("Request was malformed")
errTimeout = errors.New("Internal error: Timeout")
errNotPermited = errors.New("ioctl: operation not permitted")
errVPNServerClosed = errors.New("Vpn-server closed")

errNoTransportFound = appserver.RPCErr{
Err: router.ErrNoTransportFound.Error(),
Expand Down
6 changes: 5 additions & 1 deletion pkg/app/appserver/rpc_ingress_gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,11 @@ func (r *RPCIngressGateway) Read(req *ReadReq, resp *ReadResp) error {
copy(resp.B, buf[:resp.N])
}
if err != nil {
r.log.WithError(err).Warn("Received unexpected error when reading from server.")
// we don't print warning if the conn is ready closed
_, ok := r.cm.Get(req.ConnID)
if ok {
r.log.WithError(err).Warn("Received unexpected error when reading from server.")
}
}

resp.Err = ioErrToRPCIOErr(err)
Expand Down
6 changes: 5 additions & 1 deletion pkg/visor/hypervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,11 @@ func (hv *Hypervisor) putApp() http.HandlerFunc {
httputil.WriteJSON(w, r, http.StatusInternalServerError, err)
return
}
if err := ctx.API.SetAppDetailedStatus(ctx.App.Name, launcher.AppDetailedStatusStarting); err != nil {
appStatus := launcher.AppDetailedStatusStarting
if ctx.App.Name == skyenv.VPNClientName {
appStatus = launcher.AppDetailedStatusVPNConnecting
}
if err := ctx.API.SetAppDetailedStatus(ctx.App.Name, appStatus); err != nil {
httputil.WriteJSON(w, r, http.StatusInternalServerError, err)
return
}
Expand Down