Skip to content

Add HostdeviceResource to HostResource in inventory#847

Open
cjnolan wants to merge 3 commits intomainfrom
host-resource-vpro-support
Open

Add HostdeviceResource to HostResource in inventory#847
cjnolan wants to merge 3 commits intomainfrom
host-resource-vpro-support

Conversation

@cjnolan
Copy link
Contributor

@cjnolan cjnolan commented Feb 13, 2026

Description

Adds a new HostdeviceResource to the HostResource object in inventory. This allows details to the current vPRO support status of an edge node to be stored for each host as part of the report from the edge node HW Discovery Agent

Fixes # (issue)

Any Newly Introduced Dependencies

Please describe any newly introduced 3rd party dependencies in this change. List their name, license information and how they are used in the project.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Checklist:

  • I agree to use the APACHE-2.0 license for my code changes
  • I have not introduced any 3rd party dependency changes
  • I have performed a self-review of my code

resources: []*computev1.HostdeviceResource{expHostdevice1, expHostdevice2},
valid: true,
},
"FilterDeviceName": {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test case probably fails because the filter find two resources with the same name - createresreq1 and createresreq2 should have different devicename for this test case to pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the device name in the second resource.

}
}

func Test_StrongRelations_On_Delete_HostDevice(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test fails most likely, because the helper function CreateHostdevice() in inv_testing has cleanup function registered that makes sure that the resource gets deleted - thus it is already deleted when Host deletion is executed. You should try using this function to create Hostdevice CreateHostdeviceNoCleanup()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test needs to use the CreateHostdevice function with the cleanup as it is testing the relation between HostDevice and Host. The cleanup function it runs removes the Host after the test has completed, as per the documentation. So the HostDevice would not be deleted when the Host resource is deleted.

After some additional investigation, I have made a fix to the protobuf API to address this issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cjnolan was it fixed by changing one-to-one relationship to one-to-many for host-hostdevice?

host := dao.CreateHost(t, tenantID)
return tenantID, len(
[]any{
dao.CreateHostDeviceNoCleanup(t, tenantID, host),
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

"HostNic": {
resID: hostNic.GetResourceId(),
},
"HostDevice": {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test case is probably failing because this function needs to be updated for eager loading with : WithHostdevice() in https://github.com/open-edge-platform/infra-core/blob/host-resource-vpro-support/inventory/internal/store/host.go#L180

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, that was also needed as was a change to the filterHosts function as well in order to enable the eager loading, fixed.

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.

3 participants