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

Fixes #38072 - add host bootc_images endpoint #11257

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ianballou
Copy link
Member

What are the changes introduced in this pull request?

Adds a new /hosts/bootc_images endpoint that returns an overview of all bootc images that hosts are using.

The return data looks like the following:

{
  "total": 499,
  "bootc_images": [
    [
      "quay.io/centos-bootc/centos-bootc:stream10",
      [
        {
          "bootc_booted_digest": "sha256:54256a998f0c62e16f3927c82b570f90bd8449a52e03daabd5fd16d6419fd572",
          "host_count": 1
        }
      ]
    ]
  ]
}

This data will power a page that shows a list of image paths and each image mode host that is using that image path. Since each host could use the same image but a different digest, each image path holds any number of digests with the count of hosts that are using that digest. More digests per image path means more drift from the latest container content under that container tag.

Considerations taken when implementing this change?

Choosing where this goes was difficult -- it's related to hosts so I decided to stick it under the hosts endpoint. I use facts as a similar paradigm: host facts and bootc images are both aggregate information from hosts that are available at a single API endpoint.

What are the testing steps for this pull request?

  1. Make a bunch of different bootc hosts. You can use the following script to create one clone:
#!/bin/bash

uuid=$(uuidgen)
short=$(hostname -s)
domain=manicotto.example.com
echo "{\"dmi.system.uuid\": \"${uuid}\"}" > /etc/rhsm/facts/uuid.facts
hostnamectl set-hostname ${short}.${uuid%%-*}.${domain}
subscription-manager clean
subscription-manager register --activationkey "Default Library Key" --org "Default_Organization"
  1. Query the endpoint, test with and without paging
curl "https://`hostname`/api/hosts/bootc_images?per_page=5&page=7" -uadmin:pass
  1. Ensure that empty conditions work, check page sizes that don't make sense, etc.

@ianballou
Copy link
Member Author

Rubocop errors are unrelated & on master.

@ianballou ianballou force-pushed the 38072-bootc-overview-api branch from dd43f60 to 7bbefa8 Compare December 16, 2024 16:21
@sjha4
Copy link
Member

sjha4 commented Dec 16, 2024

Does it make sense to add filtering params to this API endpoint? Like filter for hosts or digest etc?

@ianballou
Copy link
Member Author

ianballou commented Dec 16, 2024

Does it make sense to add filtering params to this API endpoint? Like filter for hosts or digest etc?

I think it makes sense, it would enable there to be a search bar in the UI.

Question is, which params should we support? Perhaps:

  • Host name
  • Container image path
  • Container image digest

@ianballou
Copy link
Member Author

I'm thinking I might need to make some changes to how the returned data is structured to better suit UI development. Seems like more keys might be expected. I'd also like to follow the general standard we have where results is the top-level key.

"name" before the image path might be one key I should add.

@ianballou
Copy link
Member Author

I've added full support for scoped_search searching via the Host::Managed model. My only regret is that I have to load up the host IDs first and then create the content facets query, but I don't see a good way yet to combine the two queries into one.
The performance with 6579 hosts still seems fine.

@ianballou ianballou force-pushed the 38072-bootc-overview-api branch from 29a8e15 to 723f2e8 Compare December 17, 2024 22:11
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.

2 participants