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 notifications for leases #134

Merged
merged 1 commit into from
Jun 8, 2023
Merged

Add notifications for leases #134

merged 1 commit into from
Jun 8, 2023

Conversation

DanNiESh
Copy link
Contributor

@DanNiESh DanNiESh commented May 2, 2023

In progress

@tzumainn tzumainn changed the title Add notifications for leases [WIP] Add notifications for leases May 2, 2023
@tzumainn
Copy link
Contributor

tzumainn commented May 9, 2023

One question: is it possible for the Lease payload to include the Ironic Node payload? At the minimum, we probably want to have the node name and uuid and maybe the power state and provisioning state.

@DanNiESh
Copy link
Contributor Author

DanNiESh commented May 9, 2023

he Ironic Node payload?

One question: is it possible for the Lease payload to include the Ironic Node payload? At the minimum, we probably want to have the node name and uuid and maybe the power state and provisioning state.

Yes, I can add them into lease payload.

@DanNiESh DanNiESh force-pushed the events branch 5 times, most recently from ae7a636 to 360ffdc Compare May 23, 2023 02:01
@DanNiESh DanNiESh force-pushed the events branch 5 times, most recently from 3e7a470 to e8246e0 Compare May 24, 2023 19:17
@DanNiESh DanNiESh changed the title [WIP] Add notifications for leases Add notifications for leases May 24, 2023
@DanNiESh DanNiESh requested a review from tzumainn May 24, 2023 19:24
Copy link
Contributor

@tzumainn tzumainn left a comment

Choose a reason for hiding this comment

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

Looks good! A few comments.

esi_leap/common/notification_utils.py Outdated Show resolved Hide resolved
esi_leap/objects/lease.py Outdated Show resolved Hide resolved
esi_leap/objects/lease.py Show resolved Hide resolved
esi_leap/objects/lease.py Outdated Show resolved Hide resolved
esi_leap/common/rpc.py Outdated Show resolved Hide resolved
@DanNiESh
Copy link
Contributor Author

I made changes to the code according to the comments. I will test it on demo server sometime tomorrow.

esi_leap/common/rpc.py Outdated Show resolved Hide resolved
esi_leap/common/rpc.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tzumainn tzumainn left a comment

Choose a reason for hiding this comment

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

Hi! Some rather scattered comments, plus a bigger concern about the setting of resource information.

self._node_name = None
self._provision_state = None
self._power_state = None
self._node_properties = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah - notifications won't work on dummy/fake nodes unless they have these values as well, correct? I'm not sure we want to set these values however; adding a comment above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Notification only works on ironic nodes currently.

esi_leap/objects/lease.py Outdated Show resolved Hide resolved
@DanNiESh DanNiESh force-pushed the events branch 3 times, most recently from c391c15 to 8753b62 Compare June 3, 2023 00:06
@DanNiESh
Copy link
Contributor Author

DanNiESh commented Jun 3, 2023

I created a new class LeaseResourceEvent to pass in notification emit method. The new changes has been tested in demo server. A message json body looks like this:

{'message_id': 'f17a25ff-466e-45f7-9e59-5549ab3aa925', 'publisher_id': 'esi-leap-manager.esi-demo-ironic-controller.localdomain', 'event_type': 'esi_leap.LeaseResourceEvent.fulfill.end', 'priority': 'INFO', 'payload': {'esi_leap_object.name': 'LeaseCRUDPayload', 'esi_leap_object.namespace': 'esi_leap', 'esi_leap_object.version': '1.0', 'esi_leap_object.data': {'id': 113, 'name': None, 'uuid': '56a63bcd-43ac-440c-812d-e0f11166fc61', 'project_id': '218b3996b35b4e378f7701c78708d4d7', 'owner_id': '218b3996b35b4e378f7701c78708d4d7', 'resource_type': 'ironic_node', 'resource_uuid': 'f8b86846-86f2-4b63-95bc-fd3dfea93751', 'start_time': '2023-06-03T00:12:53Z', 'end_time': '9999-12-31T23:59:59Z', 'fulfill_time': None, 'expire_time': None, 'status': 'created', 'properties': {}, 'offer_uuid': None, 'parent_lease_uuid': None, 'node_name': 'dell-14', 'node_uuid': 'f8b86846-86f2-4b63-95bc-fd3dfea93751', 'node_provision_state': 'available', 'node_power_state': 'power off', 'node_properties': {'vendor': 'dell inc', 'local_gb': '557', 'cpus': '32', 'cpu_arch': 'x86_64', 'memory_mb': '393216', 'capabilities': 'cpu_vt:true,cpu_aes:true,cpu_hugepages:true,cpu_hugepages_1g:true,cpu_txt:true'}}}, 'timestamp': '2023-06-03 00:13:38.598030', '_unique_id': '1bdb824e578e4a1eb6c9e39bd6e424d7', '_context_user': None, '_context_project_id': None, '_context_system_scope': None, '_context_project': None, '_context_domain': None, '_context_user_domain': None, '_context_project_domain': None, '_context_is_admin': False, '_context_read_only': False, '_context_show_deleted': False, '_context_auth_token': None, '_context_request_id': 'req-f9524840-9c06-42cd-bb43-f434d2ba067d', '_context_global_request_id': None, '_context_resource_uuid': None, '_context_roles': [], '_context_user_identity': '- - - - -', '_context_is_admin_project': True}



@versioned_objects_base.VersionedObjectRegistry.register
class LeaseResourceEvent(base.ESILEAPObject):
Copy link
Contributor

Choose a reason for hiding this comment

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

I took a look at the Ironic code, and I'm pretty sure that what's done here can simply be done in LeaseCRUDPayload (which makes sense to me because otherwise that class isn't used all that much). Take a look at the Payloads in ironic/objects/node.py; they set values similar to what you do here. If you agree, then you can just move the logic in this class into LeaseCRUDPayload, and instantiate Payloads instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New changes updated.

add unit tests

Move emit notification to objects layer

add lease_resource_event object
@DanNiESh
Copy link
Contributor Author

DanNiESh commented Jun 8, 2023

Update: tested on demo server. The notification message is

{'message_id': '74f335a7-221b-46e1-b8f5-08b65dd548fa', 'publisher_id': 'esi-leap-manager.esi-demo-ironic-controller.localdomain', 'event_type': 'esi_leap.lease.fulfill.end', 'priority': 'INFO', 'payload': {'esi_leap_object.name': 'LeaseCRUDPayload', 'esi_leap_object.namespace': 'esi_leap', 'esi_leap_object.version': '1.0', 'esi_leap_object.data': {'id': 114, 'name': None, 'uuid': '412b071a-b37b-4a00-a0b4-ed90643b2d51', 'project_id': '218b3996b35b4e378f7701c78708d4d7', 'owner_id': '218b3996b35b4e378f7701c78708d4d7', 'resource_type': 'ironic_node', 'resource_uuid': 'f8b86846-86f2-4b63-95bc-fd3dfea93751', 'start_time': '2023-06-08T16:42:05Z', 'end_time': '9999-12-31T23:59:59Z', 'fulfill_time': '2023-06-08T16:43:02Z', 'expire_time': None, 'status': 'active', 'properties': {}, 'offer_uuid': None, 'parent_lease_uuid': None, 'node_name': 'dell-14', 'node_uuid': 'f8b86846-86f2-4b63-95bc-fd3dfea93751', 'node_provision_state': 'available', 'node_power_state': 'power on', 'node_properties': {'vendor': 'dell inc', 'local_gb': '557', 'cpus': '32', 'cpu_arch': 'x86_64', 'memory_mb': '393216', 'capabilities': 'cpu_vt:true,cpu_aes:true,cpu_hugepages:true,cpu_hugepages_1g:true,cpu_txt:true'}}}, 'timestamp': '2023-06-08 16:43:02.094990', '_unique_id': '3c3b9b5b725a4b99b7b27147d472cd10', '_context_user': None, '_context_project_id': None, '_context_system_scope': None, '_context_project': None, '_context_domain': None, '_context_user_domain': None, '_context_project_domain': None, '_context_is_admin': False, '_context_read_only': False, '_context_show_deleted': False, '_context_auth_token': None, '_context_request_id': 'req-f90b9c92-5955-47a0-a365-87fe33532457', '_context_global_request_id': None, '_context_resource_uuid': None, '_context_roles': [], '_context_user_identity': '- - - - -', '_context_is_admin_project': True}

@tzumainn
Copy link
Contributor

tzumainn commented Jun 8, 2023

Looks good - thanks!

@tzumainn tzumainn merged commit fda372a into CCI-MOC:master Jun 8, 2023
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