github.com/google/cadvisor@v0.49.1/container/systemd/factory.go (about) 1 // Copyright 2016 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package systemd 16 17 import ( 18 "fmt" 19 "strings" 20 21 "github.com/google/cadvisor/container" 22 "github.com/google/cadvisor/fs" 23 info "github.com/google/cadvisor/info/v1" 24 "github.com/google/cadvisor/watcher" 25 26 "k8s.io/klog/v2" 27 ) 28 29 type systemdFactory struct{} 30 31 func (f *systemdFactory) String() string { 32 return "systemd" 33 } 34 35 func (f *systemdFactory) NewContainerHandler(name string, metadataEnvAllowList []string, inHostNamespace bool) (container.ContainerHandler, error) { 36 return nil, fmt.Errorf("Not yet supported") 37 } 38 39 func (f *systemdFactory) CanHandleAndAccept(name string) (bool, bool, error) { 40 // on systemd using devicemapper each mount into the container has an associated cgroup that we ignore. 41 // for details on .mount units: http://man7.org/linux/man-pages/man5/systemd.mount.5.html 42 if strings.HasSuffix(name, ".mount") { 43 return true, false, nil 44 } 45 klog.V(5).Infof("%s not handled by systemd handler", name) 46 return false, false, nil 47 } 48 49 func (f *systemdFactory) DebugInfo() map[string][]string { 50 return map[string][]string{} 51 } 52 53 // Register registers the systemd container factory. 54 func Register(machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, includedMetrics container.MetricSet) error { 55 klog.V(1).Infof("Registering systemd factory") 56 factory := &systemdFactory{} 57 container.RegisterContainerHandlerFactory(factory, []watcher.ContainerWatchSource{watcher.Raw}) 58 return nil 59 }