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

Introduce Request and Task for firmware update #18801

Merged
merged 1 commit into from Jul 12, 2019

Conversation

miha-plesko
Copy link
Contributor

@miha-plesko miha-plesko commented May 23, 2019

We're introducing a new operation on physical server: firmware update. We want to use state machine-driven Request for it because it's a long running procedure and we want to be doing it on more than one server with a single click (and then track its progress).

That being said - the PR contains a new Request class and a new Task class (with internal state machine). The actual state machine implementation is done in provider codebase - depending on class of the selected physical server.

Related PR: #18774

@miq-bot add_label enhancement
@miq-bot assign @agrare

/cc @gmcculloug

@miha-plesko
Copy link
Contributor Author

Hello guys, this is basically a copy-paste of #18573 where we did physical server provisioning, only this time we do physical server firmware update.

@miha-plesko miha-plesko changed the title Introduce Request and Task for firmware update [WIP] Introduce Request and Task for firmware update May 24, 2019
@miq-bot miq-bot added the wip label May 24, 2019
@miha-plesko miha-plesko force-pushed the firmware-update branch 2 times, most recently from 8ee090d to 023cfcd Compare May 30, 2019 11:58
@miha-plesko miha-plesko changed the title [WIP] Introduce Request and Task for firmware update Introduce Request and Task for firmware update Jun 14, 2019
@miha-plesko miha-plesko reopened this Jun 14, 2019
@miha-plesko
Copy link
Contributor Author

The related PR has been merged yesterday, so I think we're good with this one as well. @gmcculloug any objections?

@miq-bot miq-bot removed the wip label Jun 14, 2019
@miha-plesko miha-plesko reopened this Jun 17, 2019
@gmcculloug
Copy link
Member

@miha-plesko Can you add a link to the related PR to the description for future reference. Also, was this PR dependent on it?

@miha-plesko
Copy link
Contributor Author

Added link to the description. No, this specific PR is not hard-related, but the actual internal state machine implementation (in Redfish provider, this PR here) depends on it.

@agrare
Copy link
Member

agrare commented Jun 20, 2019

@gmcculloug going to assign this to you since it is much more your area of expertise

@agrare agrare assigned gmcculloug and unassigned agrare Jun 20, 2019
@@ -110,6 +110,10 @@ def console_url
raise MiqException::Error, _("Console not supported")
end

def self.firmware_update_class
self::FirmwareUpdate
Copy link
Member

Choose a reason for hiding this comment

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

I only found the FirewareUpdate class defined in the Redfish PR https://github.com/ManageIQ/manageiq-providers-redfish/pull/69/files. I think we should have a FirmwareUpdate class at this intermediate class level and then the Provider class is sub-classed from this new one.

Something like:

class ManageIQ::Providers::PhysicalInfraManager::FirmwareUpdate < ::PhysicalServerFirmwareUpdateTask
  # Firmware update is triggered in a single Redfish API call for a list of servers
  # hence we don't need more than one task per firmware update request.
  SINGLE_TASK = true

  include_concern 'StateMachine'
end

Then the RedFish FirmwareUpdate class is derived from this new intermediate class.

Also, since this is a task is there a reason you picked the naming FirmwareUpdate? The name sounds more like an inventoried item then a task that would run a state-machine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @gmcculloug and sorry for delayed response due to my annual PTO. I've applied both your comments, the reason it was implemented different before is that I took VM provision request as a guideline where they

a) implement but don't ever extend the intermediate class (https://github.com/ManageIQ/manageiq/blob/master/app/models/manageiq/providers/cloud_manager/provision.rb#L1), see how providers then extend the Task directly anyway: https://github.com/ManageIQ/manageiq-providers-vmware/blob/master/app/models/manageiq/providers/vmware/infra_manager/provision.rb#L1

b) name the task as Provision and not as ProvisionTask https://github.com/ManageIQ/manageiq-providers-vmware/blob/master/app/models/manageiq/providers/vmware/infra_manager/provision.rb#L1

But I'm with you on this one, because seeing 'Provision' or 'FirmwareUpdate' inside provider feels like inventory item.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @miha-plesko. The MiqProvision class is a little special as it existed before we combined the request and tasks in sub-classed models. The name was kept for backward compatibility.

In newer models we use request/task as the model suffix.


def mark_as_completed
update_and_notify_parent(:state => 'finished', :message => msg('firmware update completed'))
MiqEvent.raise_evm_event(self, 'generic_task_finish', :message => "Done updating firmware on PhysicalServer(s)")
Copy link
Member

Choose a reason for hiding this comment

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

Is it required to raise an event here? Are you going to create policies based on this event?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No requirement currently, no, I copy-pasted from provisioning example thinking it's needed for some reason. Let me remove it then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

We're introducing a new operation on physical server: firmware update.
We want to use state machine-driven Request for it because it's a long
running procedure and we want to be doing it on more than one server
with a single click (and then track its progress).

That being said - the PR contains a new Request class and a new
Task class (with internal state machine). The actual state machine
implementation is done in provider codebase - depending on class of
the selected physical server.

Signed-off-by: Miha Pleško <miha.plesko@xlab.si>
@miq-bot
Copy link
Member

miq-bot commented Jul 11, 2019

Checked commit xlab-si@3fd59c8 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
12 files checked, 0 offenses detected
Everything looks fine. 🍰

Copy link
Member

@gmcculloug gmcculloug 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 gmcculloug merged commit 75595b5 into ManageIQ:master Jul 12, 2019
@gmcculloug gmcculloug added this to the Sprint 116 Ending Jul 22, 2019 milestone Jul 12, 2019
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.

None yet

5 participants