This commit is contained in:
Rob Watson 2022-06-11 07:20:28 +02:00
parent be99d25fb2
commit 3288b488d3
2 changed files with 3 additions and 9 deletions

View File

@ -179,11 +179,7 @@ func (pw *PodWatcher) removePod(podName string) {
func copyPodLogs(ctx context.Context, wg *sync.WaitGroup, client KubernetesClient, pod *corev1.Pod, container string, logStream chan string) *streamError {
defer wg.Done()
podLogOpts := corev1.PodLogOptions{
Follow: true,
Container: container,
}
req := client.Typed.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &podLogOpts)
req := client.Typed.CoreV1().Pods(pod.Namespace).GetLogs(pod.Name, &corev1.PodLogOptions{Follow: true, Container: container})
logs, err := req.Stream(ctx)
// If one container is still being created, do not treat this as a fatal error.

View File

@ -95,7 +95,6 @@ func (w *Watcher) Watch(ctx context.Context) error {
if err != nil {
return err
}
defer watcher.Stop()
ticker := time.NewTicker(time.Second)
@ -112,7 +111,6 @@ func (w *Watcher) Watch(ctx context.Context) error {
switch evt.Type {
case watch.Added, watch.Modified:
resource := evt.Object.(*unstructured.Unstructured)
uid := resource.GetUID()
// TODO: handle matchExpressions
selectorAsMap, ok, err := unstructured.NestedStringMap(resource.Object, "spec", "selector", "matchLabels")
if !ok || err != nil {
@ -121,12 +119,12 @@ func (w *Watcher) Watch(ctx context.Context) error {
w.logger.Printf("warning: unable to parse matchLabels: ok = %t, err = %v", ok, err)
continue
}
selector := labels.SelectorFromSet(selectorAsMap)
w.addDeployment(ctx, uid, selector)
w.addDeployment(ctx, resource.GetUID(), labels.SelectorFromSet(selectorAsMap))
case watch.Deleted:
w.removeDeployment()
}
// errChan is never closed.
case err := <-w.errChan:
return err
case <-ctx.Done():