review cleanup
don't export an internal function, and simplify some code Signed-off-by: Michael McCracken <mikmccra@cisco.com>
This commit is contained in:
parent
00dcfa6db9
commit
f8fe2ea8cb
|
@ -210,16 +210,16 @@ func (d *LxcDriver) Prestart(*ExecContext, *structs.Task) (*PrestartResponse, er
|
||||||
|
|
||||||
// Start starts the LXC Driver
|
// Start starts the LXC Driver
|
||||||
func (d *LxcDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse, error) {
|
func (d *LxcDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse, error) {
|
||||||
sresp, err, errCleanup := d.StartWithCleanup(ctx, task)
|
sresp, err, errCleanup := d.startWithCleanup(ctx, task)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if cleanupErr := errCleanup(); cleanupErr != nil {
|
if cleanupErr := errCleanup(); cleanupErr != nil {
|
||||||
d.logger.Printf("[ERR] error occured:\n%v\nwhile cleaning up from error in Start: %v", cleanupErr, err)
|
d.logger.Printf("[ERR] error occured while cleaning up from error in Start: %v", cleanupErr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sresp, err
|
return sresp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *LxcDriver) StartWithCleanup(ctx *ExecContext, task *structs.Task) (*StartResponse, error, func() error) {
|
func (d *LxcDriver) startWithCleanup(ctx *ExecContext, task *structs.Task) (*StartResponse, error, func() error) {
|
||||||
noCleanup := func() error { return nil }
|
noCleanup := func() error { return nil }
|
||||||
var driverConfig LxcDriverConfig
|
var driverConfig LxcDriverConfig
|
||||||
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
if err := mapstructure.WeakDecode(task.Config, &driverConfig); err != nil {
|
||||||
|
@ -326,10 +326,7 @@ func (d *LxcDriver) StartWithCleanup(ctx *ExecContext, task *structs.Task) (*Sta
|
||||||
if err := c.Stop(); err != nil {
|
if err := c.Stop(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := c.Destroy(); err != nil {
|
return c.Destroy()
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the resource limits
|
// Set the resource limits
|
||||||
|
|
Loading…
Reference in New Issue