X Tutup
Skip to content

Commit 91525bf

Browse files
committed
api.proto: Add pidsLimit
pidsLimit is required to enable updating PidsLimit of containers. Also, updated runtime Resources, UpdateResources and ctr with pidsLimit. Signed-off-by: Sunny Gogoi <indiasuny000@gmail.com>
1 parent 0890045 commit 91525bf

File tree

6 files changed

+192
-171
lines changed

6 files changed

+192
-171
lines changed

api/grpc/server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ func (s *apiServer) UpdateContainer(ctx context.Context, r *types.UpdateContaine
290290
if rs.MemorySwap != 0 {
291291
e.Resources.MemorySwap = int64(rs.MemorySwap)
292292
}
293+
if rs.PidsLimit != 0 {
294+
e.Resources.PidsLimit = int64(rs.PidsLimit)
295+
}
293296
}
294297
s.sv.SendTask(e)
295298
if err := <-e.ErrorCh(); err != nil {

api/grpc/types/api.pb.go

Lines changed: 180 additions & 171 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/types/api.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ message UpdateResource {
210210
repeated ThrottleDevice blkioThrottleWriteBpsDevice = 15;
211211
repeated ThrottleDevice blkioThrottleReadIopsDevice = 16;
212212
repeated ThrottleDevice blkioThrottleWriteIopsDevice = 17;
213+
uint64 pidsLimit = 18;
213214
}
214215

215216
message BlockIODevice {

ctr/container.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,9 @@ var updateCommand = cli.Command{
627627
cli.StringFlag{
628628
Name: "cpuset-mems",
629629
},
630+
cli.StringFlag{
631+
Name: "pids-limit",
632+
},
630633
},
631634
Action: func(context *cli.Context) {
632635
req := &types.UpdateContainerRequest{
@@ -644,6 +647,7 @@ var updateCommand = cli.Command{
644647
req.Resources.CpusetMems = context.String("cpuset-mems")
645648
req.Resources.KernelMemoryLimit = getUpdateCommandInt64Flag(context, "kernel-limit")
646649
req.Resources.KernelTCPMemoryLimit = getUpdateCommandInt64Flag(context, "kernel-tcp-limit")
650+
req.Resources.PidsLimit = getUpdateCommandInt64Flag(context, "pids-limit")
647651
c := getClient(context)
648652
if _, err := c.UpdateContainer(netcontext.Background(), req); err != nil {
649653
fatal(err.Error(), 1)

runtime/container_linux.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ func (c *container) UpdateResources(r *Resource) error {
127127
BlockIO: &ocs.BlockIO{
128128
Weight: &r.BlkioWeight,
129129
},
130+
Pids: &ocs.Pids{
131+
Limit: &r.PidsLimit,
132+
},
130133
}
131134

132135
srStr := bytes.NewBuffer(nil)

runtime/runtime.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ type Resource struct {
9595
Memory int64
9696
MemoryReservation int64
9797
MemorySwap int64
98+
PidsLimit int64
9899
}
99100

100101
// Possible container states

0 commit comments

Comments
 (0)
X Tutup