Skip to content

Commit

Permalink
Merge pull request #2 from incident-io/ben/watch-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benwh authored Sep 14, 2023
2 parents 5616c33 + afd42a5 commit 62fe86a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions pkg/workloads/console/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -896,8 +897,24 @@ func (c *Runner) waitForConsole(ctx context.Context, createdCsl workloadsv1alpha
return nil, errors.New("watch channel closed")
}

obj := event.Object.(*unstructured.Unstructured)
runtime.DefaultUnstructuredConverter.FromUnstructured(obj.UnstructuredContent(), csl)
// We can ignore Bookmark events, because we aren't making requests using bookmarks.
//
// If we encounter an Error event, then igore this too.
// We'll instead wait until the channel is closed, or our context timeout is
// reached.
if event.Type == watch.Bookmark || event.Type == watch.Error {
continue
}

obj, ok := event.Object.(*unstructured.Unstructured)
if !ok {
return nil, fmt.Errorf("failed to cast watch event")
}

err = runtime.DefaultUnstructuredConverter.FromUnstructured(obj.UnstructuredContent(), csl)
if err != nil {
return nil, fmt.Errorf("error converting console object: %w", err)
}

if isRunning(csl) {
return csl, nil
Expand Down

0 comments on commit 62fe86a

Please sign in to comment.