Skip to content

Commit dc79608

Browse files
authored
Merge pull request #56 from buildbarn/bytestream
Bytestream ephmeral links for downloading logs from the problems tab
2 parents 12bed04 + 5703523 commit dc79608

File tree

17 files changed

+212
-35
lines changed

17 files changed

+212
-35
lines changed

ent/gen/ent/blob/blob.go

+6-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ent/gen/ent/migrate/schema.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ent/schema/blob.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func (Blob) Fields() []ent.Field {
1616
field.String("uri").Unique().Immutable(),
1717
field.Int64("size_bytes").Optional(),
1818
field.Enum("archiving_status").
19-
Values("QUEUED", "ARCHIVING", "SUCCESS", "FAILED").
19+
Values("QUEUED", "ARCHIVING", "SUCCESS", "FAILED", "BYTESTREAM").
2020
Default("QUEUED"),
2121
field.String("reason").Optional(),
2222
field.String("archive_url").Optional(),

frontend/src/app/bazel-invocations/[invocationID]/index.graphql.ts

+1
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ fragment BlobReferenceInfo on BlobReference {
302302
name
303303
sizeInBytes
304304
downloadURL
305+
ephemeralURL
305306
}
306307
`)
307308

frontend/src/components/Problems/LogOutput/index.tsx

+24
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import React, {useEffect, useState} from 'react';
22
import {util} from 'zod';
33
import {BlobReference} from '@/graphql/__generated__/graphql';
44
import {LogViewerCard} from "@/components/LogViewer";
5+
import { env } from 'next-runtime-env';
6+
import { Button, Card, Space, Tooltip } from 'antd';
7+
import ButtonGroup from 'antd/es/button/button-group';
8+
import { DownloadOutlined, WarningOutlined } from '@ant-design/icons';
9+
import Link from 'next/link';
10+
import styles from "@/components/LogViewer/index.module.css"
11+
import DownloadButton from '@/components/DownloadButton';
512

613
interface Props {
714
blobReference: BlobReference;
@@ -10,6 +17,8 @@ interface Props {
1017

1118
const DEFAULT_TAIL_BYTES = 10_000;
1219

20+
21+
1322
/* eslint-disable consistent-return */
1423
const LogOutput: React.FC<Props> = ({blobReference, tailBytes = DEFAULT_TAIL_BYTES}) => {
1524
const [contents, setContents] = useState<string>("");
@@ -39,6 +48,21 @@ const LogOutput: React.FC<Props> = ({blobReference, tailBytes = DEFAULT_TAIL_BYT
3948
validContent = selectedLines.join('\n')
4049
}
4150

51+
if (blobReference.ephemeralURL != "" && env('NEXT_PUBLIC_BROWSER_URL')) {
52+
console.log("blobReference.ephemeralURL=", blobReference.ephemeralURL)
53+
const url = new URL(blobReference.ephemeralURL, env('NEXT_PUBLIC_BROWSER_URL'))
54+
return <Space direction="horizontal" size="small">
55+
<Card>
56+
<ButtonGroup>
57+
<DownloadButton url={url.toString()} enabled={true} buttonLabel="Download Log File" fileName="output.log" />
58+
<Tooltip title="Depending on the configuration of your remote cache, this link may point to ephemeral content and it could disappear.">
59+
<Button icon={<WarningOutlined/>} danger />
60+
</Tooltip>
61+
</ButtonGroup>
62+
</Card>
63+
</Space>
64+
}
65+
4266
return <LogViewerCard log={validContent}/>;
4367
};
4468

frontend/src/components/Problems/TestResultContainer/index.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {TestProblem} from "@/graphql/__generated__/graphql";
2-
import {Space} from "antd";
1+
import { TestProblem } from "@/graphql/__generated__/graphql";
2+
import { Space } from "antd";
33
import React from "react";
44
import ErrorAlert from "@/components/ErrorAlert";
55
import themeStyles from '@/theme/theme.module.css';
6-
import {SectionWithTestStatus} from "@/components/Problems/BuildProblem";
6+
import { SectionWithTestStatus } from "@/components/Problems/BuildProblem";
77
import LogOutput from "@/components/Problems/LogOutput";
88

99
interface Props {
@@ -12,6 +12,7 @@ interface Props {
1212
testProblem: TestProblem;
1313
}
1414

15+
1516
const TestResultContainer: React.FC<Props> = ({ id, problemLabel, testProblem }) => {
1617
const testResult = testProblem.results.find(r => r.id == id)
1718
if (!testResult) {
@@ -23,12 +24,15 @@ const TestResultContainer: React.FC<Props> = ({ id, problemLabel, testProblem })
2324
);
2425
}
2526

27+
var contents = <LogOutput blobReference={testResult.actionLogOutput} />
28+
29+
2630
return (
2731
<>
2832
<SectionWithTestStatus testProblem={testProblem} />
2933
{/* Display spin behind the actions, making UI stable when query is being executed. */}
3034
<Space direction="vertical" size="middle" className={themeStyles.space}>
31-
<LogOutput blobReference={testResult.actionLogOutput} />
35+
{contents}
3236
</Space>
3337
</>
3438
);

frontend/src/graphql/__generated__/gql.ts

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)