Skip to content

Commit a3dd13b

Browse files
authored
fix(dataproc): add error handling for quota exhaustion (#4351)
* fix(dataproc): add robust error handling for quota exhaustion * Added error handling to test cleanup. * Added error handling to quickstart.test.js
1 parent cf26047 commit a3dd13b

4 files changed

Lines changed: 100 additions & 32 deletions

File tree

dataproc/system-test/createCluster.test.js

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,37 @@ const execSync = cmd =>
3535
});
3636

3737
describe('create a dataproc cluster', () => {
38-
it('should create a dataproc cluster', async () => {
39-
const stdout = execSync(
40-
`node createCluster.js "${projectId}" "${region}" "${clusterName}"`
41-
);
42-
assert.match(stdout, new RegExp(`${clusterName}`));
38+
it('should create a dataproc cluster', async function () {
39+
try {
40+
const stdout = execSync(
41+
`node createCluster.js "${projectId}" "${region}" "${clusterName}"`
42+
);
43+
assert.match(stdout, new RegExp(`${clusterName}`));
44+
} catch (err) {
45+
if (
46+
err?.message?.includes('QUOTA') ||
47+
err?.message?.includes('RESOURCE_EXHAUSTED') ||
48+
err?.message?.includes('DISKS_TOTAL_GB')
49+
) {
50+
console.warn(
51+
`Quota limit reached in project ${projectId}. Skipping test.`
52+
);
53+
this.skip();
54+
} else {
55+
throw err;
56+
}
57+
}
4358
});
4459

4560
after(async () => {
46-
await clusterClient.deleteCluster({
47-
projectId: projectId,
48-
region: region,
49-
clusterName: clusterName,
50-
});
61+
try {
62+
await clusterClient.deleteCluster({
63+
projectId: projectId,
64+
region: region,
65+
clusterName: clusterName,
66+
});
67+
} catch (err) {
68+
// Ignore errors during cleanup
69+
}
5170
});
5271
});

dataproc/system-test/instantiateInlineWorkflowTemplate.test.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,26 @@ const {delay} = require('./util');
3030

3131
describe('instantiate an inline workflow template', () => {
3232
it('should instantiate an inline workflow template', async function () {
33-
this.retries(4);
34-
await delay(this.test);
35-
const stdout = execSync(
36-
`node instantiateInlineWorkflowTemplate.js "${projectId}" "${region}"`
37-
);
38-
assert.match(stdout, /successfully/);
33+
try {
34+
this.retries(4);
35+
await delay(this.test);
36+
const stdout = execSync(
37+
`node instantiateInlineWorkflowTemplate.js "${projectId}" "${region}"`
38+
);
39+
assert.match(stdout, /successfully/);
40+
} catch (err) {
41+
if (
42+
err?.message?.includes('QUOTA') ||
43+
err?.message?.includes('RESOURCE_EXHAUSTED') ||
44+
err?.message?.includes('DISKS_TOTAL_GB')
45+
) {
46+
console.warn(
47+
`Quota limit reached in project ${projectId}. Skipping test.`
48+
);
49+
this.skip();
50+
} else {
51+
throw err;
52+
}
53+
}
3954
});
4055
});

dataproc/system-test/quickstart.test.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,29 @@ describe('execute the quickstart', () => {
5555
});
5656

5757
it('should execute the quickstart', async function () {
58-
this.retries(4);
59-
await delay(this.test);
60-
const stdout = execSync(
61-
`node quickstart.js "${projectId}" "${region}" "${clusterName}" "${jobFilePath}"`
62-
);
63-
assert.match(stdout, /Cluster created successfully/);
64-
assert.match(stdout, /Job finished successfully/);
65-
assert.match(stdout, /successfully deleted/);
58+
try {
59+
this.retries(4);
60+
await delay(this.test);
61+
const stdout = execSync(
62+
`node quickstart.js "${projectId}" "${region}" "${clusterName}" "${jobFilePath}"`
63+
);
64+
assert.match(stdout, /Cluster created successfully/);
65+
assert.match(stdout, /Job finished successfully/);
66+
assert.match(stdout, /successfully deleted/);
67+
} catch (err) {
68+
if (
69+
err?.message?.includes('QUOTA') ||
70+
err?.message?.includes('RESOURCE_EXHAUSTED') ||
71+
err?.message?.includes('DISKS_TOTAL_GB')
72+
) {
73+
console.warn(
74+
`Quota limit reached in project ${projectId}. Skipping test.`
75+
);
76+
this.skip();
77+
} else {
78+
throw err;
79+
}
80+
}
6681
});
6782

6883
afterEach(async () => {

dataproc/system-test/submitJob.test.js

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,24 @@ const execSync = cmd =>
5151
});
5252

5353
describe('submit a Spark job to a Dataproc cluster', () => {
54-
before(async () => {
55-
const [operation] = await clusterClient.createCluster(cluster);
56-
await operation.promise();
54+
before(async function () {
55+
try {
56+
const [operation] = await clusterClient.createCluster(cluster);
57+
await operation.promise();
58+
} catch (err) {
59+
if (
60+
err?.message?.includes('QUOTA') ||
61+
err?.message?.includes('RESOURCE_EXHAUSTED') ||
62+
err?.message?.includes('DISKS_TOTAL_GB')
63+
) {
64+
console.warn(
65+
`Quota limit reached in project ${projectId}. Skipping test.`
66+
);
67+
this.skip();
68+
} else {
69+
throw err;
70+
}
71+
}
5772
});
5873

5974
it('should submit a job to a dataproc cluster', async () => {
@@ -64,10 +79,14 @@ describe('submit a Spark job to a Dataproc cluster', () => {
6479
});
6580

6681
after(async () => {
67-
await clusterClient.deleteCluster({
68-
projectId: projectId,
69-
region: region,
70-
clusterName: clusterName,
71-
});
82+
try {
83+
await clusterClient.deleteCluster({
84+
projectId: projectId,
85+
region: region,
86+
clusterName: clusterName,
87+
});
88+
} catch (err) {
89+
// Ignore errors during cleanup
90+
}
7291
});
7392
});

0 commit comments

Comments
 (0)