pleg.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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/kubernetes/pkg/types"
  16. )
  17. type PodLifeCycleEventType string
  18. const (
  19. ContainerStarted PodLifeCycleEventType = "ContainerStarted"
  20. ContainerDied PodLifeCycleEventType = "ContainerDied"
  21. ContainerRemoved PodLifeCycleEventType = "ContainerRemoved"
  22. // PodSync is used to trigger syncing of a pod when the observed change of
  23. // the state of the pod cannot be captured by any single event above.
  24. PodSync PodLifeCycleEventType = "PodSync"
  25. // Do not use the events below because they are disabled in GenericPLEG.
  26. ContainerChanged PodLifeCycleEventType = "ContainerChanged"
  27. )
  28. // PodLifecycleEvent is an event that reflects the change of the pod state.
  29. type PodLifecycleEvent struct {
  30. // The pod ID.
  31. ID types.UID
  32. // The type of the event.
  33. Type PodLifeCycleEventType
  34. // The accompanied data which varies based on the event type.
  35. // - ContainerStarted/ContainerStopped: the container name (string).
  36. // - All other event types: unused.
  37. Data interface{}
  38. }
  39. type PodLifecycleEventGenerator interface {
  40. Start()
  41. Watch() chan *PodLifecycleEvent
  42. Healthy() (bool, error)
  43. }