Skip to content

Commit

Permalink
persist the no-keep-alive flag (#1127)
Browse files Browse the repository at this point in the history
* persist the no-keep-alive flag

* fix typo
  • Loading branch information
Muhamad Azmy authored Dec 18, 2020
1 parent 66126fa commit 7b1d69b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/vm/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ type Machine struct {
Drives []Drive `json:"drives"`
Interfaces []Interface `json:"network-interfaces"`
Config Config `json:"machine-config"`
// NoKeepAlive is not used by firecracker, but instead a marker
// for the vm mananger to not restart the machine when it stops
NoKeepAlive bool `json:"no-keep-alive"`
}

// Jailed represents a jailed machine.
Expand Down
5 changes: 3 additions & 2 deletions pkg/vm/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,9 @@ func (m *Module) Run(vm pkg.VM) error {
Mem: vm.Memory,
HTEnabled: false,
},
Interfaces: nics,
Drives: devices,
Interfaces: nics,
Drives: devices,
NoKeepAlive: vm.NoKeepAlive,
}

defer func() {
Expand Down
8 changes: 8 additions & 0 deletions pkg/vm/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,14 @@ func (m *Module) monitorID(ctx context.Context, running map[string]int, id strin
return err
}

if jailed.NoKeepAlive {
// if the permanent marker was not set, and we reach here it's possible that
// the vmd was restarted, hence the in-memory copy of this flag was gone. Hence
// we need to set it correctly, and just return
m.failures.Set(id, permanent, cache.NoExpiration)
return nil
}

reason = jailed.Start(ctx)
if reason == nil {
reason = m.waitAndAdjOom(ctx, id)
Expand Down

0 comments on commit 7b1d69b

Please sign in to comment.