// NewKataMonitor create and return a new KataMonitor instance
NewKataMonitor create and return a new KataMonitor instance
// NewKataMonitor create and return a new KataMonitor instance
func NewKataMonitor(containerdAddr, containerdConfigFile string) (*KataMonitor, error) {
	if containerdAddr == "" {
		return nil, fmt.Errorf("Containerd serve address missing.")
	}
	containerdConf := &srvconfig.Config{
		State: defaults.DefaultStateDir,
	}
	if err := srvconfig.LoadConfig(containerdConfigFile, containerdConf); err != nil && !os.IsNotExist(err) {
		return nil, err
	}
	ka := &KataMonitor{
		containerdAddr:       containerdAddr,
		containerdConfigFile: containerdConfigFile,
		containerdStatePath:  containerdConf.State,
		sandboxCache: &sandboxCache{
			Mutex:     &sync.Mutex{},
			sandboxes: make(map[string]string),
		},
	}
	if err := ka.initSandboxCache(); err != nil {
		return nil, err
	}
	registerMetrics()
	go ka.sandboxCache.startEventsListener(ka.containerdAddr)
	return ka, nil
}
func NewKataMonitor ( containerdAddr , containerdConfigFile string ) ( * KataMonitor , error ) { if containerdAddr == " " { return nil , fmt . Errorf ( " " ) } containerdConf := & srvconfig . Config { State : defaults . DefaultStateDir , } if err := srvconfig . LoadConfig ( containerdConfigFile , containerdConf ) ; err != nil && ! os . IsNotExist ( err ) { return nil , err } ka := & KataMonitor { containerdAddr : containerdAddr , containerdConfigFile : containerdConfigFile , containerdStatePath : containerdConf . State , sandboxCache : & sandboxCache { Mutex : & sync . Mutex { } , sandboxes : make ( map [ string ] string ) , } , } if err := ka . initSandboxCache ( ) ; err != nil { return nil , err } registerMetrics ( ) go ka . sandboxCache . startEventsListener ( ka . containerdAddr ) return ka , nil }
NewKataMonitor create and return a new KataMonitor instance
NewKataMonitor create and return a new KataMonitor instance
// register metrics