Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪟 🐛 Fix JobService for jobs without attempts #20527

Merged
merged 2 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@use "scss/variables";

.jobStartFailure {
padding: variables.$spacing-lg;
}
28 changes: 18 additions & 10 deletions airbyte-webapp/src/components/JobItem/components/JobLogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import { useLocation } from "react-router-dom";

import { StatusIcon } from "components/ui/StatusIcon";
import { StatusIconStatus } from "components/ui/StatusIcon/StatusIcon";
import { Text } from "components/ui/Text";

import { JobsWithJobs } from "pages/ConnectionPage/pages/ConnectionItemPage/JobsList";
import { useGetDebugInfoJob } from "services/job/JobService";

import { AttemptRead, AttemptStatus, SynchronousJobRead } from "../../../core/request/AirbyteClient";
import { parseAttemptLink } from "../attemptLinkUtils";
import styles from "./JobLogs.module.scss";
import Logs from "./Logs";
import { LogsDetails } from "./LogsDetails";
import Tabs, { TabsData } from "./Tabs";
Expand Down Expand Up @@ -83,22 +85,28 @@ const JobLogs: React.FC<JobLogsProps> = ({ jobIsFailed, job }) => {

return (
<>
{attempts > 1 ? (
{attempts > 1 && (
<Tabs
activeStep={attemptNumber.toString()}
onSelect={(at) => setAttemptNumber(parseInt(at))}
data={attemptsTabs}
isFailed={jobIsFailed}
/>
) : null}
<LogsDetails
id={job.job.id}
path={path}
currentAttempt={currentAttempt}
jobDebugInfo={debugInfo}
showAttemptStats={attempts > 1}
logs={debugInfo?.attempts[attemptNumber]?.logs.logLines}
/>
)}
{attempts ? (
<LogsDetails
id={job.job.id}
path={path}
currentAttempt={currentAttempt}
jobDebugInfo={debugInfo}
showAttemptStats={attempts > 1}
logs={debugInfo?.attempts[attemptNumber]?.logs.logLines}
/>
) : (
<Text size="md" className={styles.jobStartFailure}>
<FormattedMessage id="jobs.noAttemptsFailure" />
</Text>
)}
</>
);
};
Expand Down
2 changes: 2 additions & 0 deletions airbyte-webapp/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -663,5 +663,7 @@
"connectorBuilder.resetAll": "Reset all",
"connectorBuilder.emptyName": "(empty)",

"jobs.noAttemptsFailure": "Failed to start job.",

"cloudApi.loginCallbackUrlError": "There was an error connecting to the developer portal. Please try again."
}
3 changes: 2 additions & 1 deletion airbyte-webapp/src/services/job/JobService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export const useGetDebugInfoJob = (
// If refetchWhileRunning was true, we keep refetching debug info (including logs), while the job is still
// running or hasn't ended too long ago. We need some time after the last attempt has stopped, since logs
// keep incoming for some time after the job has already been marked as finished.
const lastAttemptEndTimestamp = data?.attempts[data.attempts.length - 1].attempt.endedAt;
const lastAttemptEndTimestamp =
data?.attempts.length && data.attempts[data.attempts.length - 1].attempt.endedAt;
// While no attempt ended timestamp exists yet (i.e. the job is still running) or it hasn't ended
// more than 2 minutes (2 * 60 * 1000ms) ago, keep refetching
return lastAttemptEndTimestamp && Date.now() - lastAttemptEndTimestamp * 1000 > 2 * 60 * 1000 ? false : 2500;
Expand Down