Skip to content

Conversation

@TheRealJon
Copy link
Member

This commit refactors the OLM catalog client and service architecture to better
separate concerns and add support for the catalogd metas endpoint:

  • Refactor CatalogdClient to return HTTP responses instead of pre-processed data
  • Move catalog processing logic (packages/bundles) from client to service layer
  • Add FetchMetas method to support catalogd /api/v1/metas endpoint
  • Add new handler endpoint at /api/olm/catalogd/metas/{catalogName}
  • Improve cache key structure with separate keys for items, last-modified, and baseURL
  • Remove catalog_client_test.go (logic moved to catalog_service_test.go)
  • Update mock client in tests to work with new HTTP response-based interface

This separation allows the client to focus on HTTP operations while the service
handles business logic and caching.

@TheRealJon
Copy link
Member Author

QE Approver
/assign @yapei

Docs Approver:
/assign @jseseCCS

PX Approver:
/assign @sferich888

@openshift-ci-robot
Copy link
Contributor

openshift-ci-robot commented Oct 29, 2025

@TheRealJon: This pull request references CONSOLE-4733 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

Details

In response to this:

This commit refactors the OLM catalog client and service architecture to better
separate concerns and add support for the catalogd metas endpoint:

  • Refactor CatalogdClient to return HTTP responses instead of pre-processed data
  • Move catalog processing logic (packages/bundles) from client to service layer
  • Add FetchMetas method to support catalogd /api/v1/metas endpoint
  • Add new handler endpoint at /api/olm/catalogd/metas/{catalogName}
  • Improve cache key structure with separate keys for items, last-modified, and baseURL
  • Remove catalog_client_test.go (logic moved to catalog_service_test.go)
  • Update mock client in tests to work with new HTTP response-based interface

This separation allows the client to focus on HTTP operations while the service
handles business logic and caching.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 29, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 29, 2025

@TheRealJon: GitHub didn't allow me to assign the following users: jseseCCS.

Note that only openshift members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

Details

In response to this:

QE Approver
/assign @yapei

Docs Approver:
/assign @jseseCCS

PX Approver:
/assign @sferich888

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@TheRealJon
Copy link
Member Author

/hold

depends on #15376

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 29, 2025
@openshift-ci openshift-ci bot added component/backend Related to backend component/olm Related to OLM approved Indicates a PR has been approved by an approver from all required OWNERS files. component/shared Related to console-shared labels Oct 29, 2025
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 1, 2025
TheRealJon and others added 2 commits November 3, 2025 14:01
Refactor the catalogd client to be a thin HTTP wrapper that returns raw
responses, moving all data processing logic to the catalog service layer.
This improves separation of concerns and enables better caching control.

Key changes:
- Rename Fetch to FetchAll, returning *http.Response instead of processed data
- Add buildCatalogdURL helper for consistent URL construction
- Move bundle/package processing from client to service layer
- Add processCatalog, processPackage, processBundle methods to service
- Update cache key structure with helper functions for better organization
- Change If-Modified-Since handling to use strings instead of *time.Time
- Update all tests to verify HTTP behavior instead of data processing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add support for the catalogd metas endpoint, enabling filtered queries
of catalog metadata. This builds on the refactored client architecture
to provide a new HTTP passthrough endpoint.

Key changes:
- Add CatalogdMetasEndpoint constant (/api/v1/metas)
- Add FetchMetas method to catalogd client for metas endpoint
- Add GetMetas method to catalog service for retrieving metas
- Add catalogdMetasHandler HTTP handler with /api/olm/catalogd/metas/{catalogName} route
- Preserve HTTP request method and query parameters in metas requests
- Add comprehensive tests for new metas functionality

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 4, 2025
@yapei
Copy link
Contributor

yapei commented Nov 5, 2025

curl http://localhost:9000/api/olm/catalogd/metas/openshift-redhat-marketplace we can see request is being proxied to https://<catalogd-route>/catalogs/openshift-redhat-marketplace/api/v1/metas

I1105 16:36:39.394961    4233 catalog_client.go:58] GET https://catalogd-route-openshift-catalogd.apps.ci-ln-2s20hl2-76ef8.aws-2.ci.openshift.org/catalogs/openshift-redhat-marketplace/api/v1/metas
I1105 16:36:46.587013    4233 catalog_client.go:58] HEAD https://catalogd-route-openshift-catalogd.apps.ci-ln-2s20hl2-76ef8.aws-2.ci.openshift.org/catalogs/openshift-redhat-marketplace/api/v1/metas
I1105 16:36:50.542554    4233 catalog_client.go:58] HEAD https://catalogd-route-openshift-catalogd.apps.ci-ln-2s20hl2-76ef8.aws-2.ci.openshift.org/catalogs/openshift-redhat-marketplace/api/v1/metas

Also the added & updated tests pass in CI

/verified by @yapei

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Nov 5, 2025
@openshift-ci-robot
Copy link
Contributor

