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

[WIP] Allow OrchestrationStack retirement to be triggered from Service #432

Conversation

miha-plesko
Copy link
Contributor

@miha-plesko miha-plesko commented Sep 26, 2018

Current stack retirement automation assumes being triggered on stack directly, but we want to be able to use the entrypoint

/Cloud/Orchestration/Retirement/StateMachines/StackRetirement/Default

from the service that handles stack as well. With this commit we therefore adjust existing stack retirement workflow to accept stack passed either as

$evm.root['orchestration_stack']

or as

$evm.root['service'].orchestration_stack

In latter case we also make sure that Service status gets properly updated (so that the service is then moved to "Retired Services" directory).

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

@miq-bot add_label enhancement,gaprindashvili/yes,hammer/yes
@miq-bot assign @tinaafitz

/cc @d-m-u @agrare

Related PRs:

@@ -22,7 +32,12 @@
exit MIQ_ABORT
end

# Store stack as state var so we needn't search for it every time.
$evm.set_state_var('stack', stack)
$evm.set_state_var('stack_service', stack_service)
Copy link
Member

Choose a reason for hiding this comment

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

Do not store ServiceModel objects in the state_var area. These are not guaranteed to be de-serialized later and with result in errors. Instead, if needed, store the object's ID and do the lookup in the other method.

But I'm not sure much of this is needed.

We are storing the stack_service so we can call start_retirement and finish_retirement but that could just as easily be done with the try command against $evm.root['service'].

$evm.root['service'].try(:start_retirement)

And the lookup of the stack, outside of wanting to log where it comes from, could be:
stack = $evm.root['orchestration_stack'] || $evm.root['service'].orchestration_stack

Again, maybe we can use an embedded method to add logging and load the stack objects to de-dup the code.

@tinaafitz Please review.
cc @d-m-u

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @gmcculloug. May I also ask for your opinion on entrypoint selection? Was struggling between "service retirement" approach and "orchestration stack retirement approach", picked the latter eventually. It feels like the way to go, but would value your experienced opinion.

This is the PR where I switch entrypoint ManageIQ/manageiq#18023. So on Service UI I now click "Retire this service" which results in the workflow implemented here in the PR to run. Is this OK?

Copy link
Member

Choose a reason for hiding this comment

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

@miha-plesko Our recent retirement as a request enhancement has changed the way we process retirement. We're looking into how orchestration stacks are retired now vs. how they were handled previously and will report our findings back here.

@JPrause
Copy link
Member

JPrause commented Sep 28, 2018

@miq-bot add_label blocker

@miha-plesko miha-plesko force-pushed the allow-stack-retirement-from-service branch 2 times, most recently from a14b2b6 to 636c9c4 Compare September 28, 2018 15:39
@miha-plesko
Copy link
Contributor Author

@gmcculloug sorry it took me so long to fix it, but here it is. Stack is now retrieved from Workspace using embedded method. I like it much better to have it DRY, so glad you pointed it out. The PR seems bigger but it's just because we have to explicitly register the embedded method everytime we use it.

@tinaafitz looking forward to your opinion.

handle.log(:info, 'Fetched stack from $evm.object["orchestration_stack_id"]')
stack

# From $evm.root.
Copy link
Member

Choose a reason for hiding this comment

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

Looks like there is a nice opportunity to refactor this object and root lookup code. I would create another method and pass the object reference (handle.root or handle.object) and maybe a string to help with the logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gmcculloug yeah was a bit more involved, but I think it's worth it. Only the diff is ugly now, sorry about that. So what I did was:

  • move the mixin into /ManageIQ/Cloud/Orchestration/Lifecycle class because methods like get_stack and get_service should probably be consumed by other instances as well, not just Retirement
  • opt-in for include syntax to get rid of the gigantic namespace in front of get_stack & get_service
  • convert direct methods into class methods. Or else rubocop has hard time with include in global namespace
  • fix the Travis: was failing because the mixin wasn't loaded

Looking forward to your opinion.

Current stack retirement automation assumes being triggered on stack
directly, but we want to be able to use the entrypoint

```
/Cloud/Orchestration/Retirement/StateMachines/StackRetirement/Default
```

from the service that handles stack as well. With this commit we therefore
adjust existing stack retirement workflow to accept stack passed either
as

```
$evm.root['orchestration_stack']
```

or as

```
$evm.root['service'].orchestration_stack
```

In latter case we also make sure that Service status gets properly
updated (so that the service is then moved to "Retired Services"
directory).

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

Signed-off-by: Miha Pleško <[email protected]>
@miha-plesko miha-plesko force-pushed the allow-stack-retirement-from-service branch from 636c9c4 to cbb676b Compare October 1, 2018 12:24
@miq-bot
Copy link
Member

miq-bot commented Oct 1, 2018

Checked commit miha-plesko@cbb676b with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
10 files checked, 0 offenses detected
Everything looks fine. 🍰

@miha-plesko miha-plesko changed the title Allow OrchestrationStack retirement to be triggered from Service [WIP] Allow OrchestrationStack retirement to be triggered from Service Oct 2, 2018
@miq-bot miq-bot added the wip label Oct 2, 2018
@miha-plesko
Copy link
Contributor Author

Marking WIP for now as @tinaafitz suggests there is a better approach to fix the retirement and this change may not be needed. @tinaafitz please let me know if I can be of any help, we need this for 5.9.5 which is approx end of October.

@JPrause
Copy link
Member

JPrause commented Oct 10, 2018

@miha-plesko @tinaafitz with the final 5.9.5 final build on Oct 15, where does this PR stand?

@miha-plesko
Copy link
Contributor Author

@JPrause so @tinaafitz took the BZ over and I don't have latest status. @tinaafitz sorry to push you so hard, but is there something I can do to help you with this? We really need it for 5.9.5...

@tinaafitz
Copy link
Member

Hi @miha-plesko
This PR should resolve the last orchestration stack retirement issue:
ManageIQ/manageiq#18084

We can close this PR since content changes are not required.
Thanks again for all of your work on Orchestration Stack retirement!

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.

5 participants