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

aws-autoscaling: Schedule.cron fails with "Cannot supply both 'day' and 'weekDay', use at most one" #27256

Closed
lmiguelmh opened this issue Sep 22, 2023 · 3 comments · Fixed by #27296
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling bug This issue is a bug. effort/small Small work item – less than a day of effort p2

Comments

@lmiguelmh
Copy link

lmiguelmh commented Sep 22, 2023

Describe the bug

Using the Schedule.cron fails on aws-cdk-lib==2.97.0 at synth time.

Cannot supply both 'day' and 'weekDay', use at most one

This is how I was calling it before:

autoscaling.Schedule.cron(
      week_day="MON-SUN",
      hour="1",  # 01:00 UTC+0 ~ 20:00 int PET (-05:00)
      minute="0",
  )

The problem may be here:

const cron = super.protectedCron({
weekDay: '*', // to override core.Schedule's default
day: '*', // to override core.Schedule's default
...options,
});
const cronSplit = cron.expressionString.slice(5).split(' '); // remove "cron(" from start
cronSplit.pop(); // remove year, since autoscaling does not accept it
const autoscalingCron = cronSplit.join(' ');

Expected Behavior

This was working before:

autoscaling.Schedule.cron(
      week_day="MON-SUN",
      hour="1",  # 01:00 UTC+0 ~ 20:00 int PET (-05:00)
      minute="0",
  )

Current Behavior

Error at synth time:

RuntimeError: Error: Cannot supply both 'day' and 'weekDay', use at most one

Reproduction Steps

Install latest aws-cdk-lib

Possible Solution

Workaround:

aws-cdk-lib==2.96.0

Additional Information/Context

No response

CDK CLI Version

2.97.0 (build d7cf3be)

Framework Version

No response

Node.js Version

v20.5.1

OS

Linux

Language

Python

Language Version

Python 3.11.5

Other information

No response

@lmiguelmh lmiguelmh added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 22, 2023
@github-actions github-actions bot added the @aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling label Sep 22, 2023
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 22, 2023
@khushail
Copy link
Contributor

khushail commented Sep 23, 2023

Hi @lmiguelmh , yes I am able to repro the issue. There is some default value being passed into day which is causing this error. Thanks for reporting this.

@khushail khushail added p2 effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Sep 23, 2023
@blankynap
Copy link

blankynap commented Sep 25, 2023

Had this issue today with ASG as well as ECS scheduled scaling. Jumped back to 2.96.0 where everything worked.

@mergify mergify bot closed this as completed in #27296 Oct 18, 2023
mergify bot pushed a commit that referenced this issue Oct 18, 2023
… day or weekday (#27296)

I was trying to fix [this bug](#27256), but [this revert PR](#27284) could cover it.

So I added the test cases for the bug fix.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-autoscaling Related to Amazon EC2 Auto Scaling bug This issue is a bug. effort/small Small work item – less than a day of effort p2
Projects
None yet
3 participants