Skip to content

Commit

Permalink
Merge pull request #56 from buildbarn/bytestream
Browse files Browse the repository at this point in the history
Bytestream ephmeral links for downloading logs from the problems tab
  • Loading branch information
mortenmj authored Nov 14, 2024
2 parents 12bed04 + 5703523 commit dc79608
Show file tree
Hide file tree
Showing 17 changed files with 212 additions and 35 deletions.
11 changes: 6 additions & 5 deletions ent/gen/ent/blob/blob.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ent/gen/ent/migrate/schema.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ent/schema/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (Blob) Fields() []ent.Field {
field.String("uri").Unique().Immutable(),
field.Int64("size_bytes").Optional(),
field.Enum("archiving_status").
Values("QUEUED", "ARCHIVING", "SUCCESS", "FAILED").
Values("QUEUED", "ARCHIVING", "SUCCESS", "FAILED", "BYTESTREAM").
Default("QUEUED"),
field.String("reason").Optional(),
field.String("archive_url").Optional(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ fragment BlobReferenceInfo on BlobReference {
name
sizeInBytes
downloadURL
ephemeralURL
}
`)

Expand Down
24 changes: 24 additions & 0 deletions frontend/src/components/Problems/LogOutput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import React, {useEffect, useState} from 'react';
import {util} from 'zod';
import {BlobReference} from '@/graphql/__generated__/graphql';
import {LogViewerCard} from "@/components/LogViewer";
import { env } from 'next-runtime-env';
import { Button, Card, Space, Tooltip } from 'antd';
import ButtonGroup from 'antd/es/button/button-group';
import { DownloadOutlined, WarningOutlined } from '@ant-design/icons';
import Link from 'next/link';
import styles from "@/components/LogViewer/index.module.css"
import DownloadButton from '@/components/DownloadButton';

interface Props {
blobReference: BlobReference;
Expand All @@ -10,6 +17,8 @@ interface Props {

const DEFAULT_TAIL_BYTES = 10_000;



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

if (blobReference.ephemeralURL != "" && env('NEXT_PUBLIC_BROWSER_URL')) {
console.log("blobReference.ephemeralURL=", blobReference.ephemeralURL)
const url = new URL(blobReference.ephemeralURL, env('NEXT_PUBLIC_BROWSER_URL'))
return <Space direction="horizontal" size="small">
<Card>
<ButtonGroup>
<DownloadButton url={url.toString()} enabled={true} buttonLabel="Download Log File" fileName="output.log" />
<Tooltip title="Depending on the configuration of your remote cache, this link may point to ephemeral content and it could disappear.">
<Button icon={<WarningOutlined/>} danger />
</Tooltip>
</ButtonGroup>
</Card>
</Space>
}

return <LogViewerCard log={validContent}/>;
};

Expand Down
12 changes: 8 additions & 4 deletions frontend/src/components/Problems/TestResultContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {TestProblem} from "@/graphql/__generated__/graphql";
import {Space} from "antd";
import { TestProblem } from "@/graphql/__generated__/graphql";
import { Space } from "antd";
import React from "react";
import ErrorAlert from "@/components/ErrorAlert";
import themeStyles from '@/theme/theme.module.css';
import {SectionWithTestStatus} from "@/components/Problems/BuildProblem";
import { SectionWithTestStatus } from "@/components/Problems/BuildProblem";
import LogOutput from "@/components/Problems/LogOutput";

interface Props {
Expand All @@ -12,6 +12,7 @@ interface Props {
testProblem: TestProblem;
}


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

var contents = <LogOutput blobReference={testResult.actionLogOutput} />


return (
<>
<SectionWithTestStatus testProblem={testProblem} />
{/* Display spin behind the actions, making UI stable when query is being executed. */}
<Space direction="vertical" size="middle" className={themeStyles.space}>
<LogOutput blobReference={testResult.actionLogOutput} />
{contents}
</Space>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/graphql/__generated__/gql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dc79608

Please sign in to comment.