lots of work to make it actually work.
Icluding the server keep alive interval. Fix where expiry duration was added twice.
This commit is contained in:
parent
aa46ed7b5c
commit
9fc0241d08
@ -58,10 +58,10 @@ func setWinsize(f *os.File, w, h int) {
|
||||
uintptr(unsafe.Pointer(&struct{ h, w, x, y uint16 }{uint16(h), uint16(w), 0, 0})))
|
||||
}
|
||||
|
||||
func sshServer(hostKeyFile string) *ssh.Server {
|
||||
func sshServer(hostKeyFile string, shellCommand string) *ssh.Server {
|
||||
ssh.Handle(func(s ssh.Session) {
|
||||
// TODO shell should be made configurable
|
||||
cmd := exec.Command("bash")
|
||||
|
||||
cmd := exec.Command(shellCommand)
|
||||
ptyReq, winCh, isPty := s.Pty()
|
||||
if isPty {
|
||||
workingDirectory, _ := os.Getwd()
|
||||
@ -154,8 +154,8 @@ func (f ReaderFunc) Read(p []byte) (n int, err error) {
|
||||
func main() {
|
||||
wsURL := os.Args[1]
|
||||
|
||||
advanceWarningTime := 10 * time.Minute
|
||||
agentExpriryTime := 30 * time.Minute
|
||||
advanceWarningTime := 5 * time.Minute
|
||||
agentExpriryTime := 10 * time.Minute
|
||||
tickerInterval := 60 * time.Second
|
||||
agent.ConfigureAgent(advanceWarningTime, agentExpriryTime, tickerInterval)
|
||||
|
||||
@ -176,8 +176,21 @@ func main() {
|
||||
|
||||
// Need to create listener implementation that aactually listens for websocket connections.
|
||||
var service AgentService
|
||||
shells := []string{"bash", "sh", "ash", "ksh", "zsh", "fish", "tcsh", "csh"}
|
||||
shell := ""
|
||||
for _, candidate := range shells {
|
||||
shell, err = exec.LookPath(candidate)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
if shell == "" {
|
||||
log.Printf("Cannot find a shell in %v", shells)
|
||||
os.Exit(1)
|
||||
}
|
||||
log.Printf("Using shell %s for remote sessions", shell)
|
||||
service = ListenerServer(func() *ssh.Server {
|
||||
return sshServer("hostkey.pem")
|
||||
return sshServer("hostkey.pem", shell)
|
||||
})
|
||||
//service = ConnectionServer(netCatServer)
|
||||
//service = ConnectionServer(echoServer)
|
||||
|
@ -69,7 +69,6 @@ type FilteredFileSystem struct {
|
||||
}
|
||||
|
||||
func (ffs FilteredFileSystem) Open(name string) (http.File, error) {
|
||||
log.Println("Name : " + name)
|
||||
f, err := ffs.fs.Open(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
25
kubernetes/deployment.yaml
Normal file
25
kubernetes/deployment.yaml
Normal file
@ -0,0 +1,25 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
labels:
|
||||
app: converge
|
||||
name: converge
|
||||
namespace: wamblee-org
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: converge
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: converge
|
||||
spec:
|
||||
containers:
|
||||
- image: your.repo.com/converge:1.0
|
||||
imagePullPolicy: Always
|
||||
name: converge
|
||||
ports:
|
||||
- containerPort: 8000
|
||||
|
||||
|
13
kubernetes/service.yaml
Normal file
13
kubernetes/service.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
labels:
|
||||
app: converge
|
||||
name: converge
|
||||
spec:
|
||||
ports:
|
||||
- port: 8000
|
||||
protocol: TCP
|
||||
targetPort: 8000
|
||||
selector:
|
||||
app: converge
|
@ -1,6 +1,6 @@
|
||||
Session is set to expire at %v
|
||||
|
||||
The session expires automatically after %d time.
|
||||
The session expires automatically after %v.
|
||||
If there are no more sessions after logging out, the agent
|
||||
terminates.
|
||||
|
||||
@ -8,6 +8,10 @@ You can extend this time using
|
||||
|
||||
touch $agentdir/.hold
|
||||
|
||||
The expiry time is equal to the modification time of the .hold
|
||||
file with the expiry duration added.
|
||||
|
||||
To prevent the agent from exiting after the last session is gone,
|
||||
also use the above command in any shell.
|
||||
|
||||
|
||||
|
@ -161,7 +161,7 @@ func (state *AgentState) expiryTime(filename string) time.Time {
|
||||
func check() {
|
||||
now := time.Now()
|
||||
|
||||
expiryTime := state.expiryTime(".hold").Add(state.agentExpriryTime)
|
||||
expiryTime := state.expiryTime(".hold")
|
||||
|
||||
if now.After(expiryTime) {
|
||||
messageUsers("Expiry time was reached logging out")
|
||||
|
@ -17,34 +17,40 @@
|
||||
<h1>About</h1>
|
||||
|
||||
<p>
|
||||
Converge is a utility for troubleshooting builds on continuous integration serves.
|
||||
It solves a common problem where the cause of job failure is difficult to determine.
|
||||
This is complicated furhter by the fact that build jobs are usually run on a build
|
||||
farm where there is no access to the build agents or in more modern envrionments when
|
||||
jobs are run in ephemeral containers.
|
||||
Converge is a utility for troubleshooting builds on continuous integration serves.
|
||||
It solves a common problem where the cause of job failure is difficult to determine.
|
||||
This is complicated further by the fact that build jobs are usually run on a build
|
||||
farm where there is no access to the build agents or in more modern envrionments when
|
||||
jobs are run in ephemeral containers.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
With Converge it is possible to get remote shell access to such jobs. This works
|
||||
by configuring the build job to connect to a Converge server using an agent program.
|
||||
The agent program can be downloaded from within the CI job using curl or wget.
|
||||
Next, an end-use can connect to the Converge server, a rendez-vous server, that connects
|
||||
the client and server together.
|
||||
With Converge it is possible to get remote shell access to such jobs. This works
|
||||
by configuring the build job to connect to a Converge server using an agent program.
|
||||
The agent program can be downloaded from within the CI job using curl or wget.
|
||||
Next, an end-use can connect to the Converge server, a rendez-vous server, that connects
|
||||
the client and server together.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The setup is such that the connection from client (end-user) to server (agent on CI job)
|
||||
is end-to-end encrypted. The Converge server itself is no more than a bitpipe which pumps
|
||||
data between client and agent.
|
||||
The setup is such that the connection from client (end-user) to server (agent on CI job)
|
||||
is end-to-end encrypted. The Converge server itself is no more than a bitpipe which pumps
|
||||
data between client and agent.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Both ssh and sftp are supported. Multiple shells are also allowed.
|
||||
Both ssh and sftp are supported. Multiple shells are also allowed.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
There is a timeout mechanism in the agent such that jobs do not hang indefinetely waiting
|
||||
for a connection.
|
||||
There is a timeout mechanism in the agent such that jobs do not hang indefinitely waiting
|
||||
for a connection. This mechanism is useful to make sure build agents do not wait
|
||||
indefinitely for a user session. By default, the agent exits with status 0 when
|
||||
the first client exits after logging in. This behavior as well as general expiry can be
|
||||
controlled from within a shell session by touching a .hold file. After logging in, the
|
||||
user can control expiry of the session as instructed by messages in the ssh session.
|
||||
Then the timeout of a session is near the user is informed about this with messages
|
||||
in the shell.
|
||||
</p>
|
||||
|
||||
<h1>Usage</h1>
|
||||
@ -75,7 +81,7 @@
|
||||
</pre>
|
||||
|
||||
<p>This is a command that can be used as a proxy command for SSH which performs the connection to the remote
|
||||
server.</p>
|
||||
server.</p>
|
||||
|
||||
<p>
|
||||
Next step is to run a local SSH of SFTP client:
|
||||
@ -118,7 +124,7 @@
|
||||
|
||||
<pre>
|
||||
ssh -oServerAliveInterval=10 -p 10000 abc@localhost
|
||||
sftp -oServerAliveInterval=10 -oPort 10000 abc@localhost
|
||||
sftp -oServerAliveInterval=10 -oPort=10000 abc@localhost
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
|
Loading…
Reference in New Issue
Block a user