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(glue): restore notifyDelayAfter across different job types #33842

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
46 changes: 46 additions & 0 deletions packages/@aws-cdk/aws-glue-alpha/lib/jobs/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Code } from '../code';
import { MetricType, JobState, WorkerType, GlueVersion } from '../constants';
import { IConnection } from '../connection';
import { ISecurityConfiguration } from '../security-configuration';
import { CfnJob, CfnJobProps } from 'aws-cdk-lib/aws-glue';

/**
* Interface representing a new or an imported Glue Job
Expand Down Expand Up @@ -448,6 +449,26 @@ export interface JobProps {
* @see https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html
**/
readonly continuousLogging?: ContinuousLoggingProps;

/**
* Specifies configuration properties of a notification (optional).
* After a job run starts, the number of minutes to wait before sending a job run delay notification.
*
* @default - undefined
*/
readonly notifyDelayAfter?: cdk.Duration;

/**
* Specifies whether job run queuing is enabled for the job runs for this job.
* A value of true means job run queuing is enabled for the job runs.
* If false or not populated, the job runs will not be considered for queueing.
* If this field does not match the value set in the job run, then the value from
* the job run field will be used. This property must be set to false for flex jobs.
* If this property is enabled, maxRetries must be set to zero.
*
* @default - no job run queuing
*/
readonly jobRunQueuingEnabled?: boolean;
}

/**
Expand All @@ -473,6 +494,31 @@ export abstract class Job extends JobBase {
return new Import(scope, id);
}

/**
* Utility method to help with creating the CfnJob resource.
* It handles common/shared JobProps, while allowing CfnJobProps overrides.
*
* @param scope the scope to create the resource in.
* @param props the JobProps to use for the resource.
* @param cfnProps the CfnJobProps overrides to use for the resource.
* @protected
*/
protected static setupJobResource(scope: constructs.Construct, props: JobProps, cfnProps: CfnJobProps) {
return new CfnJob(scope, 'Resource', {
name: props.jobName,
description: props.description,
executionProperty: props.maxConcurrentRuns ? { maxConcurrentRuns: props.maxConcurrentRuns } : undefined,
timeout: props.timeout?.toMinutes(),
connections: props.connections ? { connections: props.connections.map((connection) => connection.connectionName) } : undefined,
securityConfiguration: props.securityConfiguration?.securityConfigurationName,
maxRetries: props.jobRunQueuingEnabled ? 0 : props.maxRetries,
jobRunQueuingEnabled: props.jobRunQueuingEnabled ? props.jobRunQueuingEnabled : false,
notificationProperty: props.notifyDelayAfter ? { notifyDelayAfter: props.notifyDelayAfter.toMinutes() } : undefined,
tags: props.tags,
...cfnProps,
});
}

/**
* The IAM role Glue assumes to run this job.
*/
Expand Down
49 changes: 1 addition & 48 deletions packages/@aws-cdk/aws-glue-alpha/lib/jobs/pyspark-etl-job.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CfnJob } from 'aws-cdk-lib/aws-glue';
import { Construct } from 'constructs';
import { JobType, GlueVersion, JobLanguage, PythonVersion, WorkerType } from '../constants';
import { Code } from '../code';
Expand All @@ -16,43 +15,6 @@ export interface PySparkEtlJobProps extends SparkJobProps {
* @default - no extra files
*/
readonly extraPythonFiles?: Code[];

/**
* Additional files, such as configuration files that AWS Glue copies to the working directory of your script before executing it.
*
* @default - no extra files specified.
*
* @see https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html
*/
readonly extraFiles?: Code[];

/**
* Extra Jars S3 URL (optional)
* S3 URL where additional jar dependencies are located
* @default - no extra jar files
*/
readonly extraJars?: Code[];

/**
* Setting this value to true prioritizes the customer's extra JAR files in the classpath.
*
* @default false - priority is not given to user-provided jars
*
* @see `--user-jars-first` in https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html
*/
readonly extraJarsFirst?: boolean;

/**
* Specifies whether job run queuing is enabled for the job runs for this job.
* A value of true means job run queuing is enabled for the job runs.
* If false or not populated, the job runs will not be considered for queueing.
* If this field does not match the value set in the job run, then the value from
* the job run field will be used. This property must be set to false for flex jobs.
* If this property is enabled, maxRetries must be set to zero.
*
* @default false
*/
readonly jobRunQueuingEnabled?: boolean;
}

