containerd / nri

Node Resource Interface
Apache License 2.0
257 stars 65 forks source link

Support adjust oom_Score_adj for NRI plugins #92

Closed zxj874478410 closed 3 months ago

zxj874478410 commented 4 months ago

The LinuxContainer structure transferred by the containerd contains the OomScoreAdj field. However, the NRI plugins do not support the adjustment of this field. Theoretically, the OomScoreAdj field should be customized by users to provide more refined QoS control.

The definition of LinuxContainer:

type LinuxContainer struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields

    Namespaces  []*LinuxNamespace `protobuf:"bytes,1,rep,name=namespaces,proto3" json:"namespaces,omitempty"`
    Devices     []*LinuxDevice    `protobuf:"bytes,2,rep,name=devices,proto3" json:"devices,omitempty"`
    Resources   *LinuxResources   `protobuf:"bytes,3,opt,name=resources,proto3" json:"resources,omitempty"`
    OomScoreAdj *OptionalInt      `protobuf:"bytes,4,opt,name=oom_score_adj,json=oomScoreAdj,proto3" json:"oom_score_adj,omitempty"`
    CgroupsPath string            `protobuf:"bytes,5,opt,name=cgroups_path,json=cgroupsPath,proto3" json:"cgroups_path,omitempty"`
}

The definition of LinuxContainerAdjustment:

type LinuxContainerAdjustment struct {
    state         protoimpl.MessageState
    sizeCache     protoimpl.SizeCache
    unknownFields protoimpl.UnknownFields

    Devices     []*LinuxDevice  `protobuf:"bytes,1,rep,name=devices,proto3" json:"devices,omitempty"`
    Resources   *LinuxResources `protobuf:"bytes,2,opt,name=resources,proto3" json:"resources,omitempty"`
    CgroupsPath string          `protobuf:"bytes,3,opt,name=cgroups_path,json=cgroupsPath,proto3" json:"cgroups_path,omitempty"`
}

Obviously, losing the ability to oom adjust is not reasonable.

samuelkarp commented 4 months ago

Obviously, losing the ability to oom adjust is not reasonable.

NRI currently supports a subset of fields as adjustable, and accepts pull requests to increase the set of supported fields. Supporting a subset was a reasonable mechanism to start experimenting with NRI and discovering use-cases that it can satisfy.

I would be open to supporting OomScoreAdj.

zxj874478410 commented 4 months ago

NRI currently supports a subset of fields as adjustable, and accepts pull requests to increase the set of supported fields. Supporting a subset was a reasonable mechanism to start experimenting with NRI and discovering use-cases that it can satisfy.

I tried to modify some of the NRI code to add the ability to adjust the OomScoreAdj, and it passed the functional verification. The relevant code is attached in PR #94.