@@ -171,26 +171,26 @@ func (p *Provisioner) StartSession(snapshotID string, user resources.EphemeralUs
171
171
172
172
defer func () {
173
173
if err != nil {
174
- p .revertSession (name )
174
+ p .revertSession (fsm , name )
175
175
176
176
if portErr := p .FreePort (port ); portErr != nil {
177
177
log .Err (portErr )
178
178
}
179
179
}
180
180
}()
181
181
182
- if err : = fsm .CreateClone (name , snapshot .ID ); err != nil {
182
+ if err = fsm .CreateClone (name , snapshot .ID ); err != nil {
183
183
return nil , errors .Wrap (err , "failed to create clone" )
184
184
}
185
185
186
186
appConfig := p .getAppConfig (fsm .Pool (), name , port )
187
187
appConfig .SetExtraConf (extraConfig )
188
188
189
- if err : = postgres .Start (p .runner , appConfig ); err != nil {
189
+ if err = postgres .Start (p .runner , appConfig ); err != nil {
190
190
return nil , errors .Wrap (err , "failed to start a container" )
191
191
}
192
192
193
- if err : = p .prepareDB (appConfig , user ); err != nil {
193
+ if err = p .prepareDB (appConfig , user ); err != nil {
194
194
return nil , errors .Wrap (err , "failed to prepare a database" )
195
195
}
196
196
@@ -263,30 +263,30 @@ func (p *Provisioner) ResetSession(session *resources.Session, snapshotID string
263
263
264
264
defer func () {
265
265
if err != nil {
266
- p .revertSession (name )
266
+ p .revertSession (newFSManager , name )
267
267
}
268
268
}()
269
269
270
- if err : = postgres .Stop (p .runner , fsm .Pool (), name ); err != nil {
270
+ if err = postgres .Stop (p .runner , fsm .Pool (), name ); err != nil {
271
271
return nil , errors .Wrap (err , "failed to stop container" )
272
272
}
273
273
274
- if err : = fsm .DestroyClone (name ); err != nil {
274
+ if err = fsm .DestroyClone (name ); err != nil {
275
275
return nil , errors .Wrap (err , "failed to destroy clone" )
276
276
}
277
277
278
- if err : = newFSManager .CreateClone (name , snapshot .ID ); err != nil {
278
+ if err = newFSManager .CreateClone (name , snapshot .ID ); err != nil {
279
279
return nil , errors .Wrap (err , "failed to create clone" )
280
280
}
281
281
282
282
appConfig := p .getAppConfig (newFSManager .Pool (), name , session .Port )
283
283
appConfig .SetExtraConf (session .ExtraConfig )
284
284
285
- if err : = postgres .Start (p .runner , appConfig ); err != nil {
285
+ if err = postgres .Start (p .runner , appConfig ); err != nil {
286
286
return nil , errors .Wrap (err , "failed to start container" )
287
287
}
288
288
289
- if err : = p .prepareDB (appConfig , session .EphemeralUser ); err != nil {
289
+ if err = p .prepareDB (appConfig , session .EphemeralUser ); err != nil {
290
290
return nil , errors .Wrap (err , "failed to prepare database" )
291
291
}
292
292
@@ -383,15 +383,15 @@ func buildPoolEntry(fsm pool.FSManager) (models.PoolEntry, error) {
383
383
}
384
384
385
385
// Other methods.
386
- func (p * Provisioner ) revertSession (name string ) {
386
+ func (p * Provisioner ) revertSession (fsm pool. FSManager , name string ) {
387
387
log .Dbg (`Reverting start of a session...` )
388
388
389
- if runnerErr := postgres .Stop (p .runner , p . pm . First () .Pool (), name ); runnerErr != nil {
390
- log .Err (`Revert:` , runnerErr )
389
+ if runnerErr := postgres .Stop (p .runner , fsm .Pool (), name ); runnerErr != nil {
390
+ log .Err ("Stop Postgres:" , runnerErr )
391
391
}
392
392
393
- if runnerErr := p . pm . First () .DestroyClone (name ); runnerErr != nil {
394
- log .Err (`Revert:` , runnerErr )
393
+ if runnerErr := fsm .DestroyClone (name ); runnerErr != nil {
394
+ log .Err ("Destroy clone:" , runnerErr )
395
395
}
396
396
}
397
397
0 commit comments