@@ -56,6 +56,9 @@ func collectCreateContainerResult(request *CreateContainerRequest) *result {
5656 if request .Container .Hooks == nil {
5757 request .Container .Hooks = & Hooks {}
5858 }
59+ if request .Container .Rlimits == nil {
60+ request .Container .Rlimits = []* POSIXRlimit {}
61+ }
5962 if request .Container .Linux == nil {
6063 request .Container .Linux = & LinuxContainer {}
6164 }
@@ -85,6 +88,7 @@ func collectCreateContainerResult(request *CreateContainerRequest) *result {
8588 Mounts : []* Mount {},
8689 Env : []* KeyValue {},
8790 Hooks : & Hooks {},
91+ Rlimits : []* POSIXRlimit {},
8892 Linux : & LinuxContainerAdjustment {
8993 Devices : []* LinuxDevice {},
9094 Resources : & LinuxResources {
@@ -210,6 +214,9 @@ func (r *result) adjust(rpl *ContainerAdjustment, plugin string) error {
210214 return err
211215 }
212216 }
217+ if err := r .adjustRlimits (rpl .Rlimits , plugin ); err != nil {
218+ return err
219+ }
213220
214221 return nil
215222}
@@ -659,6 +666,19 @@ func (r *result) adjustCgroupsPath(path, plugin string) error {
659666 return nil
660667}
661668
669+ func (r * result ) adjustRlimits (rlimits []* POSIXRlimit , plugin string ) error {
670+ create , id , adjust := r .request .create , r .request .create .Container .Id , r .reply .adjust
671+ for _ , l := range rlimits {
672+ if err := r .owners .claimRlimits (id , l .Type , plugin ); err != nil {
673+ return err
674+ }
675+
676+ create .Container .Rlimits = append (create .Container .Rlimits , l )
677+ adjust .Rlimits = append (adjust .Rlimits , l )
678+ }
679+ return nil
680+ }
681+
662682func (r * result ) updateResources (reply , u * ContainerUpdate , plugin string ) error {
663683 if u .Linux == nil || u .Linux .Resources == nil {
664684 return nil
@@ -873,6 +893,7 @@ type owners struct {
873893 rdtClass string
874894 unified map [string ]string
875895 cgroupsPath string
896+ rlimits map [string ]string
876897}
877898
878899func (ro resultOwners ) ownersFor (id string ) * owners {
@@ -980,6 +1001,10 @@ func (ro resultOwners) claimCgroupsPath(id, plugin string) error {
9801001 return ro .ownersFor (id ).claimCgroupsPath (plugin )
9811002}
9821003
1004+ func (ro resultOwners ) claimRlimits (id , typ , plugin string ) error {
1005+ return ro .ownersFor (id ).claimRlimit (typ , plugin )
1006+ }
1007+
9831008func (o * owners ) claimAnnotation (key , plugin string ) error {
9841009 if o .annotations == nil {
9851010 o .annotations = make (map [string ]string )
@@ -1183,6 +1208,17 @@ func (o *owners) claimUnified(key, plugin string) error {
11831208 return nil
11841209}
11851210
1211+ func (o * owners ) claimRlimit (typ , plugin string ) error {
1212+ if o .rlimits == nil {
1213+ o .rlimits = make (map [string ]string )
1214+ }
1215+ if other , taken := o .rlimits [typ ]; taken {
1216+ return conflict (plugin , other , "rlimit" , typ )
1217+ }
1218+ o .rlimits [typ ] = plugin
1219+ return nil
1220+ }
1221+
11861222func (o * owners ) claimCgroupsPath (plugin string ) error {
11871223 if other := o .cgroupsPath ; other != "" {
11881224 return conflict (plugin , other , "cgroups path" )
0 commit comments