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

Add policy checking for the retirement request. #86

Merged
merged 1 commit into from
Apr 7, 2017

Conversation

lfu
Copy link
Member

@lfu lfu commented Apr 4, 2017

All events are sent to automate for processing since Event Switchboard PR.
Since then the policy checking for prevent action has changed from a sync process to an async process.

Part of #14641.

https://bugzilla.redhat.com/show_bug.cgi?id=1439331

@miq-bot assign @gmcculloug
@miq-bot add_label bug, darga/yes, euwe/yes

@miq-bot
Copy link
Member

miq-bot commented Apr 4, 2017

@lfu Cannot apply the following labels because they are not recognized: control, automate

@gmcculloug
Copy link
Member

@tinaafitz @mkanoor Please review

#
# Description: This method stops the retirement if the policy prevents
#
event = $evm.root['event_stream']
Copy link
Contributor

Choose a reason for hiding this comment

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

event = $evm.root['event_stream']
if event.full_data && event.full_data[:policy][:prevented]
$evm.log("info", "#{event.message}")
exit MIQ_STOP
Copy link
Contributor

Choose a reason for hiding this comment

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

@lfu In the Spec we might want to stub the exit method. The spec is tested outside of the Automate Engine

# Description: This method stops the retirement if the policy prevents
#
event = $evm.root['event_stream']
if event.full_data && event.full_data[:policy][:prevented]
Copy link
Contributor

Choose a reason for hiding this comment

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

@lfu we should check if event is 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.

@mkanoor I think it can reach this point in automate only if the event stream object exists.

@tinaafitz
Copy link
Member

@lfu Should the request_orchestration_stack_retire policy instance be changed as well?

@lfu
Copy link
Member Author

lfu commented Apr 4, 2017 via email

@mkanoor
Copy link
Contributor

mkanoor commented Apr 4, 2017

@mkanoor
Copy link
Contributor

mkanoor commented Apr 4, 2017

@lfu we should also be creating a notification when this method stops the process, e.g if retirement is requested and we dont raise a notification users would think retirement is stuck.
@tinaafitz please comment.

@tinaafitz
Copy link
Member

@mkanoor @lfu Yes, it would be important to create a notification if the prevent policy stops the process. Since the method is generic, we could just use "event.message" as the notification message.
Here's an example of the create_notification:
https://github.com/tinaafitz/manageiq-content/blob/master/content/automate/ManageIQ/Cloud/VM/Retirement/StateMachines/VMRetirement.class/__methods__/update_retirement_status.rb#L41

@tinaafitz
Copy link
Member

tinaafitz commented Apr 4, 2017

@lfu Spoke to @bzwei about stack retirement. These changes should apply to the orchestration_stack retirement request as well. We can add it to the db/fixtures/miq_event_definitions.csv.

@lfu lfu force-pushed the prevent_retirement_request branch from cc89bd9 to f814bd8 Compare April 4, 2017 21:24
@miq-bot
Copy link
Member

miq-bot commented Apr 4, 2017

Checked commit lfu@f814bd8 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
0 files checked, 0 offenses detected
Everything looks good. 🏆

@lfu
Copy link
Member Author

lfu commented Apr 5, 2017

@miq-bot add_label fine/yes

@tinaafitz
Copy link
Member

@lfu Looks good.

@gmcculloug gmcculloug merged commit c6c51d4 into ManageIQ:master Apr 7, 2017
@gmcculloug gmcculloug added this to the Sprint 58 Ending Apr 10, 2017 milestone Apr 7, 2017
simaishi pushed a commit that referenced this pull request Apr 7, 2017
Add policy checking for the retirement request.
(cherry picked from commit c6c51d4)
@simaishi
Copy link
Contributor

simaishi commented Apr 7, 2017

Fine backport details:

$ git log -1
commit b795b481722c08fc837668b6c779bbb8ac047387
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Fri Apr 7 14:37:54 2017 -0400

    Merge pull request #86 from lfu/prevent_retirement_request
    
    Add policy checking for the retirement request.
    (cherry picked from commit c6c51d4e6580c866334629b627cefb955fd1801d)

@simaishi
Copy link
Contributor

Euwe backport (to manageiq repo) details:

$ git log -1
commit 58b5c37c809081b02816ea5583b1b0595f19b86f
Author: Satoe Imaishi <simaishi@redhat.com>
Date:   Mon Apr 17 14:01:35 2017 -0400

    Merge pull request #86 from lfu/prevent_retirement_request
    
    Add policy checking for the retirement request.
    (cherry picked from commit c6c51d4e6580c866334629b627cefb955fd1801d)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1440402

@lfu lfu deleted the prevent_retirement_request branch September 29, 2018 14:33
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.

6 participants