Skip to content

Commit

Permalink
Do not return error state if console is terminated by user
Browse files Browse the repository at this point in the history
When console is working in `ondemand=true` mode, if session exit
signal is received which means user hope to stop current session,
just return nil as this is a normal behavior.
  • Loading branch information
chenglch committed Mar 21, 2018
1 parent c057413 commit 619cdf3
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"net/http"

"encoding/json"
"github.com/xcat2/goconserver/console"
"github.com/gorilla/mux"
"github.com/xcat2/goconserver/console"
)

type CommandApi struct {
Expand Down
2 changes: 1 addition & 1 deletion api/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"io/ioutil"
"net/http"

"github.com/gorilla/mux"
"github.com/xcat2/goconserver/common"
"github.com/xcat2/goconserver/console"
"github.com/xcat2/goconserver/storage"
"github.com/gorilla/mux"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/congo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"fmt"
"github.com/xcat2/goconserver/console"
"github.com/spf13/cobra"
"github.com/xcat2/goconserver/console"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion console/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package console

import (
"fmt"
"github.com/xcat2/goconserver/common"
"github.com/spf13/cobra"
"github.com/xcat2/goconserver/common"
"golang.org/x/crypto/ssh/terminal"
"os"
"runtime"
Expand Down
2 changes: 1 addition & 1 deletion console/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package console
import (
"context"
"fmt"
google_protobuf "github.com/golang/protobuf/ptypes/empty"
"github.com/xcat2/goconserver/common"
pb "github.com/xcat2/goconserver/console/consolepb"
google_protobuf "github.com/golang/protobuf/ptypes/empty"
net_context "golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand Down
4 changes: 2 additions & 2 deletions goconserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"github.com/xcat2/goconserver/api"
"github.com/xcat2/goconserver/common"
"github.com/gorilla/mux"
"github.com/spf13/cobra"
"github.com/xcat2/goconserver/api"
"github.com/xcat2/goconserver/common"
"io/ioutil"
"log"
"net/http"
Expand Down
8 changes: 6 additions & 2 deletions plugins/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package plugins

import (
"fmt"
"github.com/xcat2/goconserver/common"
"github.com/kr/pty"
"github.com/xcat2/goconserver/common"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -78,5 +78,9 @@ func (self *CommondConsole) Close() error {
}

func (self *CommondConsole) Wait() error {
return self.command.Wait()
err := self.command.Wait()
if err == nil || strings.Contains(err.Error(), "killed") {
return nil
}
return err
}
8 changes: 7 additions & 1 deletion plugins/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,13 @@ func (self *SSHConsole) Close() error {

func (self *SSHConsole) Wait() error {
if self.session != nil {
return self.session.Wait()
err := self.session.Wait()
switch err.(type) {
case *ssh.ExitMissingError:
return nil
default:
return err
}
}
return nil
}
2 changes: 1 addition & 1 deletion storage/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/xcat2/goconserver/common"
"github.com/coreos/etcd/clientv3"
"github.com/xcat2/goconserver/common"
"os"
"reflect"
"strings"
Expand Down

0 comments on commit 619cdf3

Please sign in to comment.