github.com/kubewharf/katalyst-core@v0.5.3/cmd/katalyst-agent/app/agent/orm.go (about) 1 /* 2 Copyright 2022 The Katalyst Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package agent 18 19 import ( 20 "fmt" 21 22 "k8s.io/klog/v2" 23 plugincache "k8s.io/kubernetes/pkg/kubelet/pluginmanager/cache" 24 25 "github.com/kubewharf/katalyst-core/pkg/agent/orm" 26 "github.com/kubewharf/katalyst-core/pkg/config" 27 ) 28 29 const ( 30 ORMAgent = orm.ORMAgentName 31 ) 32 33 func InitORM(agentCtx *GenericContext, conf *config.Configuration, _ interface{}, _ string) (bool, Component, error) { 34 m, err := orm.NewManager(conf.PluginRegistrationDir+"/kubelet.sock", agentCtx.EmitterPool.GetDefaultMetricsEmitter(), agentCtx.MetaServer, conf) 35 if err != nil { 36 return false, ComponentStub{}, fmt.Errorf("failed to init ORM: %v", err) 37 } 38 39 if klog.V(5).Enabled() { 40 klog.Infof("InitORM GetHandlerType: %v", m.GetHandlerType()) 41 } 42 agentCtx.PluginManager.AddHandler(m.GetHandlerType(), plugincache.PluginHandler(m)) 43 return true, m, nil 44 }