-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3090 from kolyshkin/cfq_quota_period
libct/cg/v1: work around CPU quota period set failure
- Loading branch information
Showing
6 changed files
with
226 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/sirupsen/logrus" | ||
|
||
"github.com/opencontainers/runc/libcontainer/cgroups" | ||
"github.com/opencontainers/runc/libcontainer/cgroups/systemd" | ||
"github.com/opencontainers/runc/libcontainer/configs" | ||
) | ||
|
||
func usage() { | ||
fmt.Print(`Open Container Initiative contrib/cmd/sd-helper | ||
sd-helper is a tool that uses runc/libcontainer/cgroups/systemd package | ||
functionality to communicate to systemd in order to perform various operations. | ||
Currently this is limited to starting and stopping systemd transient slice | ||
units. | ||
Usage: | ||
sd-helper [-debug] [-parent <pname>] {start|stop} <name> | ||
Example: | ||
sd-helper -parent system.slice start system-pod123.slice | ||
`) | ||
os.Exit(1) | ||
} | ||
|
||
var ( | ||
debug = flag.Bool("debug", false, "enable debug output") | ||
parent = flag.String("parent", "", "parent unit name") | ||
) | ||
|
||
func main() { | ||
if !systemd.IsRunningSystemd() { | ||
logrus.Fatal("systemd is required") | ||
} | ||
|
||
// Set the flags. | ||
flag.Parse() | ||
if *debug { | ||
logrus.SetLevel(logrus.DebugLevel) | ||
} | ||
if flag.NArg() != 2 { | ||
usage() | ||
} | ||
|
||
cmd := flag.Arg(0) | ||
unit := flag.Arg(1) | ||
|
||
err := unitCommand(cmd, unit, *parent) | ||
if err != nil { | ||
logrus.Fatal(err) | ||
} | ||
} | ||
|
||
func newManager(config *configs.Cgroup) cgroups.Manager { | ||
if cgroups.IsCgroup2UnifiedMode() { | ||
return systemd.NewUnifiedManager(config, "", false) | ||
} | ||
return systemd.NewLegacyManager(config, nil) | ||
} | ||
|
||
func unitCommand(cmd, name, parent string) error { | ||
podConfig := &configs.Cgroup{ | ||
Name: name, | ||
Parent: parent, | ||
Resources: &configs.Resources{}, | ||
} | ||
pm := newManager(podConfig) | ||
|
||
switch cmd { | ||
case "start": | ||
return pm.Apply(-1) | ||
case "stop": | ||
return pm.Destroy() | ||
} | ||
|
||
return fmt.Errorf("unknown command: %s", cmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters