Skip to content

Add third party plugins #54

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

Open
wants to merge 37 commits into
base: chameleoncloud/xena
Choose a base branch
from

Conversation

Mark-Powers
Copy link

@Mark-Powers Mark-Powers commented Nov 30, 2021

This adds third party plugins, by creating a robust base class that manages the API, the service functions, the policies, and monitoring.

Notes for review:

  • the Host third party plugin was created to "show off" what this is capable of. Less important for us, but more of interest if this code is eventually merged upstream.
  • the base third party plugin is where most of the code is, essentially all of the plugin boilerplate.
  • The third party plugins all share the same db models, and custom data on the resource is stored in a JSON column.

@Mark-Powers Mark-Powers reopened this Dec 15, 2021
@Mark-Powers Mark-Powers marked this pull request as ready for review January 25, 2022 20:09
Change-Id: I9f0d7f47e92ed222cbb7cd042304317f6c2e74ee
Change-Id: Ia0bd2e39327b42597eae60a54a3050cc6ff0764c
Change-Id: I714c7389067e7d6d625790a3f776a07484652cb9
@Mark-Powers Mark-Powers removed the request for review from diurnalist August 4, 2022 15:47
@Mark-Powers Mark-Powers changed the base branch from chameleoncloud/train to chameleoncloud/xena June 1, 2023 15:30
@Mark-Powers
Copy link
Author

Note: This git history is too messy to merge on it's own, we should squash.

@Mark-Powers Mark-Powers requested a review from super-cooper June 12, 2023 19:53
Copy link

@super-cooper super-cooper left a comment

Choose a reason for hiding this comment

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

A lot of comments, but considering the sheer volume of code here, I think that's a pretty good ratio! I tried my best to fully understand everything going on here, and it helped that I've been working a little bit on plugins recently, but I did find myself getting a bit lost in the sauce. I hope my comments make sense and are useful.

Comment on lines +2048 to +2051
# Add extra filter if using 3rd party resource type
if resource_type not in EXTRA_CAPABILITY_MODELS:
query = query.join(models.Resource).filter_by(
resource_type=resource_type)

Choose a reason for hiding this comment

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

This looks like it could be consolidated into the above else body instead of performing this check again.

"An unexpected exception type was generated. This "
"indicates that some exception is not being wrapped "
"properly in a BlazarException."))
except common_ex.BlazarException:

Choose a reason for hiding this comment

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

Is there a reason why we're excluding the warning that used to be here?

Copy link
Author

Choose a reason for hiding this comment

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

This only exists in our fork, I'll revert my change for now

'status': status.reservation.PENDING
}
reservation = db_api.reservation_create(reservation_values)
plugin = self.plugin_manager.get(resource_type)

Choose a reason for hiding this comment

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

I'm not seeing any other references to ManagerService.plugin_manager in blazar. Is this supposed to be a call to self._get_plugin instead?

Copy link
Author

Choose a reason for hiding this comment

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

No idea how this got here, the branch is unreachable anyway since _get_plugin handles it already.

resource_type=resource_type)

plugin = self.plugins.get(resource_type)
plugin = self._get_plugin(resource_type)

Choose a reason for hiding this comment

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

self._get_plugin doesn't appear to have an appropriate check to throw UnsupportedResourceType and might result in confusing errors.

Copy link
Author

Choose a reason for hiding this comment

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

I am not sure what is better, unsupported resource type or invalid plugin name, which is raised right after if no plugin is returned. I left it as "invalid plugin name" to reduce the code base a bit.


if resource_type not in self.plugins:
if resource_type in self.plugins:
plugin = self.plugins.get(resource_type)

Choose a reason for hiding this comment

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

Is there a reason why we're not using self._get_plugin here? It seems that most of this code is duplicated between the regular and third party plugin branches of this conditional. We could just use _get_plugin and most of the same code for both.

Copy link
Author

Choose a reason for hiding this comment

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

Good point. Like above I've similarly made this just raise "invalid plugin name"

policy.check_enforcement(self.resource_type(), "delete")
resource = db_api.resource_get(self.resource_type(), resource_id)
if resource is None:
raise manager_ex.ResourceNotFound(

Choose a reason for hiding this comment

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

This exception appears to come from plugin_ex, not manager_ex.


def api_update(self, resource_id, data):
policy.check_enforcement(self.resource_type(), "put")
extras = data["extras"]

Choose a reason for hiding this comment

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

Should this be data.get("extras")? I see we check for not extras in a couple lines

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that's a good idea. I guess this would be the difference between not including it in the API request and it being empty. Either way, returning None is fine.

return rest

def query_resource_allocations(self, resources, lease_id=None,
reservation_id=None, detail=False):

Choose a reason for hiding this comment

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

detail appears unused

return resource_policy


class ResourceMonitorPlugin():

Choose a reason for hiding this comment

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

Should this implement BaseMonitorPlugin?

Copy link
Author

Choose a reason for hiding this comment

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

Good point

if port["data"]["port_id"] in active_port_ids
]
except Exception as e:
LOG.exception('Skipping health check. %s', str(e))

Choose a reason for hiding this comment

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

This should return, no?

Copy link
Author

Choose a reason for hiding this comment

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

I would expect it to return empty lists in the next statement, this is copied from the host monitor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants