This patchset adds an options column to cgrules config file
parsing.  Within this column, a user can specify an "ignore"
option that will instruct cgrules to ignore processes that
exactly match this rule and perform no processing on these
processes.  It is anticipated that a separate process - outside
of cgrulesengd - will be used to manage processes that match
ignore rules.

A couple examples:

<user>      <controller>        <destination>        <options>
tom:http*   memory              TomsCgroup           ignore
*           memory              DefaultCgroup

For the above example:
    * A new process named httpd spawned in TomsCgroup within the 
      memory controller will be ignored by cgrulesengd.  Again,
      it's expected that another process will manage the processes
      within TomsCgroup
    * Similarly processes named http, httpX, http70, etc. within
      TomsCgroup will also be ignored
    * cgrulesengd will attempt to move any processes that do not 
      match the ignore rule into the DefaultCgroup

<user>      <controller>        <destination>        <options>
*           cpu                 IgnoreCG/            ignore
*           cpu                 DefaultCgroup

For the above example:
    * Any new processes spawned within the IgnoreCG or a child
      cgroup within IgnoreCG will be ignored by cgrulesengd
    * cgrulesengd will attempt to move any processes that do not 
      match the ignore rule into the DefaultCgroup

All functional tests and unit tests are passing:
    https://travis-ci.com/drakenclimber/libcgroup/builds/139807850

Code coverage increased from 16% to 18%.  The logic added for 
this commit was fully covered with the exception of a few error
handling cases:
    https://coveralls.io/builds/27467169

The code is also available on github here:
    https://github.com/drakenclimber/libcgroup/tree/issues/ignore_field_v4

Changes from v3 to v4:
* Removed the '*' wildcard logic from the ignore rule's destination
  field.  It now assumes wildcarding by default
* Updated the tests accordingly
Changes from v2 to v3:
* Fixed a couple compiler warnings
* Added logic to handle SomeCgroup/* to cgroup_compare_ignore_rule().
  Prior to v3, it couldn't properly match SomeGroup to SomeGroup/*
  because of the trailing "/"
* Added a couple more tests to handle the forward slash logic
  outlined above
Changes from v1 to v2:
* Split MAX_MNT_ELEMENTS change into its own patch
* Added test results to commit messages

Tom Hromatka (10):
  tests: Add STATIC and UNIT_TEST definitions to automake files
  api: Increase MAX_MNT_ELEMENTS to 16
  api.c: Add options field for rules defined in cgrules conf file
  tests: Add unit tests for cgroup_parse_rules_options()
  api.c: Add function to read /proc/{pid}/cgroup
  tests: Add unit tests for cg_get_cgroups_from_proc_cgroups()
  api.c: Add logic to process ignore rules
  tests: Add unit tests for cgroup_compare_ignore_rule()
  cgrulesengd: Add wildcard matching for process names
  tests: Add unit tests for cgroup_compare_wildcard_procname()

 src/Makefile.am                                    |   4 +-
 src/api.c                                          | 387 ++++++++++++++++++++-
 src/libcgroup-internal.h                           |  30 +-
 tests/gunit/002-cgroup_parse_rules_options.cpp     | 105 ++++++
 .../gunit/003-cg_get_cgroups_from_proc_cgroups.cpp | 175 ++++++++++
 tests/gunit/004-cgroup_compare_ignore_rule.cpp     | 384 ++++++++++++++++++++
 .../gunit/005-cgroup_compare_wildcard_procname.cpp |  97 ++++++
 tests/gunit/Makefile.am                            |  10 +-
 8 files changed, 1183 insertions(+), 9 deletions(-)
 create mode 100644 tests/gunit/002-cgroup_parse_rules_options.cpp
 create mode 100644 tests/gunit/003-cg_get_cgroups_from_proc_cgroups.cpp
 create mode 100644 tests/gunit/004-cgroup_compare_ignore_rule.cpp
 create mode 100644 tests/gunit/005-cgroup_compare_wildcard_procname.cpp

-- 
1.8.3.1



_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to