-
Notifications
You must be signed in to change notification settings - Fork 896
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
Provider native operations state machine #14405
Provider native operations state machine #14405
Conversation
310e18c
to
52e4085
Compare
Overall LGTM. Still wonder if it might be nicer to use the better state machine system. |
52e4085
to
434a591
Compare
I love the ascii art state diagram. Also:
LOL, I heard this coming before I read it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excited about this!
I have a few comments, but nothing really mandatory.
# finished <---------- notifying --------------/ | ||
# :finish :notify | ||
# | ||
def load_transitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this method be protected?
I'm thinking of the possibility of later converging on one state machine. And this feels a bit like an internal detail that I would hope could be hidden away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It certainly can, done
end | ||
end | ||
|
||
if refresh_finished |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can refresh_finished?
become a private method that's called by poll_refresh
?
Then, this method becomes:
def poll_refresh
if refreshed_finished?
queue_signal(:notify)
else
queue_signal(:poll_refresh, :deliver_on => Time.now.utc + 1.minute)
end
end
I suppose you could one-line that into a ternary, but the if/else
looks fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can refresh_finished? become a private method that's called by poll_refresh?
Yeah I like that a lot, I'll just need to handle the refresh task error differently since right now it is returning out of poll_refresh and signaling :error
@@ -0,0 +1,129 @@ | |||
class ManageIQ::Providers::NativeCrud < Job |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming is hard...
ManageIQ::Providers::NativeOperationWorkflow
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for not Crud
I guess it's for any operation thats to be scheduled (async) and which needs a refresh after it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I like Workflow
, aligns better with the miq_provision_workflow
/miq_request_workflow
# v | | ||
# finished <---------- notifying --------------/ | ||
# :finish :notify | ||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
f59205e
to
db27d48
Compare
Okay moved everything from |
This pull request is not mergeable. Please rebase and repush. |
db27d48
to
103c4e0
Compare
This pull request is not mergeable. Please rebase and repush. |
103c4e0
to
454a00b
Compare
@job.signal(:start) | ||
end | ||
|
||
it 'doesn\'t allow poll_native_task signal' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: if you use double quote, then you don't have to escape the '
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I started with '
and wanted to keep it consistent...maybe should switch to "
everywhere here
3ca48a4
to
1764f21
Compare
Checked commits agrare/manageiq@a32c8a1~...1764f21 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
This LGTM... @blomquisg if you're happy with it, please merge. |
@agrare do you plan using this anywhere? Otherwise I could use https://www.pivotaltracker.com/story/show/144430761 to make use of this... |
@durandom I was going to start moving some vm power ops over to use this, but by all means start using/modifying it for whatever you want :) |
the sleep here is also needed because tower needs some time to actually propagate it's updates if we would return immediately it _could_ be that the we get the old playbooks the whole sleep business is a workaround anyway until we get proper polling via ManageIQ#14405
the sleep here is also needed because tower needs some time to actually propagate it's updates if we would return immediately it _could_ be that the we get the old playbooks the whole sleep business is a workaround anyway until we get proper polling via ManageIQ#14405
the sleep here is also needed because tower needs some time to actually propagate it's updates if we would return immediately it _could_ be that the we get the old playbooks the whole sleep business is a workaround anyway until we get proper polling via ManageIQ/manageiq#14405 (transferred from ManageIQ/manageiq@85090c9)
@Glutexo yes it is used by https://github.com/ManageIQ/manageiq/blob/master/app/models/service/resource_linking.rb#L21-L23 via https://github.com/ManageIQ/manageiq/blob/master/app/models/service/linking_workflow.rb. It is really based around something that needs to do an EmsRefresh and get the resulting object though. |
Sorry, my bad, I deleted my comment instead of editing it. N00b. Pasting here for the context: Is this actually used somewhere already? I‘ve found a reference to this PR in |
@Glutexo if you don't need to do the EmsRefresh step you can probably just use the first few states, you should be able to provide your own state transitions in a subclass |
Thanks, @agrare! I’ll take a look at it for reference. I guess there are two reasons why there are those nasty things going on:
From what you said it looks like the |
This provides the basics for a provider extensible CRUD state machine.
The basic workflow is:
State transition diagram:
Examples of a successful and an unsuccessful notification from a NativeCrud job: