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

Cast success to boolean in inventory report #925

Merged
merged 1 commit into from
Dec 19, 2024

Conversation

jeremylenz
Copy link
Collaborator

@jeremylenz jeremylenz commented Nov 14, 2024

The success fact (along with other Boolean RHSM facts, apparently) gets converted to a string at some point during Foreman/Katello processing. This caused problems for the Insights folks, so I'm raising this to ensure that it's cast back to a boolean value in the rh_cloud inventory report. This should produce reports that look like this:

{
  "report_slice_id": "c2e1020a-5722-47cb-9573-043291265985",
  "hosts": [
    {
      "fqdn": "rhel9b.fedora.example.com",
      "account": "0000000",
      "subscription_manager_id": "45d3d61a-b76e-404d-98ed-3475a06c7611",
      "satellite_id": "45d3d61a-b76e-404d-98ed-3475a06c7611",
      "conversions": {
        "source_os": {
          "name": "AlmaLinux",
          "version": "Unknown - Fact not reported"
        },
        "target_os": {
          "name": "Red Hat Enterprise Linux",
          "version": "Unknown - Fact not reported"
        },
        "convert2rhel_through_foreman": 1,
        "activity": "conversion",
        "packages_0_nevra": "convert2rhel-0:2.0.0-1.el8.noarch",
        "packages_0_signature": "RSA/SHA256, Thu May 30 13:31:33 2024, Key ID 199e2f91fd431d51",
        "activity_started": "2024-07-11T17:28:54.281664Z",
        "activity_ended": "2024-07-11T17:48:47.026664Z",
        "success": true
      },
...

One other note - For source_os version and target_os version, if for some reason the host does not report that fact, I have a default value as "Unknown - Fact not reported". (I needed to have a key/value pair there rather than omitting it entirely, because of some quirks about rh_cloud JSON which are discussed in #914 but really you probably don't want to know ;) Since that's also a string, I believe it should still comply with the schema outlined in https://github.com/RedHatInsights/inventory-schemas/pull/142/files. Let me know if that's a problem.

@chris1984 chris1984 self-assigned this Nov 21, 2024
Copy link

@bocekm bocekm left a comment

Choose a reason for hiding this comment

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

Thanks, @jeremylenz. Looks good.

bocekm added a commit to bocekm/inventory-schemas that referenced this pull request Dec 13, 2024
@jeremylenz jeremylenz requested a review from chris1984 December 13, 2024 15:17
Copy link
Member

@chris1984 chris1984 left a comment

Choose a reason for hiding this comment

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

ACK, confirmed it's a Boolean in pry and also in the report output:

"hosts": [
    {
      "fqdn": "ip-10-0-167-8.rhos-01.prod.psi.rdu2.redhat.com",
      "account": "5235210",
      "subscription_manager_id": "b13773a2-26f6-4041-8856-249a440f558f",
      "satellite_id": "b13773a2-26f6-4041-8856-249a440f558f",
      "conversions": {
        "source_os": {
          "name": "AlmaLinux",
          "version": "8.10"
        },
        "target_os": {
          "name": "Red Hat Enterprise Linux",
          "version": "8.10"
        },
        "convert2rhel_through_foreman": 1,
        "activity": "conversion",
        "packages_0_nevra": "convert2rhel-0:2.0.0-1.el8.noarch",
        "packages_0_signature": "RSA/SHA256, Thu May 30 13:31:33 2024, Key ID 199e2f91fd431d51",
        "activity_started": "2024-07-11T17:28:54.281664Z",
        "activity_ended": "2024-07-11T17:48:47.026664Z",
        "success": true
      },

@jeremylenz jeremylenz merged commit d642c75 into theforeman:develop Dec 19, 2024
19 checks passed
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.

3 participants