(mountpoint string, group string, resources *Resources)
| 188 | } |
| 189 | |
| 190 | func NewManager(mountpoint string, group string, resources *Resources) (*Manager, error) { |
| 191 | if resources == nil { |
| 192 | return nil, errors.New("resources reference is nil") |
| 193 | } |
| 194 | if err := VerifyGroupPath(group); err != nil { |
| 195 | return nil, err |
| 196 | } |
| 197 | path := filepath.Join(mountpoint, group) |
| 198 | if err := os.MkdirAll(path, defaultDirPerm); err != nil { |
| 199 | return nil, err |
| 200 | } |
| 201 | m := Manager{ |
| 202 | unifiedMountpoint: mountpoint, |
| 203 | path: path, |
| 204 | } |
| 205 | if err := m.ToggleControllers(resources.EnabledControllers(), Enable); err != nil { |
| 206 | // clean up cgroup dir on failure |
| 207 | os.Remove(path) |
| 208 | return nil, err |
| 209 | } |
| 210 | if err := setResources(path, resources); err != nil { |
| 211 | os.Remove(path) |
| 212 | return nil, err |
| 213 | } |
| 214 | return &m, nil |
| 215 | } |
| 216 | |
| 217 | type InitConfig struct { |
| 218 | mountpoint string |
searching dependent graphs…