/**
Expand Down Expand Up @@ -85,9 +47,7 @@ export class PySparkEtlJob extends SparkJob {
...this.nonExecutableCommonArguments(props),
};

const jobResource = new CfnJob(this, 'Resource', {
name: props.jobName,
description: props.description,
const jobResource = PySparkEtlJob.setupJobResource(this, props, {
role: this.role.roleArn,
command: {
name: JobType.ETL,
Expand All @@ -97,13 +57,6 @@ export class PySparkEtlJob extends SparkJob {
glueVersion: props.glueVersion ?? GlueVersion.V4_0,
workerType: props.workerType ?? WorkerType.G_1X,
numberOfWorkers: props.numberOfWorkers ? props.numberOfWorkers : 10,
maxRetries: props.jobRunQueuingEnabled ? 0 : props.maxRetries,
jobRunQueuingEnabled: props.jobRunQueuingEnabled ? props.jobRunQueuingEnabled : false,
executionProperty: props.maxConcurrentRuns ? { maxConcurrentRuns: props.maxConcurrentRuns } : undefined,
timeout: props.timeout?.toMinutes(),
connections: props.connections ? { connections: props.connections.map((connection) => connection.connectionName) } : undefined,
securityConfiguration: props.securityConfiguration?.securityConfigurationName,
tags: props.tags,
defaultArguments,
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { CfnJob } from 'aws-cdk-lib/aws-glue';
import { Construct } from 'constructs';
import { JobType, GlueVersion, JobLanguage, PythonVersion, WorkerType, ExecutionClass } from '../constants';
import * as cdk from 'aws-cdk-lib/core';
import { Code } from '../code';
import { SparkJob, SparkJobProps } from './spark-job';
import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
Expand All @@ -10,45 +8,13 @@ import { addConstructMetadata } from 'aws-cdk-lib/core/lib/metadata-resource';
* Properties for PySparkFlexEtlJob
*/
export interface PySparkFlexEtlJobProps extends SparkJobProps {
/**
* Specifies configuration properties of a notification (optional).
* After a job run starts, the number of minutes to wait before sending a job run delay notification.
* @default - undefined
*/
readonly notifyDelayAfter?: cdk.Duration;

/**
* Extra Python Files S3 URL (optional)
* S3 URL where additional python dependencies are located
*
* @default - no extra files
*/
readonly extraPythonFiles?: Code[];

/**
* Additional files, such as configuration files that AWS Glue copies to the working directory of your script before executing it.
*
* @default - no extra files specified.
*
* @see https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html
*/
readonly extraFiles?: Code[];

/**
* Extra Jars S3 URL (optional)
* S3 URL where additional jar dependencies are located
* @default - no extra jar files
*/
readonly extraJars?: Code[];

/**
* Setting this value to true prioritizes the customer's extra JAR files in the classpath.
*
* @default false - priority is not given to user-provided jars
*
* @see `--user-jars-first` in https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html
*/
readonly extraJarsFirst?: boolean;
}