@yapei: This PR has been marked as verified by @yapei.

Details

In response to this:

curl http://localhost:9000/api/olm/catalogd/metas/openshift-redhat-marketplace we can see request is being proxied to https://<catalogd-route>/catalogs/openshift-redhat-marketplace/api/v1/metas

I1105 16:36:39.394961    4233 catalog_client.go:58] GET https://catalogd-route-openshift-catalogd.apps.ci-ln-2s20hl2-76ef8.aws-2.ci.openshift.org/catalogs/openshift-redhat-marketplace/api/v1/metas
I1105 16:36:46.587013    4233 catalog_client.go:58] HEAD https://catalogd-route-openshift-catalogd.apps.ci-ln-2s20hl2-76ef8.aws-2.ci.openshift.org/catalogs/openshift-redhat-marketplace/api/v1/metas
I1105 16:36:50.542554    4233 catalog_client.go:58] HEAD https://catalogd-route-openshift-catalogd.apps.ci-ln-2s20hl2-76ef8.aws-2.ci.openshift.org/catalogs/openshift-redhat-marketplace/api/v1/metas

Also the added & updated tests pass in CI

/verified by @yapei

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@TheRealJon
Copy link
Member Author

/unhold

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 5, 2025
Copy link
Member

@jhadvig jhadvig left a comment

Choose a reason for hiding this comment

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

Adding couple of small comments. Otherwise looks good 👍
Thank you @TheRealJon 🤘

return nil, nil, nil, err
query := r.URL.Query()
queryParams := ""
if len(queryParams) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

queryParams are always 0. We probably want query, so we can just omit the if statement

Suggested change
if len(queryParams) > 0 {
query := r.URL.Query()
queryParams := query.Encode()


func getKey(catalog string) string {
return keyPrefix + catalog
func getCatlogLastModifiedKey(catalog string) string {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func getCatlogLastModifiedKey(catalog string) string {
func getCatalogLastModifiedKey(catalog string) string {

s.cache.Delete(key)
delete(s.index, key)
delete(s.catalogLastModified, catalogName)
itemsKey := getCatalogItemsKey(catalogName)
Copy link
Member

Choose a reason for hiding this comment

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

Love this implementation ❤️

o.mux.ServeHTTP(w, r)
}

func (o *OLMHandler) catalogdMetasHandler(w http.ResponseWriter, r *http.Request) {
Copy link
Member

Choose a reason for hiding this comment

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

lets add method validation

    if r.Method != http.MethodGet && r.Method != http.MethodPost {
        w.Header().Set("Allow", "GET")
        serverutils.SendResponse(w, http.StatusMethodNotAllowed, 
            serverutils.ApiError{Err: "Only GET method are supported"})
        return
    }
    ...

Extract middleware from pkg/server/middleware.go into pkg/middleware/
package to improve separation of concerns and align with standard Go
project organization. This refactoring breaks down the monolithic server
package by moving HTTP middleware into a focused, reusable library.

Changes:
- Move middleware from pkg/server to pkg/middleware package
- Update all middleware references in server.go and handler.go
- Export middleware functions (AuthMiddleware, WithBearerTokenReview, etc.)
- Add HTTP method restriction to catalogd metas endpoint
- Fix typo: getCatlogLastModifiedKey → getCatalogLastModifiedKey
- Simplify query parameter encoding in catalog client

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Nov 6, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 7, 2025

@TheRealJon: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-e2e-aws-ovn 57897b2 link false /test okd-scos-e2e-aws-ovn

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Copy link
Member

@jhadvig jhadvig left a comment

Choose a reason for hiding this comment

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

Thanks @TheRealJon 👍

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 7, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 7, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhadvig, TheRealJon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sferich888
Copy link

/label px-approved

@openshift-ci openshift-ci bot added the px-approved Signifies that Product Support has signed off on this PR label Nov 7, 2025
@jseseCCS
Copy link

jseseCCS commented Nov 7, 2025

/label docs-approved

@openshift-ci openshift-ci bot added the docs-approved Signifies that Docs has signed off on this PR label Nov 7, 2025
@yapei
Copy link
Contributor

yapei commented Nov 10, 2025

confirmed the latest code still works, adding back labels
/verified by @yapei

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Nov 10, 2025
@openshift-ci-robot
Copy link
Contributor

@yapei: This PR has been marked as verified by @yapei.

Details

In response to this:

confirmed the latest code still works, adding back labels
/verified by @yapei

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-bot openshift-merge-bot bot merged commit 99306f8 into openshift:main Nov 10, 2025
7 of 8 checks passed
@TheRealJon TheRealJon deleted the CONSOLE-4733 branch November 12, 2025 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/backend Related to backend component/olm Related to OLM component/shared Related to console-shared docs-approved Signifies that Docs has signed off on this PR jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. px-approved Signifies that Product Support has signed off on this PR verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants