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

[Bug]: Scheduled Action Update State Override Start Time and End Time with Null value #33708

Closed
yaput opened this issue Oct 2, 2023 · 3 comments · Fixed by #33713
Closed
Labels
bug Addresses a defect in current functionality. service/appautoscaling Issues and PRs that pertain to the appautoscaling service.
Milestone

Comments

@yaput
Copy link
Contributor

yaput commented Oct 2, 2023

Terraform Core Version

1.1.X

AWS Provider Version

5.3.0

Affected Resource(s)

  • aws_scheduledaction

Expected Behavior

  1. Create new scheduled action with startTime and endTime
  2. Resource created and attached to ECS
  3. Update minCapacity for existing scheduled action that has been created at step 1
  4. schedule value updated, but retain start time and end time value

Actual Behavior

  1. Create new scheduled action with startTime and endTime
  2. Resource created and attached to ECS
  3. Update minCapacity for existing scheduled action that has been created at step 1
  4. schedule value updated, startTime and endTime value changed to null

Relevant Error/Panic Output Snippet

No Error, but it cause my scheduled action keep running without `endTime` and cost us some money to unexpected scale out event for longer than expected.

Terraform Configuration Files

resource "aws_appautoscaling_scheduled_action" "scale_morning_promo_start" {
  name               = module.autoscaling_schedule_morning_promo_start_traffic.name
  service_namespace  = local.service_namespace
  resource_id        = module.ecs-app.resource_id
  scalable_dimension = local.scalable_dimension
  timezone           = local.timezone
  schedule           = "cron(45 07 * * ? *)"
  start_time         = "2023-02-24T00:00:00+07:00"
  end_time           = "2023-02-24T23:59:59+07:00"

  scalable_target_action {
    min_capacity = local.ecs_task_count_promo_target_high
  }
  count = local.disable_resource
}

This the only config, but as I mentioned above on the behavior section, I update the minCapacity value and re-apply it again, then start_time and end_time is null when I check the schedule action state.

Steps to Reproduce

  1. Create new scheduler with above config:
        {
            "ScalableDimension": "ecs:service:DesiredCount", 
            "Schedule": "cron(0 7 * * ? *)", 
            "ResourceId": "service/my-service-cluster/my-app-123abcde", 
            "CreationTime": 1685949955.663, 
            "ScheduledActionARN": "arn:aws:autoscaling:ap-southeast-1:1234567:scheduledAction:c6540143-e917-4d89-8aab-5f61566b4ee2:resource/ecs/service/my-service-cluster/my-app-123abcde:scheduledActionName/my-service-normal-123456", 
            "ScalableTargetAction": {
                "MinCapacity": 1
            }, 
            "ScheduledActionName": "my-service-normal-1234566", 
            "StartTime": 1685293200.0, 
            "Timezone": "Asia/Jakarta", 
            "ServiceNamespace": "ecs", 
            "EndTime": 1685725199.0
        }, 
  1. Re-apply with updated minCapacity value (Notice that StartTime and EndTime are missing after update):
        {
            "ScalableDimension": "ecs:service:DesiredCount", 
            "Schedule": "cron(0 7 * * ? *)", 
            "ResourceId": "service/my-service-cluster/my-app-123abcde", 
            "CreationTime": 1685949955.663, 
            "ScheduledActionARN": "arn:aws:autoscaling:ap-southeast-1:1234567:scheduledAction:c6540143-e917-4d89-8aab-5f61566b4ee2:resource/ecs/service/my-service-cluster/my-app-123abcde:scheduledActionName/my-service-normal-123456", 
            "ScalableTargetAction": {
                "MinCapacity": 2
            }, 
            "ScheduledActionName": "my-service-normal-1234566", 
            "Timezone": "Asia/Jakarta", 
            "ServiceNamespace": "ecs"
        }, 

Debug Output

I tried to debug it locally with main branch and checkout a new branch base on main and try to debug it from I got the unexpected result when run the acc test.

  1. When creating new resource, the payload is:
{
  "EndTime": "2023-10-07T14:45:21Z",
  "ResourceId": "service/tf-acc-test-12345/tf-acc-test-12345",
  "ScalableDimension": "ecs:service:DesiredCount",
  "ScalableTargetAction": {
    "MaxCapacity": 5,
    "MinCapacity": 1
  },
  "Schedule": "at(2023-09-30T14:45:21)",
  "ScheduledActionName": "tf-acc-test-12345",
  "ServiceNamespace": "ecs",
  "StartTime": "2023-10-01T14:45:21Z",
  "Timezone": "UTC"
}
  1. When update the existing scheduler the resource payload become (Notice that StartTime and EndTime are missing after update):
{
  "EndTime": null,
  "ResourceId": "service/tf-acc-test-12345/tf-acc-test-12345",
  "ScalableDimension": "ecs:service:DesiredCount",
  "ScalableTargetAction": null,
  "Schedule": "at(2023-10-01T14:45:21)",
  "ScheduledActionName": "tf-acc-test-12345",
  "ServiceNamespace": "ecs",
  "StartTime": null,
  "Timezone": null
}

