Make SessionSetup faster and support for command execution

This commit is contained in:
Jonathan Leibiusky @xetorthio
2017-09-11 18:09:27 -03:00
parent 86044788b9
commit fe299fed90
9 changed files with 162 additions and 124 deletions

View File

@@ -37,7 +37,11 @@ func (f *localCachedFactory) GetForSession(sessionId string) (DockerApi, error)
defer f.rw.Unlock()
if f.sessionClient != nil {
return f.sessionClient, nil
if err := f.check(f.sessionClient.GetClient()); err == nil {
return f.sessionClient, nil
} else {
f.sessionClient.GetClient().Close()
}
}
c, err := client.NewEnvClient()
@@ -69,7 +73,11 @@ func (f *localCachedFactory) GetForInstance(instance *types.Instance) (DockerApi
defer c.rw.Unlock()
if c.client != nil {
return c.client, nil
if err := f.check(c.client.GetClient()); err == nil {
return c.client, nil
} else {
c.client.GetClient().Close()
}
}
// Need to create client to the DinD docker daemon