-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
Ensure desired_vcpus is set before including it in update #4855
Ensure desired_vcpus is set before including it in update #4855
Conversation
When updating an AWS Batch compute environment, do not specify `DesiredvCpus` in the call to `UpdateComputeEnvironment` unless `desired_vcpus` is set.
Hey @hectcastro! Can you add an acceptance test which tries to cover this behavior? I have a feeling the proposed fix should actually be adding a Here's some relevant documentation: |
This reverts commit c256f6b.
Set min_vcpus to something greater than the default number of desired vCPUs when unset.
I think I've got a decent test case for not setting
I had a hard time implementing a fix with In trying to make a better sense of |
@@ -447,7 +473,8 @@ resource "aws_iam_role_policy_attachment" "aws_ec2_spot_fleet_role" { | |||
########## security group ########## | |||
|
|||
resource "aws_security_group" "test_acc" { | |||
name = "tf_acc_test_batch_sg_%d" | |||
name = "tf_acc_test_batch_sg_%d" | |||
vpc_id = "${aws_vpc.test_acc.id}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added to help produce a valid CE when desired_vcpu
is non-zero. If I made code changes to the resource such that it wouldn't send a value for desired vCPUs, the CE would get into an invalid state citing that its associated security group wasn't in the specified VPC.
@hectcastro Thanks. I was planning to file a bug and came across this issue.
Even if AWS Batch does increase desired_vcpus, For some reason, Any idea if this is the expected behaviour or related the issue you're fixing ? |
seems like the value needs to be excluded from the api request (or included if we pass back the value retrieved from aws). any update on this? anything I can do to move this along? |
Is there any current workaround for this issue ? |
I do something like this: |
Thanks for the workaround @theothertom. This solves my issue. But I had to modify the implementation to fit my requirement for couple of reasons, like:
So I used
Script:
And referenced like this:
Inspired from this gist |
@rajbettaswamy This one ignores desired_vcpus, |
@ratanos Wow ! This solves my issue and implementation is way cleaner and simple compared to mine. Thanks for your help. |
Using the lifecycle ignore changes no longer appears to work in 0.12 of terraform ie lifecycle {
ignore_changes = [
"compute_resources.0.desired_vcpus"
]
} |
@hectcastro @bflad Can we merge this PR? |
If anyone is on Terraform 0.12 and looking for a solution => hashicorp/terraform#21433 (comment) |
This only solves the issue when compute env is scaling down (not in all cases too). Therefore, we still need this PR merged ASAP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi everyone 👋 Apologies for the delay with fixing this bug. Using this additional test (thanks @hectcastro) and some minor logic adjustments (ignore sending 0 on creation and only send the value on update if the value is updated) the resource will now support fully optional desired_vcpus
.
Output from acceptance testing:
--- PASS: TestAccAWSBatchComputeEnvironment_createEc2WithoutComputeResources (29.11s)
--- PASS: TestAccAWSBatchComputeEnvironment_createSpotWithoutBidPercentage (32.25s)
--- PASS: TestAccAWSBatchComputeEnvironment_createUnmanaged (57.26s)
--- PASS: TestAccAWSBatchComputeEnvironment_createUnmanagedWithComputeResources (58.43s)
--- PASS: TestAccAWSBatchComputeEnvironment_createEc2WithTags (59.85s)
--- PASS: TestAccAWSBatchComputeEnvironment_createSpotWithAllocationStrategy (63.04s)
--- PASS: TestAccAWSBatchComputeEnvironment_createSpot (63.87s)
--- PASS: TestAccAWSBatchComputeEnvironment_createWithNamePrefix (72.05s)
--- PASS: TestAccAWSBatchComputeEnvironment_createEc2 (73.24s)
--- PASS: TestAccAWSBatchComputeEnvironment_launchTemplate (75.56s)
--- PASS: TestAccAWSBatchComputeEnvironment_updateState (87.29s)
--- PASS: TestAccAWSBatchComputeEnvironment_UpdateLaunchTemplate (100.51s)
--- PASS: TestAccAWSBatchComputeEnvironment_updateInstanceType (100.57s)
--- PASS: TestAccAWSBatchComputeEnvironment_updateComputeEnvironmentName (103.34s)
--- PASS: TestAccAWSBatchComputeEnvironment_ComputeResources_MaxVcpus (115.60s)
--- PASS: TestAccAWSBatchComputeEnvironment_ComputeResources_DesiredVcpus_Computed (159.84s)
--- PASS: TestAccAWSBatchComputeEnvironment_ComputeResources_MinVcpus (225.13s)
* origin/master: (59 commits) Update CHANGELOG for hashicorp#13935 resource/aws_batch_compute_environment: Remove resource from Terraform state when not found instead of returning error (hashicorp#13935) resource/aws_dynamodb_table: Return error instead of panic on empty CreateTable response (hashicorp#13925) Update CHANGELOG for hashicorp#13918 New Data Source: aws_efs_access_points (hashicorp#13918) tests/resource/aws_instance: Ensure sweeper has dependencies on resources that manage EC2 Instances (hashicorp#13917) Update CHANGELOG for hashicorp#13937 Update CHANGELOG for hashicorp#5448 resource/aws_cloudtrail: Handle single event selector in cloudtrail with non-default read_write_type (hashicorp#5448) Update CHANGELOG for hashicorp#13892 correct retry message to match in error handling correct import resource name accept empty string in volume_type validation Update CHANGELOG for hashicorp#4855 resource/aws_batch_compute_environment: Support fully optional desired_vcpus and wait for updates add retry error handling for SLR remove unused WebACL resource name in disappears test reference current AWS partition in iam role policy stmt remove duplicated disappears test step Update CHANGELOG for hashicorp#13926 ...
This has been released in version 2.68.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Fixes #4671 #4788
When updating an AWS Batch compute environment, do not specify
DesiredvCpus
in the call toUpdateComputeEnvironment
unlessdesired_vcpus
is set.Output from acceptance testing: