Skip to content

Commit

Permalink
feat: enhance orm by nri
Browse files Browse the repository at this point in the history
Signed-off-by: Airren <qiang.ren@intel.com>
  • Loading branch information
Airren committed Apr 24, 2024
1 parent 4edd0e2 commit 0664b75
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 78 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ GIT_VERSION=$(shell git describe --abbrev=0 --tags --always)
endif

IMAGE_TAG = ${GIT_VERSION}
REGISTRY ?= docker.io
REGISTRY ?= oss-community-cn-shanghai.cr.volces.com
REGISTRY_NAMESPACE ?= kubewharf
REGISTRY_USER ?= ""
REGISTRY_PWD ?= ""
Expand Down
45 changes: 32 additions & 13 deletions cmd/katalyst-agent/app/options/orm/orm_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,45 @@ import (
)

type GenericORMPluginOptions struct {
ORMRconcilePeriod time.Duration
ORMResourceNamesMap map[string]string
ORMPodNotifyChanLen int
TopologyPolicyName string
NumericAlignResources []string
ORMWorkMode string
ORMReconcilePeriod time.Duration
ORMResourceNamesMap map[string]string
ORMPodNotifyChanLen int
TopologyPolicyName string
NumericAlignResources []string
ORMPodResourcesSocket string
ORMDevicesProvider string
ORMKubeletPodResourcesEndpoints []string
ORMNRISocketPath string
ORMNRIPluginName string
ORMNRIPluginIndex string
ORMNRIHandleEvents string
}

func NewGenericORMPluginOptions() *GenericORMPluginOptions {
return &GenericORMPluginOptions{
ORMRconcilePeriod: time.Second * 5,
ORMResourceNamesMap: map[string]string{},
ORMPodNotifyChanLen: 10,
TopologyPolicyName: "",
NumericAlignResources: []string{"cpu", "memory"},
ORMWorkMode: "nri",
ORMReconcilePeriod: time.Second * 5,
ORMResourceNamesMap: map[string]string{},
ORMPodNotifyChanLen: 10,
TopologyPolicyName: "",
NumericAlignResources: []string{"cpu", "memory"},
ORMPodResourcesSocket: "unix:/var/lib/katalyst/pod-resources/kubelet.sock",
ORMDevicesProvider: "",
ORMKubeletPodResourcesEndpoints: []string{"/var/lib/kubelet/pod-resources/kubelet.sock"},
ORMNRISocketPath: "/var/run/nri/nri.sock",
ORMNRIPluginName: "orm",
ORMNRIPluginIndex: "00",
ORMNRIHandleEvents: "RunPodSandbox,CreateContainer,UpdateContainer,RemovePodSandbox",
}
}

func (o *GenericORMPluginOptions) AddFlags(fss *cliflag.NamedFlagSets) {
fs := fss.FlagSet("orm")

fs.DurationVar(&o.ORMRconcilePeriod, "orm-reconcile-period",
o.ORMRconcilePeriod, "orm resource reconcile period")
fs.StringVar(&o.ORMWorkMode, "orm-work-mode", o.ORMWorkMode, "orm work mode, nri or bypass")
fs.DurationVar(&o.ORMReconcilePeriod, "orm-reconcile-period",
o.ORMReconcilePeriod, "orm resource reconcile period")
fs.StringToStringVar(&o.ORMResourceNamesMap, "orm-resource-names-map", o.ORMResourceNamesMap,
"A set of ResourceName=ResourceQuantity pairs that map resource name during out-of-band Resource Manager allocation period. "+
"e.g. 'resource.katalyst.kubewharf.io/reclaimed_millicpu=cpu,resource.katalyst.kubewharf.io/reclaimed_memory=memory' "+
Expand All @@ -70,17 +81,25 @@ func (o *GenericORMPluginOptions) AddFlags(fss *cliflag.NamedFlagSets) {
"devices provider provides devices resources and allocatable for ORM podResources api")
fs.StringSliceVar(&o.ORMKubeletPodResourcesEndpoints, "orm-kubelet-pod-resources-endpoints", o.ORMKubeletPodResourcesEndpoints,
"kubelet podResources endpoints for ORM kubelet devices provider")
fs.StringVar(&o.ORMNRIPluginName, "orm-nri-plugin-name", o.ORMNRIPluginName, "orm nri plugin name")
fs.StringVar(&o.ORMNRIPluginIndex, "orm-nri-plugin-index", o.ORMNRIPluginIndex, "orm nri plugin index")
fs.StringVar(&o.ORMNRIHandleEvents, "orm-nri-handle-events", o.ORMNRIHandleEvents, "orm nri handle events")
}

func (o *GenericORMPluginOptions) ApplyTo(conf *ormconfig.GenericORMConfiguration) error {
conf.ORMRconcilePeriod = o.ORMRconcilePeriod
conf.ORMWorkMode = o.ORMWorkMode
conf.ORMReconcilePeriod = o.ORMReconcilePeriod
conf.ORMResourceNamesMap = o.ORMResourceNamesMap
conf.ORMPodNotifyChanLen = o.ORMPodNotifyChanLen
conf.TopologyPolicyName = o.TopologyPolicyName
conf.NumericAlignResources = o.NumericAlignResources
conf.ORMPodResourcesSocket = o.ORMPodResourcesSocket
conf.ORMDevicesProvider = o.ORMDevicesProvider
conf.ORMKubeletPodResourcesEndpoints = o.ORMKubeletPodResourcesEndpoints
conf.ORMNRISocketPath = o.ORMNRISocketPath
conf.ORMNRIPluginName = o.ORMNRIPluginName
conf.ORMNRIPluginIndex = o.ORMNRIPluginIndex
conf.ORMNRIHandleEvents = o.ORMNRIHandleEvents

return nil
}
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/cespare/xxhash v1.1.0
github.com/cilium/ebpf v0.7.0
github.com/containerd/cgroups v1.0.1
github.com/containerd/nri v0.6.0
github.com/evanphx/json-patch v5.6.0+incompatible
github.com/fsnotify/fsnotify v1.5.4
github.com/gogo/protobuf v1.3.2
Expand Down Expand Up @@ -70,6 +71,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/containerd/ttrpc v1.2.3-0.20231030150553-baadfd8e7956 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
Expand Down Expand Up @@ -99,7 +101,7 @@ require (
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/sys/mountinfo v0.6.0 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down
Loading

0 comments on commit 0664b75

Please sign in to comment.