Panic Output

No response

Important Factoids

Since I'm newb so I tried to debug it locally by print the request payload and the state that has been stored, here is my findings:

  1. Create new scheduled action input payload:
{
  "EndTime": "2023-10-10T10:10:59Z",
  "ResourceId": "service/tf-acc-test-12345/tf-acc-test-12345",
  "ScalableDimension": "ecs:service:DesiredCount",
  "ScalableTargetAction": {
    "MaxCapacity": 5,
    "MinCapacity": 1
  },
  "Schedule": "at(2023-10-03T10:10:59)",
  "ScheduledActionName": "tf-acc-test-12345",
  "ServiceNamespace": "ecs",
  "StartTime": "2023-10-04T10:10:59Z",
  "Timezone": "UTC"
}

with the stored state:

{
  "CreationTime": "2023-10-02T03:11:15.605Z",
  "EndTime": "2023-10-10T10:10:59Z",
  "ResourceId": "service/tf-acc-test-12345/tf-acc-test-12345",
  "ScalableDimension": "ecs:service:DesiredCount",
  "ScalableTargetAction": {
    "MaxCapacity": 5,
    "MinCapacity": 1
  },
  "Schedule": "at(2023-10-03T10:10:59)",
  "ScheduledActionARN": "arn:aws:autoscaling:ap-southeast-1:12345:scheduledAction:2ca2b6de-ea80-47cc-9131-0f58c3a38ef2:resource/ecs/service/tf-acc-test-12345/tf-acc-test-12345:scheduledActionName/tf-acc-test-12345",
  "ScheduledActionName": "tf-acc-test-12345",
  "ServiceNamespace": "ecs",
  "StartTime": "2023-10-04T10:10:59Z",
  "Timezone": "UTC"
}
  1. Update Schedule value above scheduled action input payload:
{
  "EndTime": null,
  "ResourceId": "service/tf-acc-test-12345/tf-acc-test-12345",
  "ScalableDimension": "ecs:service:DesiredCount",
  "ScalableTargetAction": null,
  "Schedule": "at(2023-10-04T10:10:59)",
  "ScheduledActionName": "tf-acc-test-12345",
  "ServiceNamespace": "ecs",
  "StartTime": null,
  "Timezone": null
}

stored state after update

{
  "CreationTime": "2023-10-02T03:11:15.605Z",
  "EndTime": null,
  "ResourceId": "service/tf-acc-test-12345/tf-acc-test-12345",
  "ScalableDimension": "ecs:service:DesiredCount",
  "ScalableTargetAction": {
    "MaxCapacity": 5,
    "MinCapacity": 1
  },
  "Schedule": "at(2023-10-04T10:10:59)",
  "ScheduledActionARN": "arn:aws:autoscaling:ap-southeast-1:12345:scheduledAction:2ca2b6de-ea80-47cc-9131-0f58c3a38ef2:resource/ecs/service/tf-acc-test-12345/tf-acc-test-7236294745198118092:scheduledActionName/tf-acc-test-12345",
  "ScheduledActionName": "tf-acc-test-12345",
  "ServiceNamespace": "ecs",
  "StartTime": null,
  "Timezone": "UTC"
}

Somehow StartTime and EndTime has been override but other value like ScalableTargetAction doesn't get override by null value

References

No response

Would you like to implement a fix?

Yes

@yaput yaput added the bug Addresses a defect in current functionality. label Oct 2, 2023
@github-actions github-actions bot added the service/appautoscaling Issues and PRs that pertain to the appautoscaling service. label Oct 2, 2023
@github-actions
Copy link

github-actions bot commented Oct 2, 2023

Community Note

Voting for Prioritization

  • Please vote on this issue by adding a 👍 reaction to the original post to help the community and maintainers prioritize this request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

Volunteering to Work on This Issue

  • If you are interested in working on this issue, please leave a comment.
  • If this would be your first contribution, please review the contribution guide.

@terraform-aws-provider terraform-aws-provider bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 2, 2023
@justinretzolk justinretzolk removed the needs-triage Waiting for first response or review from a maintainer. label Oct 26, 2023
@github-actions github-actions bot added this to the v5.42.0 milestone Mar 18, 2024
Copy link

This functionality has been released in v5.42.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. Thank you!

Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/appautoscaling Issues and PRs that pertain to the appautoscaling service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants