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

SWATCH-1929: Replace rhsm.VM_HOST_UUID by system profile.virtual_host_uuid #3043

Merged
merged 1 commit into from Feb 19, 2024

Conversation

Sgitario
Copy link
Contributor

@Sgitario Sgitario commented Feb 8, 2024

Jira issue: SWATCH-1929

Description

Add support for the recently added system profile fact virtual_host_uuid (RedHatInsights/inventory-schemas#121) which replaces legacy facts rhsm.VM_HOST_UUID.

Testing

1.- podman-compose up
2.- Create hosts for orgId=16790890 in Insights database

./bin/insert-mock-hosts --hbi --clear --org 16790890 --account account123 --num-guests 1 --hypervisor-id 123456

3.- DEV_MODE=true SUBSCRIPTION_SYNC_ENABLED=true ENABLE_SYNCHRONOUS_OPERATIONS=true ./gradlew :bootRun
4.- Perform tally snapshot:

http PUT ":8000/api/rhsm-subscriptions/v1/internal/rpc/tally/snapshots/16790890" \
Origin:console.redhat.com \
x-rh-swatch-synchronous-request:true \
x-rh-swatch-psk:placeholder \
x-rh-identity:$(echo -n '{"identity":{"account_number":"","type":"User","user":{"is_org_admin":true},"internal":{"org_id":"16790890"}}}' | base64 -w 0)

5.- Query the created hosts in the swatch database and confirm the virtual_host_uuid has been used:

SELECT hypervisor_uuid FROM hosts;

It should be 123456.

@Sgitario Sgitario added the QE Pull request should be approved by QE before merge label Feb 8, 2024
@san7ket san7ket self-requested a review February 9, 2024 10:19
@san7ket
Copy link
Contributor

san7ket commented Feb 9, 2024

/retest

1 similar comment
@san7ket
Copy link
Contributor

san7ket commented Feb 13, 2024

/retest

@kahowell kahowell self-assigned this Feb 13, 2024
@kahowell kahowell self-requested a review February 13, 2024 15:21
Comment on lines 89 to 90
+ "left outer join hosts h_ on h.facts->'satellite'->>'virtual_host_uuid' = h_.canonical_facts->>'subscription_manager_id' "
+ "where h.facts->'satellite'->'virtual_host_uuid' is not null "
Copy link
Contributor

Choose a reason for hiding this comment

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

We actually still need to consult the 'satellite'->'virtual_host_uuid' fact, because the reporting pipeline for Satellite doesn't yet use the canonical field.

I determined this via:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the pointers! I've just removed the satelite changes and updated the PR and JIRA descriptions.

@Sgitario Sgitario changed the title SWATCH-1929: Replace satellite.virtual_host_uuid and rhsm.VM_HOST_UUID by system profile.virtual_host_uuid SWATCH-1929: Replace rhsm.VM_HOST_UUID by system profile.virtual_host_uuid Feb 14, 2024
@ntkathole
Copy link
Member

QE : Needs to modify insights-qe/iqe-rhsm-subscriptions-plugin/-/blob/master/iqe_rhsm_subscriptions/__init__.py?ref_type=heads#L975 VM_HOST_UUID while generating hypervisor in HBI using Kafka to fix the test failure.

Copy link
Contributor

@san7ket san7ket left a comment

Choose a reason for hiding this comment

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

  • Create a Hypervisor Guest map using swatch-client or smqe-tools in a account. Creates one hypervsior with 2 guests

swatch-client consumer hypervisor -u <username> -g 2

  • In EE, Sync conduit and check HBI if the hosts are present along with virtual_host_uuid for guests

app.host_inventory.rest_client.hosts_api.api_host_get_host_list()

app.host_inventory.rest_client.hosts_api.api_host_get_host_system_profile_by_id(['id of the guests from above result'])
{'count': 1,
 'page': 1,
 'per_page': 50,
 'results': [{'id': '01d43448-adba-413a-842f-5f7407b6961b',
              'system_profile': {'ansible': None,
                                 'arch': 'x86_64',
                                 'basearch': None,
<snip>
                                 'virtual_host_uuid': 'd54b8b39-a433-46f4-8810-d96c1b437d2d',
                                 'yum_repos': None}}],
 'total': 1}
  • Sync tally and check if the hypervisor is correctly tallied and present in system_table along with guests
app.rhsm_subscriptions.rest_client.instances_api.get_instances_by_product("RHEL for x86",uom="Sockets",category="hypervisor")
2024-02-16 12:26:09.970 [    INFO] [root] REST: http://swatch-api-service.ephemeral-9hddxl.svc:8000/api/rhsm-subscriptions/v1/instances/products/RHEL%20for%20x86
2024-02-16 12:26:10.211 [    INFO] [iqe.base.rest_client] REST: METHOD=GET, request_id=None, params=[('uom', 'Sockets'), ('category', 'hypervisor')]
Out[12]: 
{'data': [{'category': 'hypervisor',
          'display_name': 'hyper_ifxyorum.example.edu',
          'id': '8a0951f6-df69-4c9a-afbe-a4b947332934',
          'instance_id': '869a18ad-1858-46bc-935d-3099087fd83e',
          'last_seen': datetime.datetime(2024, 2, 16, 12, 6, 36, 788247, tzinfo=tzlocal()),
          'measurements': [2.0],
          'number_of_guests': 2,
          'subscription_manager_id': 'd54b8b39-a433-46f4-8810-d96c1b437d2d'}],
'meta': {'count': 1, 'measurements': ['Sockets'], 'product': 'RHEL for x86'}}

@san7ket
Copy link
Contributor

san7ket commented Feb 16, 2024

Raised a fix for test failure, will merge after this PR is merged.

@Sgitario
Copy link
Contributor Author

Raised a fix for test failure, will merge after this PR is merged.

Okis, merging then!

@san7ket
Copy link
Contributor

san7ket commented Feb 16, 2024

@Sgitario Can we keep this open for while, we are trying to see if we can succesfully make the CI here green

@san7ket
Copy link
Contributor

san7ket commented Feb 16, 2024

/retest

@Sgitario
Copy link
Contributor Author

@Sgitario Can we keep this open for while, we are trying to see if we can succesfully make the CI here green

+1 let me know when I can merge it, or feel free to merge it yourself.

@san7ket
Copy link
Contributor

san7ket commented Feb 16, 2024

/retest

2 similar comments
@san7ket
Copy link
Contributor

san7ket commented Feb 16, 2024

/retest

@san7ket
Copy link
Contributor

san7ket commented Feb 19, 2024

/retest

@san7ket
Copy link
Contributor

san7ket commented Feb 19, 2024

@Sgitario We can merge this

@Sgitario Sgitario merged commit 9f0bac6 into main Feb 19, 2024
9 checks passed
@Sgitario Sgitario deleted the jcarvaja/SWATCH-1929 branch February 19, 2024 10:47
@Sgitario
Copy link
Contributor Author

@san7ket , thanks! Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QE Pull request should be approved by QE before merge
Projects
None yet
4 participants