libct: don't use GetPaths

Since commit 714c91e9f7, method GetPaths() should only be used
for saving container state. For other uses, we have a new method,
Path(), which is cleaner.

Fix GetPaths() usage introduced by recent commits 859a780d6f and 9087f2e82.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2020-06-15 18:21:01 -07:00
parent 5b247e739c
commit a77d7b1d0f
2 changed files with 4 additions and 9 deletions

View File

@ -264,7 +264,7 @@ func (m *manager) Set(container *configs.Config) error {
// Freeze toggles the container's freezer cgroup depending on the state
// provided
func (m *manager) Freeze(state configs.FreezerState) (Err error) {
path := m.GetPaths()["freezer"]
path := m.Path("freezer")
if m.cgroups == nil || path == "" {
return errors.New("cannot toggle freezer: cgroups not configured for container")
}
@ -382,8 +382,7 @@ func (m *manager) GetCgroups() (*configs.Cgroup, error) {
}
func (m *manager) GetFreezerState() (configs.FreezerState, error) {
paths := m.GetPaths()
dir := paths["freezer"]
dir := m.Path("freezer")
freezer, err := m.getSubsystems().Get("freezer")
// If the container doesn't have the freezer cgroup, say it's undefined.

View File

@ -51,12 +51,8 @@ func (m *mockCgroupManager) Destroy() error {
}
func (m *mockCgroupManager) Exists() bool {
paths := m.GetPaths()
if paths != nil {
_, err := os.Lstat(paths["devices"])
return err == nil
}
return false
_, err := os.Lstat(m.Path("devices"))
return err == nil
}
func (m *mockCgroupManager) GetPaths() map[string]string {