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-1650: Set productID for hosts based on system architecture for QPC hosts #2652

Merged
merged 7 commits into from
Oct 17, 2023

Conversation

kflahert
Copy link
Contributor

Jira issue: SWATCH-1650

Description

When receiving reports from Discovery, we don't receive the specific product_id and must use the system architecture field to determine which RHEL variant it is.

Testing

Setup

  1. Insert test data into hbi database:
INSERT INTO public.hosts VALUES ('8d04f27f-387b-46e3-bf24-975d9803f434', '11481777', 'dctsvl041', '2023-10-11 12:57:05.14065+00', '2023-10-11 12:57:05.140654+00', '{"qpc": {"source_types": ["network"], "qpc_server_id": "acd19e2f-f388-4919-8f8a-542993cc34e8", "last_discovered": "2023-04-13T14:27:38.110030", "qpc_server_version": "0.0.0.2e8c7503e5832ccbef3fe877ee2eda4fbf4084ed", "rh_products_installed": ["RHEL"]}, "yupana": {"org_id": "123", "source": "qpc", "account": "11481777", "yupana_host_id": "46fb3601-66b6-4e00-af4c-db57826805ce", "report_slice_id": "0828ae2d-87b3-4830-8051-6bcd0a0528ba", "report_platform_id": "5eea14c0-a5c5-4a09-aeeb-6ba926bc7675"}}', '{"qpc": {"scanner-id": ["acd19e2f-f388-4919-8f8a-542993cc34e8"], "data-collector": ["qpc"], "last-discovered": ["2023-04-13T14:27:38.110030"], "scanner-version": ["0.0.0.2e8c7503e5832ccbef3fe877ee2eda4fbf4084ed"], "scanner-hostname": ["rhel.mzalewsk.csb"], "scanner-ip-address": ["192.168.2.66"]}}', '{"fqdn": "dctsvl041", "bios_uuid": "24093b42-82e0-b164-dded-b9d01afb32d3", "ip_addresses": ["10.92.84.38", "10.92.248.15", "10.92.83.11"], "mac_addresses": ["00:50:56:bb:7d:4d", "00:50:56:bb:cb:16", "00:50:56:bb:7d:2d"], "subscription_manager_id": "c10f7c02-eeb7-4497-bf98-330f7cd12e6d"}', '{"arch": "x86_64", "os_release": "7.7", "number_of_cpus": 4, "cores_per_socket": 1, "operating_system": {"name": "RHEL", "major": 7, "minor": 7}, "number_of_sockets": 4, "infrastructure_type": "virtual", "system_memory_bytes": 8235855872}', '', '2023-10-12 17:57:05.006+00', 'yupana', '{"yupana": {"last_check_in": "2023-10-11T12:57:05.123898+00:00", "stale_timestamp": "2023-10-12T17:57:05.006000+00:00", "check_in_succeeded": true}}', '123', '[]');
INSERT INTO public.hosts VALUES ('bca658f4-9acf-46fe-b127-8206b482b76c', '11481777', 'dcdeal016', '2023-10-11 12:57:05.27185+00', '2023-10-11 12:57:05.271854+00', '{"qpc": {"source_types": ["network"], "qpc_server_id": "acd19e2f-f388-4919-8f8a-542993cc34e8", "last_discovered": "2023-04-13T14:27:38.110030", "qpc_server_version": "0.0.0.2e8c7503e5832ccbef3fe877ee2eda4fbf4084ed", "rh_products_installed": ["RHEL"]}, "yupana": {"org_id": "123", "source": "qpc", "account": "11481777", "yupana_host_id": "7a4dd535-95e0-42dc-9730-f5a0588d5208", "report_slice_id": "0828ae2d-87b3-4830-8051-6bcd0a0528ba", "report_platform_id": "5eea14c0-a5c5-4a09-aeeb-6ba926bc7675"}}', '{"qpc": {"scanner-id": ["acd19e2f-f388-4919-8f8a-542993cc34e8"], "data-collector": ["qpc"], "last-discovered": ["2023-04-13T14:27:38.110030"], "scanner-version": ["0.0.0.2e8c7503e5832ccbef3fe877ee2eda4fbf4084ed"], "scanner-hostname": ["rhel.mzalewsk.csb"], "scanner-ip-address": ["192.168.2.66"]}}', '{"fqdn": "dcdeal016", "bios_uuid": "e7983b42-911d-a24a-a933-aeaff61afb5d", "ip_addresses": ["10.92.84.225"], "mac_addresses": ["00:50:56:bb:ac:4f"], "subscription_manager_id": "3f3fac14-6e5c-4b8e-99d4-6046c5ea6be3"}', '{"arch": "i386", "os_release": "7.9", "number_of_cpus": 2, "cores_per_socket": 1, "operating_system": {"name": "RHEL", "major": 7, "minor": 9}, "number_of_sockets": 2, "infrastructure_type": "virtual", "system_memory_bytes": 16691855360}', '', '2023-10-12 17:57:05.121+00', 'yupana', '{"yupana": {"last_check_in": "2023-10-11T12:57:05.259100+00:00", "stale_timestamp": "2023-10-12T17:57:05.121000+00:00", "check_in_succeeded": true}}', '123', '[]');
INSERT INTO public.hosts VALUES ('edd90d0b-bc2d-40ec-bea5-163bbf649f42', '11481777', 'dcdeal019', '2023-10-11 12:57:05.379894+00', '2023-10-11 12:57:05.379898+00', '{"qpc": {"source_types": ["network"], "qpc_server_id": "acd19e2f-f388-4919-8f8a-542993cc34e8", "last_discovered": "2023-04-13T14:27:38.110030", "qpc_server_version": "0.0.0.2e8c7503e5832ccbef3fe877ee2eda4fbf4084ed", "rh_products_installed": ["RHEL"]}, "yupana": {"org_id": "123", "source": "qpc", "account": "11481777", "yupana_host_id": "070e540c-9b96-40ab-b99b-880a230abb49", "report_slice_id": "0828ae2d-87b3-4830-8051-6bcd0a0528ba", "report_platform_id": "5eea14c0-a5c5-4a09-aeeb-6ba926bc7675"}}', '{"qpc": {"scanner-id": ["acd19e2f-f388-4919-8f8a-542993cc34e8"], "data-collector": ["qpc"], "last-discovered": ["2023-04-13T14:27:38.110030"], "scanner-version": ["0.0.0.2e8c7503e5832ccbef3fe877ee2eda4fbf4084ed"], "scanner-hostname": ["rhel.mzalewsk.csb"], "scanner-ip-address": ["192.168.2.66"]}}', '{"fqdn": "dcdeal019", "bios_uuid": "66c93b42-6a8b-e13f-8f45-45b7d64f0cf2", "ip_addresses": ["10.92.84.227"], "mac_addresses": ["00:50:56:bb:3b:35"], "subscription_manager_id": "7df3ebb5-8d76-4412-bcf7-a96bbbb96908"}', '{"arch": "i686", "os_release": "7.9", "number_of_cpus": 2, "cores_per_socket": 1, "operating_system": {"name": "RHEL", "major": 7, "minor": 9}, "number_of_sockets": 2, "infrastructure_type": "virtual", "system_memory_bytes": 8236068864}', '', '2023-10-12 17:57:05.257+00', 'yupana', '{"yupana": {"last_check_in": "2023-10-11T12:57:05.369622+00:00", "stale_timestamp": "2023-10-12T17:57:05.257000+00:00", "check_in_succeeded": true}}', '123', '[]');
INSERT INTO public.hosts VALUES ('9221258a-06c5-4dde-ac72-f0c5b1d5b3e9', '11481777', 'dcdevl064', '2023-10-11 12:57:05.636241+00', '2023-10-11 12:57:05.636245+00', '{"qpc": {"source_types": ["network"], "qpc_server_id": "acd19e2f-f388-4919-8f8a-542993cc34e8", "last_discovered": "2023-04-13T14:27:38.110030", "qpc_server_version": "0.0.0.2e8c7503e5832ccbef3fe877ee2eda4fbf4084ed", "rh_products_installed": ["RHEL"]}, "yupana": {"org_id": "123", "source": "qpc", "account": "11481777", "yupana_host_id": "93d945d4-7592-4bc3-80e6-d3ca76089020", "report_slice_id": "0828ae2d-87b3-4830-8051-6bcd0a0528ba", "report_platform_id": "5eea14c0-a5c5-4a09-aeeb-6ba926bc7675"}}', '{"qpc": {"scanner-id": ["acd19e2f-f388-4919-8f8a-542993cc34e8"], "data-collector": ["qpc"], "last-discovered": ["2023-04-13T14:27:38.110030"], "scanner-version": ["0.0.0.2e8c7503e5832ccbef3fe877ee2eda4fbf4084ed"], "scanner-hostname": ["rhel.mzalewsk.csb"], "scanner-ip-address": ["192.168.2.66"]}}', '{"fqdn": "dcdevl064", "bios_uuid": "abdc3b42-091d-c73a-d089-098ab8214f8c", "ip_addresses": ["192.168.122.1", "10.92.84.80"], "mac_addresses": ["00:50:56:bb:db:60", "52:54:00:06:b0:0f"], "subscription_manager_id": "aa972268-e55d-492c-b78d-78b70cc0f7d6"}', '{"arch": "aarch64", "os_release": "8.6", "number_of_cpus": 4, "cores_per_socket": 1, "operating_system": {"name": "RHEL", "major": 8, "minor": 6}, "number_of_sockets": 4, "infrastructure_type": "virtual", "system_memory_bytes": 8140435456}', '', '2023-10-12 17:57:05.509+00', 'yupana', '{"yupana": {"last_check_in": "2023-10-11T12:57:05.625408+00:00", "stale_timestamp": "2023-10-12T17:57:05.509000+00:00", "check_in_succeeded": true}}', '123', '[]');
INSERT INTO public.hosts VALUES ('279bda46-d3fa-4afb-8867-8c5da072b517', '11481777', 'dctsvl149.group.local', '2023-10-11 12:57:05.78085+00', '2023-10-11 12:57:05.780873+00', '{"qpc": {"source_types": ["network"], "qpc_server_id": "acd19e2f-f388-4919-8f8a-542993cc34e8", "last_discovered": "2023-04-13T14:27:38.110030", "qpc_server_version": "0.0.0.2e8c7503e5832ccbef3fe877ee2eda4fbf4084ed", "rh_products_installed": ["RHEL"]}, "yupana": {"org_id": "123", "source": "qpc", "account": "11481777", "yupana_host_id": "7815b27a-0c8f-4020-8f04-c288cca17a4b", "report_slice_id": "0828ae2d-87b3-4830-8051-6bcd0a0528ba", "report_platform_id": "5eea14c0-a5c5-4a09-aeeb-6ba926bc7675"}}', '{"qpc": {"scanner-id": ["acd19e2f-f388-4919-8f8a-542993cc34e8"], "data-collector": ["qpc"], "last-discovered": ["2023-04-13T14:27:38.110030"], "scanner-version": ["0.0.0.2e8c7503e5832ccbef3fe877ee2eda4fbf4084ed"], "scanner-hostname": ["rhel.mzalewsk.csb"], "scanner-ip-address": ["192.168.2.66"]}}', '{"fqdn": "dctsvl149.group.local", "bios_uuid": "86443b42-1b58-06af-6124-a64186f28e0e", "ip_addresses": ["10.98.80.39", "192.168.122.1"], "mac_addresses": ["00:50:56:bb:56:4e", "52:54:00:06:b0:0f"], "subscription_manager_id": "8047b762-aeb5-4e95-804a-71a6b5749665"}', '{"arch": "ppc64le", "os_release": "8.6", "number_of_cpus": 2, "cores_per_socket": 1, "operating_system": {"name": "RHEL", "major": 8, "minor": 6}, "number_of_sockets": 2, "infrastructure_type": "virtual", "system_memory_bytes": 8140894208}', '', '2023-10-12 17:57:05.623+00', 'yupana', '{"yupana": {"last_check_in": "2023-10-11T12:57:05.751512+00:00", "stale_timestamp": "2023-10-12T17:57:05.623000+00:00", "check_in_succeeded": true}}', '123', '[]');

