mirror of
https://github.com/opencontainers/runc.git
synced 2025-09-26 19:41:35 +08:00
libct: State: ensure Resources is not nil
Since opencontainers/cgroups v0.0.2 (commitb206a015
), all stuct Resources fields are annotated with "omitempty" attribute. As a result, the loaded configuration may have Resources == nil. It is totally OK (rootless containers may have no resources configured) except since commit6c5441e5
, cgroup v1 fs manager requires Resources to be set in the call to NewManager (this is a cgroup v1 deficiency, or maybe our implementation deficiency, or both). To work around this, let's add code to ensure Resources is never nil after loading from state.json. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:

committed by
Jared Ledvina

parent
f5e8c63fdc
commit
e34f6438e9
@@ -164,6 +164,10 @@ func loadState(root string) (*State, error) {
|
||||
if err := json.NewDecoder(f).Decode(&state); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Cgroup v1 fs manager expect Resources to never be nil.
|
||||
if state.Config.Cgroups.Resources == nil {
|
||||
state.Config.Cgroups.Resources = &cgroups.Resources{}
|
||||
}
|
||||
return state, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user