container.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright 2014 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. // Package container defines types for sub-container events and also
  15. // defines an interface for container operation handlers.
  16. package container
  17. import info "github.com/google/cadvisor/info/v1"
  18. // ListType describes whether listing should be just for a
  19. // specific container or performed recursively.
  20. type ListType int
  21. const (
  22. ListSelf ListType = iota
  23. ListRecursive
  24. )
  25. type ContainerType int
  26. const (
  27. ContainerTypeRaw ContainerType = iota
  28. ContainerTypeDocker
  29. ContainerTypeSystemd
  30. ContainerTypeCrio
  31. ContainerTypeContainerd
  32. ContainerTypeMesos
  33. )
  34. // Interface for container operation handlers.
  35. type ContainerHandler interface {
  36. // Returns the ContainerReference
  37. ContainerReference() (info.ContainerReference, error)
  38. // Returns container's isolation spec.
  39. GetSpec() (info.ContainerSpec, error)
  40. // Returns the current stats values of the container.
  41. GetStats() (*info.ContainerStats, error)
  42. // Returns the subcontainers of this container.
  43. ListContainers(listType ListType) ([]info.ContainerReference, error)
  44. // Returns the processes inside this container.
  45. ListProcesses(listType ListType) ([]int, error)
  46. // Returns absolute cgroup path for the requested resource.
  47. GetCgroupPath(resource string) (string, error)
  48. // Returns container labels, if available.
  49. GetContainerLabels() map[string]string
  50. // Returns the container's ip address, if available
  51. GetContainerIPAddress() string
  52. // Returns whether the container still exists.
  53. Exists() bool
  54. // Cleanup frees up any resources being held like fds or go routines, etc.
  55. Cleanup()
  56. // Start starts any necessary background goroutines - must be cleaned up in Cleanup().
  57. // It is expected that most implementations will be a no-op.
  58. Start()
  59. // Type of handler
  60. Type() ContainerType
  61. }