/**
Expand Down Expand Up @@ -81,9 +47,7 @@ export class PySparkFlexEtlJob extends SparkJob {
...this.nonExecutableCommonArguments(props),
};

const jobResource = new CfnJob(this, 'Resource', {
name: props.jobName,
description: props.description,
const jobResource = PySparkFlexEtlJob.setupJobResource(this, props, {
role: this.role.roleArn,
command: {
name: JobType.ETL,
Expand All @@ -94,16 +58,9 @@ export class PySparkFlexEtlJob extends SparkJob {
workerType: props.workerType ? props.workerType : WorkerType.G_1X,
numberOfWorkers: props.numberOfWorkers ? props.numberOfWorkers : 10,
maxRetries: props.maxRetries,
executionProperty: props.maxConcurrentRuns ? { maxConcurrentRuns: props.maxConcurrentRuns } : undefined,
notificationProperty: props.notifyDelayAfter ? { notifyDelayAfter: props.notifyDelayAfter.toMinutes() } : undefined,
timeout: props.timeout?.toMinutes(),
connections: props.connections ? { connections: props.connections.map((connection) => connection.connectionName) } : undefined,
securityConfiguration: props.securityConfiguration?.securityConfigurationName,
tags: props.tags,
executionClass: ExecutionClass.FLEX,
jobRunQueuingEnabled: false,
defaultArguments,

});

const resourceName = this.getResourceNameAttribute(jobResource.ref);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CfnJob } from 'aws-cdk-lib/aws-glue';
import { Construct } from 'constructs';
import { JobType, GlueVersion, JobLanguage, PythonVersion, WorkerType } from '../constants';
import { Code } from '../code';
Expand All @@ -16,43 +15,6 @@ export interface PySparkStreamingJobProps extends SparkJobProps {
* @default - no extra files
*/
readonly extraPythonFiles?: Code[];

/**
* Additional files, such as configuration files that AWS Glue copies to the working directory of your script before executing it.
*
* @default - no extra files specified.
*
* @see https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html
*/
readonly extraFiles?: Code[];

/**
* Extra Jars S3 URL (optional)
* S3 URL where additional jar dependencies are located
* @default - no extra jar files
*/
readonly extraJars?: Code[];

/**
* Setting this value to true prioritizes the customer's extra JAR files in the classpath.
*
* @default false - priority is not given to user-provided jars
*
* @see `--user-jars-first` in https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html
*/
readonly extraJarsFirst?: boolean;

/**
* Specifies whether job run queuing is enabled for the job runs for this job.
* A value of true means job run queuing is enabled for the job runs.
* If false or not populated, the job runs will not be considered for queueing.
* If this field does not match the value set in the job run, then the value from
* the job run field will be used. This property must be set to false for flex jobs.
* If this property is enabled, maxRetries must be set to zero.
*
* @default - no job run queuing
*/
readonly jobRunQueuingEnabled?: boolean;
}

/**
Expand Down Expand Up @@ -85,9 +47,7 @@ export class PySparkStreamingJob extends SparkJob {
...this.nonExecutableCommonArguments(props),
};

const jobResource = new CfnJob(this, 'Resource', {
name: props.jobName,
description: props.description,
const jobResource = PySparkStreamingJob.setupJobResource(this, props, {
role: this.role.roleArn,
command: {
name: JobType.STREAMING,
Expand All @@ -97,13 +57,6 @@ export class PySparkStreamingJob extends SparkJob {
glueVersion: props.glueVersion ? props.glueVersion : GlueVersion.V4_0,
workerType: props.workerType ? props.workerType : WorkerType.G_1X,
numberOfWorkers: props.numberOfWorkers ? props.numberOfWorkers : 10,
maxRetries: props.jobRunQueuingEnabled ? 0 : props.maxRetries,
jobRunQueuingEnabled: props.jobRunQueuingEnabled ? props.jobRunQueuingEnabled : false,
executionProperty: props.maxConcurrentRuns ? { maxConcurrentRuns: props.maxConcurrentRuns } : undefined,
timeout: props.timeout?.toMinutes(),
connections: props.connections ? { connections: props.connections.map((connection) => connection.connectionName) } : undefined,
securityConfiguration: props.securityConfiguration?.securityConfigurationName,
tags: props.tags,
defaultArguments,
});

Expand Down
23 changes: 1 addition & 22 deletions packages/@aws-cdk/aws-glue-alpha/lib/jobs/python-shell-job.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CfnJob } from 'aws-cdk-lib/aws-glue';
import * as iam from 'aws-cdk-lib/aws-iam';
import { Job, JobProps } from './job';
import { Construct } from 'constructs';
Expand All @@ -22,18 +21,6 @@ export interface PythonShellJobProps extends JobProps {
* @default 0.0625
*/
readonly maxCapacity?: MaxCapacity;

