Skip to content

Commit

Permalink
debug: testing unbuffered channels
Browse files Browse the repository at this point in the history
  • Loading branch information
exu committed Nov 20, 2021
1 parent f1642a4 commit bc4e4a0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/api/v1/client/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func (c DirectScriptsAPI) ExecuteScript(id, namespace, executionName string, exe

// Logs reads logs from API SSE endpoint asynchronously
func (c DirectScriptsAPI) Logs(id string) (logs chan output.Output, err error) {
logs = make(chan output.Output, 1000)
logs = make(chan output.Output)
uri := c.getURI("/executions/%s/logs", id)

req, err := http.NewRequest("GET", uri, nil)
Expand Down
7 changes: 5 additions & 2 deletions pkg/executor/client/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,17 @@ func (c JobExecutor) Get(id string) (execution testkube.ExecutionResult, err err
// Logs returns job logs
// TODO too many goroutines - need to be simplified
func (c JobExecutor) Logs(id string) (out chan output.Output, err error) {
out = make(chan output.Output, 10000)
out = make(chan output.Output)
logs, err := c.Client.TailJobLogs(id)
if err != nil {
return out, err
}

go func() {
defer close(out)
defer func() {
fmt.Printf("%+v\n", "closing JobExecutor.Logs out log")
close(out)
}()
for l := range logs {
output, err := output.GetLogEntry(l)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/jobs/jobclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (c *JobClient) GetPodLogs(podName string) (logs []byte, err error) {
}

func (c *JobClient) TailPodLogs(ctx context.Context, podName string) (logs chan []byte, err error) {
logs = make(chan []byte, 10000)
logs = make(chan []byte)
count := int64(1)

podLogOptions := v1.PodLogOptions{
Expand Down

0 comments on commit bc4e4a0

Please sign in to comment.