Steps

  1. Start app with: DEV_MODE=true SPRING_PROFILES_ACTIVE=kakfa-queue,worker,api ./gradlew :bootRun
  2. Run tally: http PUT ":8000/api/rhsm-subscriptions/v1/internal/rpc/tally/snapshots/123" x-rh-swatch-psk:placeholder
  3. Opt in org:
curl -X 'PUT' \
  'http://localhost:8000/api/rhsm-subscriptions/v1/opt-in' \
  -H 'accept: application/vnd.api+json' \
  -H 'x-rh-identity: ewogICAgImlkZW50aXR5IjogewogICAgICAgICJ0eXBlIjogIlVzZXIiLAogICAgICAgICJ1c2VyIiA6IHsKICAgICAgICAgICAgImlzX29yZ19hZG1pbiI6IHRydWUKICAgICAgICB9LAogICAgICAgICJpbnRlcm5hbCIgOiB7CiAgICAgICAgICAgICJvcmdfaWQiOiAiMTIzIgogICAgICAgIH0KICAgIH0KfQ=='

Verification

  1. Run the following commands and should get values for each different variant.
curl -X 'GET' \
  'http://localhost:8000/api/rhsm-subscriptions/v1/tally/products/RHEL%20for%20x86/Cores?granularity=Daily&beginning=2023-10-16T00%3A00%3A00Z&ending=2023-10-16T23%3A59%3A59Z&use_running_totals_format=false' \
  -H 'accept: application/vnd.api+json' \
  -H 'x-rh-identity: ewogICAgImlkZW50aXR5IjogewogICAgICAgICJ0eXBlIjogIlVzZXIiLAogICAgICAgICJ1c2VyIiA6IHsKICAgICAgICAgICAgImlzX29yZ19hZG1pbiI6IHRydWUKICAgICAgICB9LAogICAgICAgICJpbnRlcm5hbCIgOiB7CiAgICAgICAgICAgICJvcmdfaWQiOiAiMTIzIgogICAgICAgIH0KICAgIH0KfQ=='


  curl -X 'GET' \
  'http://localhost:8000/api/rhsm-subscriptions/v1/tally/products/RHEL%20for%20ARM/Cores?granularity=Daily&beginning=2023-10-16T00%3A00%3A00Z&ending=2023-10-16T23%3A59%3A59Z&use_running_totals_format=false' \
  -H 'accept: application/vnd.api+json' \
  -H 'x-rh-identity: ewogICAgImlkZW50aXR5IjogewogICAgICAgICJ0eXBlIjogIlVzZXIiLAogICAgICAgICJ1c2VyIiA6IHsKICAgICAgICAgICAgImlzX29yZ19hZG1pbiI6IHRydWUKICAgICAgICB9LAogICAgICAgICJpbnRlcm5hbCIgOiB7CiAgICAgICAgICAgICJvcmdfaWQiOiAiMTIzIgogICAgICAgIH0KICAgIH0KfQ=='

  curl -X 'GET' \
  'http://localhost:8000/api/rhsm-subscriptions/v1/tally/products/RHEL%20for%20IBM%20Power/Cores?granularity=Daily&beginning=2023-10-16T00%3A00%3A00Z&ending=2023-10-16T23%3A59%3A59Z&use_running_totals_format=false' \
  -H 'accept: application/vnd.api+json' \
  -H 'x-rh-identity: ewogICAgImlkZW50aXR5IjogewogICAgICAgICJ0eXBlIjogIlVzZXIiLAogICAgICAgICJ1c2VyIiA6IHsKICAgICAgICAgICAgImlzX29yZ19hZG1pbiI6IHRydWUKICAgICAgICB9LAogICAgICAgICJpbnRlcm5hbCIgOiB7CiAgICAgICAgICAgICJvcmdfaWQiOiAiMTIzIgogICAgICAgIH0KICAgIH0KfQ=='

