Skip to content

Conversation

@h2zh
Copy link
Contributor

@h2zh h2zh commented Nov 10, 2025

This PR consolidates the BrokerURL getter logics for Origin and Cache in their advertising process, and adds a new fed test for Broker-enabled Cache.

See the commit messages for details.

Not sure if this PR conflicts with the current Broker work you're doing @patrickbrophy

h2zh added 3 commits November 10, 2025 16:38
- The broker is now used by both the Origin and Cache services. This commit moves its metrics to a common location so they can be accessed by both, rather than being coupled to the Origin.
-  Checks Origin.EnableBroker or Cache.EnableBroker and sets the broker URL appropriately
- This mirrors the origin implementation and allows tracking of cache broker connections
@h2zh h2zh added this to the v7.22 milestone Nov 10, 2025
@h2zh h2zh added cache Issue relating to the cache component broker labels Nov 10, 2025
@h2zh h2zh linked an issue Nov 10, 2025 that may be closed by this pull request
@h2zh h2zh added the origin Issue relating to the origin component label Nov 10, 2025
@h2zh h2zh requested a review from patrickbrophy November 10, 2025 18:18
@h2zh h2zh assigned h2zh and patrickbrophy and unassigned h2zh Nov 10, 2025
- The test verifies that:
1. The cache broker metric collector exists
2. The cache broker is properly enabled
3. The broker listener starts up successfully
4. The cache polls the broker endpoint (visible in logs)
5. Broker metrics can be incremented

// SetBrokerURL sets the broker URL in the advertisement for servers that have broker support enabled.
// Returns the broker URL string if successful, or an empty string if not applicable.
func SetBrokerURL(ad *server_structs.OriginAdvertiseV2, serverType server_structs.ServerType, prefixes []string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add tests for this function?

  • Test with multiple prefixes: verify broker URL is not set
  • Test with broker disabled: verify broker URL is not set
  • Test with invalid broker endpoint: verify error is returned

)

// Spin up a federation and verifies that the cache broker infrastructure is properly configured.
func TestBrokerApi(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a strange test. It appears that we are just manually incrementing the counter ourselves and then checking that it has increased? This doesn't really seem to test that the connection was actually made.

@h2zh h2zh assigned h2zh and unassigned patrickbrophy Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

broker cache Issue relating to the cache component origin Issue relating to the origin component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add BrokerURL to the cache ad when broker is enabled

2 participants