/**
* Specifies whether job run queuing is enabled for the job runs for this job.
* A value of true means job run queuing is enabled for the job runs.
* If false or not populated, the job runs will not be considered for queueing.
* If this field does not match the value set in the job run, then the value from
* the job run field will be used. This property must be set to false for flex jobs.
* If this property is enabled, maxRetries must be set to zero.
*
* @default false
*/
readonly jobRunQueuingEnabled?: boolean;
}

/**
Expand Down Expand Up @@ -78,9 +65,7 @@ export class PythonShellJob extends Job {
...this.checkNoReservedArgs(props.defaultArguments),
};

const jobResource = new CfnJob(this, 'Resource', {
name: props.jobName,
description: props.description,
const jobResource = PythonShellJob.setupJobResource(this, props, {
role: this.role.roleArn,
command: {
name: JobType.PYTHON_SHELL,
Expand All @@ -90,12 +75,6 @@ export class PythonShellJob extends Job {
glueVersion: props.glueVersion ? props.glueVersion : GlueVersion.V3_0,
maxCapacity: props.maxCapacity ? props.maxCapacity : MaxCapacity.DPU_1_16TH,
maxRetries: props.jobRunQueuingEnabled ? 0 : props.maxRetries ? props.maxRetries : 0,
jobRunQueuingEnabled: props.jobRunQueuingEnabled ? props.jobRunQueuingEnabled : false,
executionProperty: props.maxConcurrentRuns ? { maxConcurrentRuns: props.maxConcurrentRuns } : undefined,
timeout: props.timeout?.toMinutes(),
connections: props.connections ? { connections: props.connections.map((connection) => connection.connectionName) } : undefined,
securityConfiguration: props.securityConfiguration?.securityConfigurationName,
tags: props.tags,
defaultArguments,
});

Expand Down
24 changes: 1 addition & 23 deletions packages/@aws-cdk/aws-glue-alpha/lib/jobs/ray-job.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { CfnJob } from 'aws-cdk-lib/aws-glue';
import * as iam from 'aws-cdk-lib/aws-iam';
import { Job, JobProps } from './job';
import { Construct } from 'constructs';
Expand All @@ -15,18 +14,6 @@ export interface RayJobProps extends JobProps {
* @default - Runtime version will default to Ray2.4
*/
readonly runtime?: Runtime;

/**
* Specifies whether job run queuing is enabled for the job runs for this job.
* A value of true means job run queuing is enabled for the job runs.
* If false or not populated, the job runs will not be considered for queueing.
* If this field does not match the value set in the job run, then the value from
* the job run field will be used. This property must be set to false for flex jobs.
* If this property is enabled, maxRetries must be set to zero.
*
* @default - no job run queuing
*/
readonly jobRunQueuingEnabled?: boolean;
}

/**
Expand Down Expand Up @@ -76,9 +63,7 @@ export class RayJob extends Job {
throw new Error('Ray jobs only support Z.2X worker type');
}

const jobResource = new CfnJob(this, 'Resource', {
name: props.jobName,
description: props.description,
const jobResource = RayJob.setupJobResource(this, props, {
role: this.role.roleArn,
command: {
name: JobType.RAY,
Expand All @@ -88,13 +73,6 @@ export class RayJob extends Job {
glueVersion: GlueVersion.V4_0,
workerType: props.workerType ? props.workerType : WorkerType.Z_2X,
numberOfWorkers: props.numberOfWorkers ? props.numberOfWorkers: 3,
maxRetries: props.jobRunQueuingEnabled ? 0 : props.maxRetries,
jobRunQueuingEnabled: props.jobRunQueuingEnabled ? props.jobRunQueuingEnabled : false,
executionProperty: props.maxConcurrentRuns ? { maxConcurrentRuns: props.maxConcurrentRuns } : undefined,
timeout: props.timeout?.toMinutes(),
connections: props.connections ? { connections: props.connections.map((connection) => connection.connectionName) } : undefined,
securityConfiguration: props.securityConfiguration?.securityConfigurationName,
tags: props.tags,
defaultArguments,
});

Expand Down
Loading
Loading