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 Dr.CI flaky FP when GH fails to dispatch the workflow #4998

Merged
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
14 changes: 13 additions & 1 deletion torchci/lib/drciUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,15 @@ export async function hasSimilarFailures(
export function isInfraFlakyJob(job: RecentWorkflowsData): boolean {
// An infra flaky job is a failed job without any failure line and runner. It shows
// up as an empty job without any logs on GitHub. The failure can only be seen via
// the workflow summary tab
// the workflow summary tab.
//
// Also having a workflow ID means that this is a workflow job, not a workflow run.
// This is to prevent the case where GitHub failed to run the whole workflow, but
// was allowed to go through as flaky
return (
job.conclusion === "failure" &&
job.workflowId !== null &&
job.workflowId !== undefined &&
(job.failure_lines === null ||
job.failure_lines === undefined ||
job.failure_lines.join("") === "") &&
Expand All @@ -383,6 +389,12 @@ export function isInfraFlakyJob(job: RecentWorkflowsData): boolean {
export async function isLogClassifierFailed(
job: RecentWorkflowsData
): Promise<boolean> {
// Having no workflow ID means that this is a workflow run, not a workflow job.
// We don't want to apply the log classifier check for a workflow run
if (job.workflowId === null || job.workflowId === undefined) {
return false;
}

// This covers the case when there is no log on S3 or log classifier fails to triggered
const hasFailureLines =
job.failure_lines !== null &&
Expand Down
20 changes: 16 additions & 4 deletions torchci/test/drciUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ describe("Test various utils used by Dr.CI", () => {
});

test("test isInfraFlakyJob", () => {
// Not a workflow job
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe im reading this wrong, but do you have any tests where it would have been flaky if it were a workflow job, but not if it is a workflow run?

Copy link
Contributor Author

@huydhn huydhn Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are examples from the original PR #4622 that implements isInfraFlakyJob. They were all jobs that weren't run. GitHub records are gone, but they are still shown on HUD https://hud.pytorch.org/pr/110608

Copy link
Contributor Author

@huydhn huydhn Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By querying Rockset, I can confirm that there were infra flaky jobs from 110608. Here is an example:

workflowID = 6420960240 <-- Has workflow ID, so this is a job
id = 17434762139
runnerName = '' <-- Not having a runner name is a signal for infra flaky
authorEmail = 'eltociear@gmail.com'
name = 'pull / linux-jammy-py3.8-gcc11 / test (distributed, 2, 2, linux.2xlarge)'
jobName = 'linux-jammy-py3.8-gcc11 / test (distributed, 2, 2, linux.2xlarge)'
conclusion = 'failure'
failure_captures = null

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry what I mean is that I don't see tests where the existence of a workflowID has an effect on the output of the function, I only see cases that returned false regardless of whether or not the workflowID is there. This makes me think that the original code would have also returned false, so I'm confused as to if the code works, am I missing something?

const notInfraFlakyFailure: RecentWorkflowsData = {
id: "A",
name: "A",
Expand All @@ -348,8 +349,13 @@ describe("Test various utils used by Dr.CI", () => {
};
expect(isInfraFlakyJob(notInfraFlakyFailure)).toEqual(false);

// Set the workflow ID to mark this as a workflow job
notInfraFlakyFailure.workflowId = "A";
expect(isInfraFlakyJob(notInfraFlakyFailure)).toEqual(false);

const notInfraFlakyFailureAgain: RecentWorkflowsData = {
id: "A",
workflowId: "A",
name: "A",
html_url: "A",
head_sha: "A",
Expand All @@ -364,6 +370,7 @@ describe("Test various utils used by Dr.CI", () => {

const isInfraFlakyFailure: RecentWorkflowsData = {
id: "A",
workflowId: "A",
name: "A",
html_url: "A",
head_sha: "A",
Expand All @@ -381,8 +388,8 @@ describe("Test various utils used by Dr.CI", () => {
const mockJobUtils = jest.spyOn(jobUtils, "hasS3Log");
mockJobUtils.mockImplementation(() => Promise.resolve(true));

// Has log and failure lines
const validFailure: RecentWorkflowsData = {
// Not a workflow job
const mockFailure: RecentWorkflowsData = {
id: "A",
name: "A",
html_url: "A",
Expand All @@ -394,11 +401,16 @@ describe("Test various utils used by Dr.CI", () => {
head_branch: "whatever",
runnerName: "dummy",
};
expect(await isLogClassifierFailed(validFailure)).toEqual(false);
expect(await isLogClassifierFailed(mockFailure)).toEqual(false);

// Has log and failure lines and is a workflow job
mockFailure.workflowId = "A";
expect(await isLogClassifierFailed(mockFailure)).toEqual(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this line supposed to be the same as the one above it?

Copy link
Contributor Author

@huydhn huydhn Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tries to add 2 tests here:

  1. The first one without workflow ID to mark it as a workflow run, isLogClassifierFailed returns false as the default value
  2. The second one with workflow ID (so it's a job) + hasS3Log returning true + has failure lines, so isLogClassifierFailed should return false

So yeah, both of them expect false as the returned value.


// Has log but not failure lines (log classifier not triggered)
const logClassifierNotTriggered: RecentWorkflowsData = {
id: "A",
workflowId: "A",
name: "A",
html_url: "A",
head_sha: "A",
Expand All @@ -415,7 +427,7 @@ describe("Test various utils used by Dr.CI", () => {

// No S3 log
mockJobUtils.mockImplementation(() => Promise.resolve(false));
expect(await isLogClassifierFailed(validFailure)).toEqual(true);
expect(await isLogClassifierFailed(mockFailure)).toEqual(true);
});

test("test isExcludedFromFlakiness", () => {
Expand Down
Loading