Parse Jeannie reports before truncation
This commit is contained in:
parent
f32c1da60d
commit
dd065c2c93
|
|
@ -229,6 +229,10 @@ func (client *JeannieClient) Submit(ctx context.Context, command string, args []
|
|||
}
|
||||
|
||||
func (client *JeannieClient) Execution(ctx context.Context, id string) (RemoteExecution, error) {
|
||||
return client.execution(ctx, id, true)
|
||||
}
|
||||
|
||||
func (client *JeannieClient) execution(ctx context.Context, id string, bounded bool) (RemoteExecution, error) {
|
||||
if !kubernetesApplicationName.MatchString(id) {
|
||||
return RemoteExecution{}, errors.New("invalid Jeannie execution ID")
|
||||
}
|
||||
|
|
@ -236,7 +240,9 @@ func (client *JeannieClient) Execution(ctx context.Context, id string) (RemoteEx
|
|||
if err := client.request(ctx, http.MethodGet, "/v1/executions/"+id, nil, ¤t); err != nil {
|
||||
return RemoteExecution{}, err
|
||||
}
|
||||
current.Output = cleanExcerpt(current.Output, 12000)
|
||||
if bounded {
|
||||
current.Output = cleanExcerpt(current.Output, 12000)
|
||||
}
|
||||
current.Error = cleanExcerpt(current.Error, 1200)
|
||||
return current, nil
|
||||
}
|
||||
|
|
@ -264,7 +270,7 @@ func (client *JeannieClient) execute(ctx context.Context, command string, args [
|
|||
}
|
||||
|
||||
for {
|
||||
remote, err := client.Execution(ctx, submitted.ID)
|
||||
remote, err := client.execution(ctx, submitted.ID, false)
|
||||
if err != nil {
|
||||
return execution{}, fmt.Errorf("read %s execution: %w", command, err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import (
|
|||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
|
@ -32,7 +33,11 @@ func TestStatusUsesAuthenticatedReadOnlyCommand(t *testing.T) {
|
|||
_, _ = response.Write([]byte(`{"id":"status-1","status":"queued"}`))
|
||||
case "/v1/executions/status-1":
|
||||
requestCount++
|
||||
_, _ = response.Write([]byte(`{"id":"status-1","status":"failed","output":"OCI config loaded\n{\"title\":\"Jeannie Status: all\",\"mode\":\"fast\",\"cluster\":{\"profile\":\"k3s\",\"runtime\":\"k3s\"},\"rows\":[{\"status\":\"fail\",\"area\":\"Kubernetes apps\",\"check\":\"n8n\",\"summary\":\"health=Progressing\",\"detail\":\"private detail\"}]}"}`))
|
||||
_ = json.NewEncoder(response).Encode(RemoteExecution{
|
||||
ID: "status-1",
|
||||
Status: "failed",
|
||||
Output: strings.Repeat("bounded diagnostic output\n", 600) + `{"title":"Jeannie Status: all","mode":"fast","cluster":{"profile":"k3s","runtime":"k3s"},"rows":[{"status":"fail","area":"Kubernetes apps","check":"n8n","summary":"health=Progressing","detail":"private detail"}]}`,
|
||||
})
|
||||
default:
|
||||
http.NotFound(response, request)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue