Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgroup cleanups #2959

Merged
merged 8 commits into from
Oct 21, 2021
Merged

cgroup cleanups #2959

merged 8 commits into from
Oct 21, 2021

Commits on Oct 21, 2021

  1. container: remove Mounts from CgroupSubsystems

    This field is only used
     - to check if there are any mounts, i.e. len() == 0;
     - to iterate over the list of mounts in watcher.
    
    In both cases, we can reuse MountPoints without any degradation.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Oct 21, 2021
    Configuration menu
    Copy the full SHA
    591efd8 View commit details
    Browse the repository at this point in the history
  2. container: rm cgroupFilesystems from rawContainerWatcher

    cgroupPaths was basically a copy of cgroupSubsystems.MountPoints.
    This is because it was produced from the elements of the latter
    by calling common.MakeCgroupPaths() with the second argument of "/".
    Note that path.Join(something, "/") will return something.
    
    Since we have two copies of the same info, let's remove one and reuse
    the other.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Oct 21, 2021
    Configuration menu
    Copy the full SHA
    02d9fb2 View commit details
    Browse the repository at this point in the history
  3. Convert CgroupPaths from struct to map

    As this structure only have 1 element now, it does not make sense to
    have it as a structure.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Oct 21, 2021
    Configuration menu
    Copy the full SHA
    d03222e View commit details
    Browse the repository at this point in the history
  4. container: rm CgroupSubsystems type

    Replace it with map[string]string, which it is. This is a continuation
    of the previous commit, separated out for review clarity.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Oct 21, 2021
    Configuration menu
    Copy the full SHA
    ea2b951 View commit details
    Browse the repository at this point in the history
  5. container: GetCgroupSubsystems: simplify

    Instead of creating an intermediate map to remove specific mounts based
    on MetricSet, amend the supportedSubsystems map to have information
    about which subsystem reports which metrics.
    
    Based on that info, the check whether the subsystem is needed or not
    becomes much simpler.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Oct 21, 2021
    Configuration menu
    Copy the full SHA
    ca997e3 View commit details
    Browse the repository at this point in the history
  6. container: rm libcontainer.GetAllCgroupSubsystems

    It is equivalent to GetCgroupSubsystems(nil) which is easy to use,
    and there's only one user. Remove the function, patch the user.
    
    While at it, document the includeMetrics argument of
    GetCgroupSubsystems.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Oct 21, 2021
    Configuration menu
    Copy the full SHA
    891811e View commit details
    Browse the repository at this point in the history
  7. container/libcontainer: simplify for cgroup v2

    In case of cgroup v2, there are no separate per-subsystem mount points,
    and so it does not make sense to have a subsystem to mountpoint map.
    
    Yet for the unification of code between v1 and v2, we still use this
    map, although a single element is enough.
    
    For cgroup v2, the key is "", the value is the mount point (or the path
    to a specific cgroup).
    
    This commit
     - simplifes GetCgroupSubsystems for cgroup v2 (trivial) case;
     - modifies GetCgroupPath() methods to use "" as the key for cgroup v2;
     - fixes NewCgroupManager() to use "" as the key for cgroup v2 case.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Oct 21, 2021
    Configuration menu
    Copy the full SHA
    1571e28 View commit details
    Browse the repository at this point in the history
  8. manager: simplify createContainer

    The code to initialize perf collector is almost the same between cgroup
    v1 and v2, the only difference is how we get cgroup path. Since now
    GetCgroupPath is v2 ready, we can use it, and thus unify these two
    cases.
    
    This commit is best reviewed with --ignore-space-change.
    
    Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
    kolyshkin committed Oct 21, 2021
    Configuration menu
    Copy the full SHA
    b470b6c View commit details
    Browse the repository at this point in the history