@mirekdlugosz
Copy link
Contributor

Looks reasonable 👍

@Sgitario Sgitario force-pushed the kflahert/swatch-1650-qpc-hosts-bug branch from f4ae1d9 to f4bb9c8 Compare October 17, 2023 10:00
Copy link
Contributor

@Sgitario Sgitario left a comment

Choose a reason for hiding this comment

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

This pull request is in conflict with the changes that were merged in #2604, so some changes are required (see my inline comments).

if (hostFacts.getSystemProfileArch() != null
&& CollectionUtils.isEmpty(hostFacts.getSystemProfileProductIds())) {
switch (hostFacts.getSystemProfileArch()) {
case "x86_64", "i686", "i386":
Copy link
Contributor

@Sgitario Sgitario Oct 17, 2023

Choose a reason for hiding this comment

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

One question about these values, is there any documentation or link where to get more information about it? If so, I think it would be really helpful to add a comment here including a reference or link.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I'm not aware of any, @mirekdlugosz do you happen to know of any docs around the system arch we could link to for this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't really know, maybe HBI OpenAPI spec file? Or yuptoo.

As I'm on PTO this week, I'm not on position to look for links, sorry. I think it's best to merge as it is and we can add a link in another PR, if we find it.

Copy link
Contributor

@Sgitario Sgitario left a comment

Choose a reason for hiding this comment

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

LGTM.
If we could find a link where to get more information about the values, it would be perfect. However, I don't think this should be a stopper for this pull request being merged.

@kflahert kflahert merged commit 4a64833 into main Oct 17, 2023
6 checks passed
@kflahert kflahert deleted the kflahert/swatch-1650-qpc-hosts-bug branch October 17, 2023 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants