Skip to content

Conversation

@qcjames53
Copy link
Contributor

@qcjames53 qcjames53 commented Nov 26, 2025

What are the changes introduced in this pull request?

On the /api/v2/hosts/:id/packages endpoint, 'persistence' is now a scoped_search field, meaning we can use --search and --order in hammer on persistence info. This is particularly important for users who would just like to see their transient host installed packages on a bootc environment.

Considerations taken when implementing this change?

What are the testing steps for this pull request?

  1. Pull this PR and this hammer-cli-katello PR for your hammer environment.
  2. Verify hammer host package list --host-id <id> --order 'persistence ASC' works.
  3. Verify hammer host package list --host-id <id> --search 'persistence = transient' works.

Summary by Sourcery

New Features:

  • Expose the package persistence attribute as a scoped search field on the host packages endpoint to support search and ordering from clients like hammer.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

scoped_search :on => :release
scoped_search :on => :arch
scoped_search :on => :vendor, :complete_value => true
scoped_search :relation => :host_installed_packages, :on => :persistence, :complete_value => true
Copy link
Member

Choose a reason for hiding this comment

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

Based on the scoped_search docs I'd recommend using :complete_value => { true => true, false => false }. I'm pretty sure we do that in a few other places in Katello. Also consider only_explicit: true since this won't commonly be searched without the field name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How does the new code look? I ended up pulling the complete_value constants from the persistence model itself.

Copy link
Member

@jeremylenz jeremylenz left a comment

Choose a reason for hiding this comment

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

index_by(&:itself), nifty! TIL

LGTM 👍

@qcjames53 qcjames53 merged commit 68796b0 into Katello:master Dec 2, 2025
22 checks passed
@qcjames53 qcjames53 deleted the 38924 branch December 2, 2025 17:12
@ianballou
Copy link
Member

I'm hitting a problem with this:

hammer -d host package list --host-id 1 --search "persistence = transient"

[DEBUG 2025-11-28T03:05:08 API] Headers: {
    :params => {
          "search" => "persistence = transient",
            "page" => 1,
        "per_page" => 1000
    }
}
[DEBUG 2025-11-28T03:05:08 API] Using authenticator: HammerCLIForeman::Api::InteractiveBasicAuth
[DEBUG 2025-11-28T03:05:08 API] Response: {
         "total" => 0,
      "subtotal" => 0,
    "selectable" => 0,
          "page" => nil,
      "per_page" => nil,
         "error" => "'persistence' should be one of 'transient, persistent', but the query was 'transient'",
        "search" => "persistence = transient",
          "sort" => {
           "by" => "name",
        "order" => "asc"
    },
       "results" => []
}

Similarly:

image

@ianballou
Copy link
Member

Sending transient alone in the search I think looks instead at the package name by default.

@qcjames53
Copy link
Contributor Author

I have a fix ready in #11584, sorry about that.

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