Skip to content

Commit

Permalink
Merge pull request #726 from darkowlzz/add-pidsLimit
Browse files Browse the repository at this point in the history
api.proto: Add pidsLimit
  • Loading branch information
crosbymichael authored Apr 14, 2017
2 parents 0890045 + 91525bf commit a47bf53
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 171 deletions.
3 changes: 3 additions & 0 deletions api/grpc/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ func (s *apiServer) UpdateContainer(ctx context.Context, r *types.UpdateContaine
if rs.MemorySwap != 0 {
e.Resources.MemorySwap = int64(rs.MemorySwap)
}
if rs.PidsLimit != 0 {
e.Resources.PidsLimit = int64(rs.PidsLimit)
}
}
s.sv.SendTask(e)
if err := <-e.ErrorCh(); err != nil {
Expand Down
351 changes: 180 additions & 171 deletions api/grpc/types/api.pb.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/grpc/types/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ message UpdateResource {
repeated ThrottleDevice blkioThrottleWriteBpsDevice = 15;
repeated ThrottleDevice blkioThrottleReadIopsDevice = 16;
repeated ThrottleDevice blkioThrottleWriteIopsDevice = 17;
uint64 pidsLimit = 18;
}

message BlockIODevice {
Expand Down
4 changes: 4 additions & 0 deletions ctr/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,9 @@ var updateCommand = cli.Command{
cli.StringFlag{
Name: "cpuset-mems",
},
cli.StringFlag{
Name: "pids-limit",
},
},
Action: func(context *cli.Context) {
req := &types.UpdateContainerRequest{
Expand All @@ -644,6 +647,7 @@ var updateCommand = cli.Command{
req.Resources.CpusetMems = context.String("cpuset-mems")
req.Resources.KernelMemoryLimit = getUpdateCommandInt64Flag(context, "kernel-limit")
req.Resources.KernelTCPMemoryLimit = getUpdateCommandInt64Flag(context, "kernel-tcp-limit")
req.Resources.PidsLimit = getUpdateCommandInt64Flag(context, "pids-limit")
c := getClient(context)
if _, err := c.UpdateContainer(netcontext.Background(), req); err != nil {
fatal(err.Error(), 1)
Expand Down
3 changes: 3 additions & 0 deletions runtime/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ func (c *container) UpdateResources(r *Resource) error {
BlockIO: &ocs.BlockIO{
Weight: &r.BlkioWeight,
},
Pids: &ocs.Pids{
Limit: &r.PidsLimit,
},
}

srStr := bytes.NewBuffer(nil)
Expand Down
1 change: 1 addition & 0 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type Resource struct {
Memory int64
MemoryReservation int64
MemorySwap int64
PidsLimit int64
}

// Possible container states
Expand Down

0 comments on commit a47bf53

Please sign in to comment.