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

Use MiqSchedule for delayed MiqRequest execution #17520

Conversation

agrare
Copy link
Member

@agrare agrare commented Jun 4, 2018

Instead of using MiqQueue with deliver_on to run an MiqRequest later,
create a run-once MiqSchedule record.

@agrare agrare force-pushed the use_miq_schedule_for_delayed_miq_request_execution branch 2 times, most recently from db07016 to 772c659 Compare June 4, 2018 19:20
Copy link
Member

@bdunne bdunne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM. @gmcculloug Any thoughts?

start_time = get_option(:schedule_time).utc rescue nil

MiqSchedule.create!(
:name => "Request scheduled",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmcculloug you mentioned using the name here and I considered that, but I didn't see MiqRequest#name and didn't want to rely on source.name being available since source is polymorphic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property to use here would be MiqRequest#description

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay thanks, done

if get_option(:schedule_type) == "schedule"
deliver_on = get_option(:schedule_time).utc rescue nil
start_time = get_option(:schedule_time).utc rescue nil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self what if start_time is in the past (aka scheduled in the future but approval took longer)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend that we refactor this line. The classic UI sets get_option(:schedule_time) to a ActiveSupport::TimeWithZone object which supports the utc call.

I suspect that if this is set from the API or some other means it would set the time as a string in which case the code will silently error and use nil. It is also a good opportunity to get rid of the inline rescue as well.

Copy link
Member

@bdunne bdunne Jun 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by: bb29981

Instead of using MiqQueue with deliver_on to run an MiqRequest later,
create a run-once MiqSchedule record.
@agrare agrare force-pushed the use_miq_schedule_for_delayed_miq_request_execution branch from 772c659 to 08a2adf Compare June 5, 2018 20:14
@miq-bot
Copy link
Member

miq-bot commented Jun 5, 2018

Checked commit agrare@08a2adf with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 1 offense detected

app/models/miq_request.rb

@agrare
Copy link
Member Author

agrare commented Jun 7, 2018

Closing in favor of #17542

@agrare agrare closed this Jun 7, 2018
@agrare agrare deleted the use_miq_schedule_for_delayed_miq_request_execution branch August 14, 2018 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants