Skip to content

Commit 6b5d4c9

Browse files
committed
libct: State: ensure Resources is not nil
Since opencontainers/cgroups v0.0.2 (commit b206a01), 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 commit 6c5441e, 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>
1 parent 178a58d commit 6b5d4c9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

libcontainer/factory_linux.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ func loadState(root string) (*State, error) {
164164
if err := json.NewDecoder(f).Decode(&state); err != nil {
165165
return nil, err
166166
}
167+
// Cgroup v1 fs manager expect Resources to never be nil.
168+
if state.Config.Cgroups.Resources == nil {
169+
state.Config.Cgroups.Resources = &cgroups.Resources{}
170+
}
167171
return state, nil
168172
}
169173

0 commit comments

Comments
 (0)