pleg.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. Copyright 2015 The Kubernetes Authors.
  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. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package pleg
  14. import (
  15. "k8s.io/apimachinery/pkg/types"
  16. )
  17. // PodLifeCycleEventType define the event type of pod life cycle events.
  18. type PodLifeCycleEventType string
  19. const (
  20. // ContainerStarted - event type when the new state of container is running.
  21. ContainerStarted PodLifeCycleEventType = "ContainerStarted"
  22. // ContainerDied - event type when the new state of container is exited.
  23. ContainerDied PodLifeCycleEventType = "ContainerDied"
  24. // ContainerRemoved - event type when the old state of container is exited.
  25. ContainerRemoved PodLifeCycleEventType = "ContainerRemoved"
  26. // PodSync is used to trigger syncing of a pod when the observed change of
  27. // the state of the pod cannot be captured by any single event above.
  28. PodSync PodLifeCycleEventType = "PodSync"
  29. // ContainerChanged - event type when the new state of container is unknown.
  30. ContainerChanged PodLifeCycleEventType = "ContainerChanged"
  31. )
  32. // PodLifecycleEvent is an event that reflects the change of the pod state.
  33. type PodLifecycleEvent struct {
  34. // The pod ID.
  35. ID types.UID
  36. // The type of the event.
  37. Type PodLifeCycleEventType
  38. // The accompanied data which varies based on the event type.
  39. // - ContainerStarted/ContainerStopped: the container name (string).
  40. // - All other event types: unused.
  41. Data interface{}
  42. }
  43. // PodLifecycleEventGenerator contains functions for generating pod life cycle events.
  44. type PodLifecycleEventGenerator interface {
  45. Start()
  46. Watch() chan *PodLifecycleEvent
  47. Healthy() (bool, error)
  48. }