Skip to content

Commit 7dfc2aa

Browse files
committed
fix(dataproc): add robust error handling for quota exhaustion
1 parent a9fbacb commit 7dfc2aa

3 files changed

Lines changed: 59 additions & 14 deletions

File tree

dataproc/system-test/createCluster.test.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,26 @@ 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 () => {

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/submitJob.test.js

Lines changed: 18 additions & 3 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 () => {

0 commit comments

Comments
 (0)