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 Jun 27, 2024
1 parent 022f72a commit 1aac63c
Show file tree
Hide file tree
Showing 9 changed files with 621 additions and 74 deletions.
29 changes: 24 additions & 5 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
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,
ORMWorkMode: "bypass",
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
}
32 changes: 18 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ 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
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/golang/protobuf v1.5.3
github.com/google/cadvisor v0.44.2
github.com/google/uuid v1.3.0
github.com/h2non/gock v1.2.0
Expand All @@ -38,10 +39,10 @@ require (
go.opentelemetry.io/otel/sdk/export/metric v0.20.0
go.opentelemetry.io/otel/sdk/metric v0.20.0
go.uber.org/atomic v1.9.0
golang.org/x/sys v0.7.0
golang.org/x/sys v0.13.0
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
gonum.org/v1/gonum v0.8.2
google.golang.org/grpc v1.51.0
google.golang.org/grpc v1.57.1
gopkg.in/yaml.v3 v3.0.1
gotest.tools/v3 v3.0.3
k8s.io/api v0.26.1
Expand All @@ -52,7 +53,7 @@ require (
k8s.io/client-go v0.26.1
k8s.io/component-base v0.25.0
k8s.io/component-helpers v0.24.16
k8s.io/cri-api v0.24.6
k8s.io/cri-api v0.25.3
k8s.io/klog/v2 v2.80.1
k8s.io/kube-aggregator v0.24.6
k8s.io/kubelet v0.24.6
Expand All @@ -71,7 +72,8 @@ require (
github.com/OneOfOne/xxhash v1.2.5 // indirect
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/cespare/xxhash/v2 v2.2.0 // 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 @@ -102,14 +104,14 @@ 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
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20220825212826-86290f6a00fb // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
Expand All @@ -126,19 +128,21 @@ require (
go.opentelemetry.io/proto/otlp v0.7.0 // indirect
go.uber.org/multierr v1.7.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
gomodules.xyz/jsonpatch/v3 v3.0.1 // indirect
gomodules.xyz/orderedmap v0.1.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/genproto v0.0.0-20230706204954-ccb25ca9f130 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230629202037-9506855d4529 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230731190214-cbb8c96f2d6d // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
Expand Down
Loading

0 comments on commit 1aac63c

Please sign in to comment.