container.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. ContainerTypeRkt
  30. ContainerTypeSystemd
  31. ContainerTypeCrio
  32. ContainerTypeContainerd
  33. ContainerTypeMesos
  34. )
  35. // Interface for container operation handlers.
  36. type ContainerHandler interface {
  37. // Returns the ContainerReference
  38. ContainerReference() (info.ContainerReference, error)
  39. // Returns container's isolation spec.
  40. GetSpec() (info.ContainerSpec, error)
  41. // Returns the current stats values of the container.
  42. GetStats() (*info.ContainerStats, error)
  43. // Returns the subcontainers of this container.
  44. ListContainers(listType ListType) ([]info.ContainerReference, error)
  45. // Returns the processes inside this container.
  46. ListProcesses(listType ListType) ([]int, error)
  47. // Returns absolute cgroup path for the requested resource.
  48. GetCgroupPath(resource string) (string, error)
  49. // Returns container labels, if available.
  50. GetContainerLabels() map[string]string
  51. // Returns the container's ip address, if available
  52. GetContainerIPAddress() string
  53. // Returns whether the container still exists.
  54. Exists() bool
  55. // Cleanup frees up any resources being held like fds or go routines, etc.
  56. Cleanup()
  57. // Start starts any necessary background goroutines - must be cleaned up in Cleanup().
  58. // It is expected that most implementations will be a no-op.
  59. Start()
  60. // Type of handler
  61. Type() ContainerType
  62. }