Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions pkg/adaptation/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ func (r *result) adjust(rpl *ContainerAdjustment, plugin string) error {
if err := r.adjustOomScoreAdj(rpl.Linux.OomScoreAdj, plugin); err != nil {
return err
}
if err := r.adjustNamespaces(rpl.Linux.Namespaces, plugin); err != nil {
return err
}
}
if err := r.adjustRlimits(rpl.Rlimits, plugin); err != nil {
return err
Expand Down Expand Up @@ -738,6 +741,22 @@ func (r *result) adjustOomScoreAdj(OomScoreAdj *OptionalInt, plugin string) erro
return nil
}

func (r *result) adjustNamespaces(adjustment []*LinuxNamespace, plugin string) error {
if adjustment == nil {
return nil
}
create, id := r.request.create, r.request.create.Container.Id

if err := r.owners.claimNamespaces(id, plugin); err != nil {
return err
}

create.Container.Linux.Namespaces = adjustment
r.reply.adjust.Linux.Namespaces = adjustment

return nil
}

func (r *result) adjustRlimits(rlimits []*POSIXRlimit, plugin string) error {
create, id, adjust := r.request.create, r.request.create.Container.Id, r.reply.adjust
for _, l := range rlimits {
Expand Down Expand Up @@ -976,6 +995,7 @@ type owners struct {
unified map[string]string
cgroupsPath string
oomScoreAdj string
namespaces string
rlimits map[string]string
}

Expand Down Expand Up @@ -1096,6 +1116,10 @@ func (ro resultOwners) claimOomScoreAdj(id, plugin string) error {
return ro.ownersFor(id).claimOomScoreAdj(plugin)
}

func (ro resultOwners) claimNamespaces(id, plugin string) error {
return ro.ownersFor(id).claimNamespaces(plugin)
}

func (ro resultOwners) claimRlimits(id, typ, plugin string) error {
return ro.ownersFor(id).claimRlimit(typ, plugin)
}
Expand Down Expand Up @@ -1349,6 +1373,14 @@ func (o *owners) claimOomScoreAdj(plugin string) error {
return nil
}

func (o *owners) claimNamespaces(plugin string) error {
if other := o.namespaces; other != "" {
return conflict(plugin, other, "namespaces")
}
o.namespaces = plugin
return nil
}

func (ro resultOwners) clearAnnotation(id, key string) {
ro.ownersFor(id).clearAnnotation(key)
}
Expand Down
Loading
Loading