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(batch): CE update handling #1567

Merged
merged 1 commit into from
Nov 12, 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
10 changes: 10 additions & 0 deletions apis/batch/generator-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@ ignore:
- CreateComputeEnvironmentInput.ComputeResources.InstanceRole
- UpdateComputeEnvironmentInput.ComputeResources.InstanceRole
- CreateComputeEnvironmentInput.ComputeResources.SpotIamFleetRole
- UpdateComputeEnvironmentInput.ComputeResources.AllocationStrategy
- UpdateComputeEnvironmentInput.ComputeResources.BidPercentage
- UpdateComputeEnvironmentInput.ComputeResources.Ec2Configuration
- UpdateComputeEnvironmentInput.ComputeResources.Ec2KeyPair
- UpdateComputeEnvironmentInput.ComputeResources.InstanceTypes
- UpdateComputeEnvironmentInput.ComputeResources.LaunchTemplate
- UpdateComputeEnvironmentInput.ComputeResources.PlacementGroup
- UpdateComputeEnvironmentInput.ComputeResources.Tags
- UpdateComputeEnvironmentInput.ComputeResources.Type
- UpdateComputeEnvironmentInput.ComputeResources.UpdateToLatestImageVersion
- UpdateComputeEnvironmentInput.UpdatePolicy
- CreateComputeEnvironmentInput.ComputeResources.ImageId # deprecated, use ec2Configuration[].imageIdOverride instead
- UpdateComputeEnvironmentInput.ComputeResources.ImageId
- CreateJobQueueInput.JobQueueName
Expand Down
30 changes: 27 additions & 3 deletions apis/batch/v1alpha1/custom_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ type CustomComputeEnvironmentParameters struct {
// For more information, see VPCs and Subnets (https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html)
// in the Amazon VPC User Guide.
// (Subnets is originally a field of ComputeResources)
// Subnets is a required field for CE type MANAGED
// Subnets is a required field for CE type MANAGED.
// For a MANGED CE of type EC2 or SPOT to be able to update this field
// Allocation Strategy BEST_FIT_PROGRESSIVE or SPOT_CAPACITY_OPTIMIZED is required.
// +optional
// +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-aws/apis/ec2/v1beta1.Subnet
// +crossplane:generate:reference:refFieldName=SubnetIDRefs
Expand All @@ -78,6 +80,8 @@ type CustomComputeEnvironmentParameters struct {
// and must contain at least one security group. Fargate doesn't support launch
// templates. If security groups are specified using both securityGroupIds and
// launchTemplate, the values in securityGroupIds are used.
// For a MANGED CE of type EC2 or SPOT to be able to update this field
// Allocation Strategy BEST_FIT_PROGRESSIVE or SPOT_CAPACITY_OPTIMIZED is required.
// +optional
// +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-aws/apis/ec2/v1beta1.SecurityGroup
// +crossplane:generate:reference:refFieldName=SecurityGroupIDRefs
Expand All @@ -99,6 +103,9 @@ type CustomComputeEnvironmentParameters struct {
// (ARN) of an instance profile. For example, ecsInstanceRole or arn:aws:iam::<aws_account_id>:instance-profile/ecsInstanceRole
// . For more information, see Amazon ECS Instance Role (https://docs.aws.amazon.com/batch/latest/userguide/instance_IAM_role.html)
// in the Batch User Guide.
// Only applicable to MANGED CE of type EC2 or SPOT.
// This field can be updated for CE only
// with Allocation Strategy BEST_FIT_PROGRESSIVE or SPOT_CAPACITY_OPTIMIZED.
//
// This parameter isn't applicable to jobs that are running on Fargate resources,
// and shouldn't be specified.
Expand Down Expand Up @@ -150,11 +157,28 @@ type CustomComputeEnvironmentParameters struct {
// +optional
SpotIAMFleetRoleSelector *xpv1.Selector `json:"spotIamFleetRoleSelector,omitempty"`

// Specifies the infrastructure update policy for the compute environment. For
// more information about infrastructure updates, see Updating compute environments
// (https://docs.aws.amazon.com/batch/latest/userguide/updating-compute-environments.html)
// in the Batch User Guide.
// Only applicable to MANGED CE of type EC2 or SPOT.
// This field requires an update request to be set and it can be updated for CE only
// with Allocation Strategy BEST_FIT_PROGRESSIVE or SPOT_CAPACITY_OPTIMIZED.
//
// JobExecutionTimeoutMinutes specifies the job timeout (in minutes) when the compute environment
// infrastructure is updated. The default value is 30.
//
// TerminateJobsOnUpdate specifies whether jobs are automatically terminated when the computer
// environment infrastructure is updated. The default value is false.
UpdatePolicy *UpdatePolicy `json:"updatePolicy,omitempty"`

// Specifies whether the AMI ID is updated to the latest one that's supported
// by Batch when the compute environment has an infrastructure update.
// The default value is false.
// This field requires an update request to be changed and it can be updated for CE only
// with Allocation Strategy BEST_FIT_PROGRESSIVE and SPOT_CAPACITY_OPTIMIZED.
// Only applicable to MANGED CE of type EC2 or SPOT.
// This field requires an update request to be set and it can be updated for CE only
// with Allocation Strategy BEST_FIT_PROGRESSIVE or SPOT_CAPACITY_OPTIMIZED.
// Also to get this field changed, you need to include another change to trigger an update.
//
// If an AMI ID is specified in the imageIdOverride parameters or
// by the launch template specified in the launchTemplate parameter, this parameter
Expand Down
72 changes: 5 additions & 67 deletions apis/batch/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 0 additions & 26 deletions apis/batch/v1alpha1/zz_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion examples/batch/ec2computeenvironment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ spec:
tags:
ce: "my-ec2-ce"
other: "blaa"
# for EC2 and EC2Spot: If the original allocation strategy is BEST_FIT,
# infrastructure updates aren't supported.
# In that case the only fields in computeResources that can be updated are:
# minvCPUs and maxvCPUs
computeResources:
type_: EC2
allocationStrategy: BEST_FIT_PROGRESSIVE # optional, AWS default is BEST_FIT
minvCPUs: 1
maxvCPUs: 32
instanceTypes:
- "optimal"
tags:
cr: "cr-for-ec2-ce"
other: "non-updatable-tag"
other: "updatable-tag"
providerConfigRef:
name: example
8 changes: 6 additions & 2 deletions examples/batch/spotec2computeenvironment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ spec:
name: spot-fleet-tagging-role
tags:
ce: "my-spotec2-ce"
# for EC2 and EC2Spot: If the original allocation strategy is BEST_FIT,
# infrastructure updates aren't supported.
# In that case the only fields in computeResources that can be updated are:
# minvCPUs and maxvCPUs
computeResources:
type_: SPOT
allocationStrategy: BEST_FIT
maxvCPUs: 24
allocationStrategy: SPOT_CAPACITY_OPTIMIZED # optional, AWS default is BEST_FIT
minvCPUs: 1
maxvCPUs: 24
instanceTypes:
- "optimal"
providerConfigRef:
Expand Down
53 changes: 41 additions & 12 deletions package/crds/batch.aws.crossplane.io_computeenvironments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ spec:
short name or full Amazon Resource Name (ARN) of an instance
profile. For example, ecsInstanceRole or arn:aws:iam::<aws_account_id>:instance-profile/ecsInstanceRole
. For more information, see Amazon ECS Instance Role (https://docs.aws.amazon.com/batch/latest/userguide/instance_IAM_role.html)
in the Batch User Guide. \n This parameter isn't applicable
to jobs that are running on Fargate resources, and shouldn't
be specified."
in the Batch User Guide. Only applicable to MANGED CE of type
EC2 or SPOT. This field can be updated for CE only with Allocation
Strategy BEST_FIT_PROGRESSIVE or SPOT_CAPACITY_OPTIMIZED. \n
This parameter isn't applicable to jobs that are running on
Fargate resources, and shouldn't be specified."
type: string
instanceRoleRef:
description: InstanceRoleRef is a reference to the IAM InstanceProfile
Expand Down Expand Up @@ -316,6 +318,9 @@ spec:
at least one security group. Fargate doesn't support launch
templates. If security groups are specified using both securityGroupIds
and launchTemplate, the values in securityGroupIds are used.
For a MANGED CE of type EC2 or SPOT to be able to update this
field Allocation Strategy BEST_FIT_PROGRESSIVE or SPOT_CAPACITY_OPTIMIZED
is required.
items:
type: string
type: array
Expand Down Expand Up @@ -588,7 +593,9 @@ spec:
and Subnets (https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Subnets.html)
in the Amazon VPC User Guide. (Subnets is originally a field
of ComputeResources) Subnets is a required field for CE type
MANAGED
MANAGED. For a MANGED CE of type EC2 or SPOT to be able to update
this field Allocation Strategy BEST_FIT_PROGRESSIVE or SPOT_CAPACITY_OPTIMIZED
is required.
items:
type: string
type: array
Expand Down Expand Up @@ -619,17 +626,39 @@ spec:
the type parameter is set to UNMANAGED."
format: int64
type: integer
updatePolicy:
description: "Specifies the infrastructure update policy for the
compute environment. For more information about infrastructure
updates, see Updating compute environments (https://docs.aws.amazon.com/batch/latest/userguide/updating-compute-environments.html)
in the Batch User Guide. Only applicable to MANGED CE of type
EC2 or SPOT. This field requires an update request to be set
and it can be updated for CE only with Allocation Strategy BEST_FIT_PROGRESSIVE
or SPOT_CAPACITY_OPTIMIZED. \n JobExecutionTimeoutMinutes specifies
the job timeout (in minutes) when the compute environment infrastructure
is updated. The default value is 30. \n TerminateJobsOnUpdate
specifies whether jobs are automatically terminated when the
computer environment infrastructure is updated. The default
value is false."
properties:
jobExecutionTimeoutMinutes:
format: int64
type: integer
terminateJobsOnUpdate:
type: boolean
type: object
updateToLatestImageVersion:
description: "Specifies whether the AMI ID is updated to the latest
one that's supported by Batch when the compute environment has
an infrastructure update. The default value is false. This field
requires an update request to be changed and it can be updated
for CE only with Allocation Strategy BEST_FIT_PROGRESSIVE and
SPOT_CAPACITY_OPTIMIZED. \n If an AMI ID is specified in the
imageIdOverride parameters or by the launch template specified
in the launchTemplate parameter, this parameter is ignored.
For more information on updating AMI IDs during an infrastructure
update, see Updating the AMI ID (https://docs.aws.amazon.com/batch/latest/userguide/updating-compute-environments.html#updating-compute-environments-ami)
an infrastructure update. The default value is false. Only applicable
to MANGED CE of type EC2 or SPOT. This field requires an update
request to be set and it can be updated for CE only with Allocation
Strategy BEST_FIT_PROGRESSIVE or SPOT_CAPACITY_OPTIMIZED. Also
to get this field changed, you need to include another change
to trigger an update. \n If an AMI ID is specified in the imageIdOverride
parameters or by the launch template specified in the launchTemplate
parameter, this parameter is ignored. For more information on
updating AMI IDs during an infrastructure update, see Updating
the AMI ID (https://docs.aws.amazon.com/batch/latest/userguide/updating-compute-environments.html#updating-compute-environments-ami)
in the Batch User Guide. \n When updating a compute environment,
changing this setting requires an infrastructure update of the
compute environment. For more information, see Updating compute
Expand Down
Loading