Documentation
¶
Index ¶
- Constants
- func ExtractContainersFromPod(pod *corev1.Pod) map[string]*Container
- type Container
- type ContainerList
- func (cl *ContainerList) AddContainer(c *Container)
- func (cl ContainerList) EnsureContainer(c *Container) error
- func (cl *ContainerList) EnsurePodStatus(pod *corev1.Pod) error
- func (cl *ContainerList) GetContainer(uid string) (*Container, bool)
- func (cl *ContainerList) RemoveContainer(uid string) error
- func (cl *ContainerList) UpdateContainer(c *Container) error
- type Extension
- type GraceOptions
- type Loggregator
- type LoggregatorAppMeta
- type LoggregatorLogger
- type PodWatcher
Constants ¶
const ( DefaultStagingExecutorEntrypoint = "/packs/executor" DefaultStagingDownloaderEntrypoint = "/packs/downloader" DefaultStagingUploaderEntrypoint = "/packs/uploader" DefaultRuntimeEntrypoint = "/lifecycle/launch" DefaultFailGracePeriod = "5" DefaultSuccessGracePeriod = "5" )
https://github.com/cloudfoundry-incubator/eirini-staging/tree/master/image
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Container ¶
type Container struct { PodName string Namespace string Name string PodUID string UID string InitContainer bool State *corev1.ContainerState LoggregatorOptions config.LoggregatorOptions Loggregator *Loggregator AppMeta *LoggregatorAppMeta }
type ContainerList ¶
type ContainerList struct { Containers map[string]*Container KubeConfig *rest.Config LoggregatorOptions config.LoggregatorOptions Tails sync.WaitGroup Context context.Context }
func (*ContainerList) AddContainer ¶
func (cl *ContainerList) AddContainer(c *Container)
func (ContainerList) EnsureContainer ¶
func (cl ContainerList) EnsureContainer(c *Container) error
EnsureContainer make sure the container exists in the list and we are monitoring it.
func (*ContainerList) EnsurePodStatus ¶
func (cl *ContainerList) EnsurePodStatus(pod *corev1.Pod) error
EnsurePodStatus handles a pod event by adding or removing container tailing goroutines. Every running container in the monitored namespace has its own goroutine that reads its log stream. When a container is stopped we stop the relevant gorouting (if it is still running, it could already be stopped because of an error).
func (*ContainerList) GetContainer ¶
func (cl *ContainerList) GetContainer(uid string) (*Container, bool)
func (*ContainerList) RemoveContainer ¶
func (cl *ContainerList) RemoveContainer(uid string) error
func (*ContainerList) UpdateContainer ¶
func (cl *ContainerList) UpdateContainer(c *Container) error
UpdateContainer decides whether a container should be added, left alone or removed from the container list. It does that but checking the state of of the container.
type Extension ¶
type Extension struct { Logger *zap.SugaredLogger Options GraceOptions }
Extension changes pod definitions
func NewGracePeriodInjector ¶
func NewGracePeriodInjector(opts *GraceOptions) *Extension
NewGracePeriodInjector returns the podwatcher extension which injects a grace Period on Eirini generated pods
func (*Extension) Handle ¶
func (ext *Extension) Handle(ctx context.Context, eiriniManager eirinix.Manager, pod *corev1.Pod, req admission.Request) admission.Response
Handle injects gracefulPeriod in opi containers: In case an application is too fast to fail, we might miss logs as Kubernetes will terminate the container before the watcher had occasion to attach to stream any logs.
- Finalizers let the pod terminates, not giving any chance to get logs from terminated container.
- PostStop/PreStart hooks doesn't guarantee execution in case of containers terminated by failures (e.g. an invalid app was pushed in Eirini), if causing crashloopbackoff hooks aren't executed correctly.
type GraceOptions ¶
type GraceOptions struct {
FailGracePeriod, SuccessGracePeriod string
StagingDownloaderEntrypoint string
StagingExecutorEntrypoint string
StagingUploaderEntrypoint string
RuntimeEntrypoint string
GraceImageContainsString string
}
GraceOptions lets customize the graceful periods and the entrypoint of the images which are mutated to inject the grace period logic
type Loggregator ¶
type Loggregator struct { Meta *LoggregatorAppMeta ConnectionOptions config.LoggregatorOptions KubeClient *kubernetes.Clientset LoggregatorClient *loggregator.IngressClient Context context.Context }
func NewLoggregator ¶
func NewLoggregator(ctx context.Context, m *LoggregatorAppMeta, kubeClient *kubernetes.Clientset, connectionOptions config.LoggregatorOptions) *Loggregator
func (*Loggregator) Envelope ¶
func (l *Loggregator) Envelope(message []byte) *loggregator_v2.Envelope
func (*Loggregator) SetupLoggregatorClient ¶
func (l *Loggregator) SetupLoggregatorClient() error
func (*Loggregator) Tail ¶
func (l *Loggregator) Tail(namespace, pod, container string) error
type LoggregatorAppMeta ¶
type LoggregatorLogger ¶
type LoggregatorLogger struct{}
func (LoggregatorLogger) Panicf ¶
func (LoggregatorLogger) Panicf(message string, args ...interface{})
func (LoggregatorLogger) Printf ¶
func (LoggregatorLogger) Printf(message string, args ...interface{})
type PodWatcher ¶
type PodWatcher struct { Config config.ConfigType Containers ContainerList Manager eirinix.Manager }
func NewPodWatcher ¶
func NewPodWatcher(config config.ConfigType) *PodWatcher
func (*PodWatcher) EnsureLogStream ¶
EnsureLogStream ensures that the already running pod logs are tracked and sets the latest RV found to be able to track future changes. It gets the current RV to start watching on and reads the pods currently running in the namespace to process them with EnsurePodStatus. This allows the PodWatcher to stream logs of currently running pods if restarted (or updated).
func (*PodWatcher) Finish ¶
func (pw *PodWatcher) Finish()