Skip to content

feat(controlplane-api): model spectre listeners - #665

Draft
miju04 wants to merge 7 commits into
mainfrom
feat/model-listeners
Draft

miju04 wants to merge 7 commits into
mainfrom
feat/model-listeners

Conversation

@miju04

@miju04 miju04 commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@miju04
miju04 requested a review from ron96g September 21, 2026 07:07
@stefan-ctrl
stefan-ctrl self-requested a review September 21, 2026 08:04

@stefan-ctrl stefan-ctrl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As a draft review was requested, I've added few comments.

Generally, it looks good, and the projector seems to be used as intended.

I have a few questions regarding the business requirements, as ListenerApplication is not part of the initial projection. Is this by design or as it is still WIP, will be added at a later time?

Comment on lines +66 to +79
case *entgen.ListenerQuery:
q.Where(listener.Or(
listener.HasSubscriptionWith(
apisubscription.HasOwnerWith(
application.HasOwnerTeamWith(team.NameIn(teams...)),
),
),
listener.HasExposureWith(
apiexposure.HasOwnerWith(
application.HasOwnerTeamWith(team.NameIn(teams...)),
),
),
))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Question:
What about filtering for ListenerApplications?
Spectre, as I understand it, is a 3-party application: Listener, Provider, Consumer.
The current filter only considers the consumer through subscription and the provider through exposure.

Should the listener application’s owner team also be allowed to view the listener?
Depending on the MC view, this might be needed.

@miju04 miju04 Sep 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ahh, I think i misunderstood this. I thought the Listener is always the Consumer. But thinking about this it makes more sense, that the Listener is from a third independent application, which requests access to the route between a Provider and Consumer.

Adding the ListenerApplication should then make this possible

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I just added the separate application to the listener.

})
})

Context("when viewer is unrelated to the Listener", func() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the context covert when the viewer is the application owner of the ListenerApplication (i.e. SpectreApplication)? Should they be able to view the state of the approvals?

type SpectreApplicationSpec struct {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added a testcase where the viewer only owns the listener application and sees the state of the approval and approval requests.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice to add an additional schema test file to keep the test file clean and not cluttered 👍

@miju04
miju04 force-pushed the feat/model-listeners branch from 6eae82e to 9ae9011 Compare September 23, 2026 13:32
@miju04

miju04 commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

As a draft review was requested, I've added few comments.

Generally, it looks good, and the projector seems to be used as intended.

I have a few questions regarding the business requirements, as ListenerApplication is not part of the initial projection. Is this by design or as it is still WIP, will be added at a later time?

And currently i only implement the controlplane-api after this is done i'll implement the projector change, which populates it.

@stefan-ctrl stefan-ctrl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

First round of review. Will continue after some meetings.

api.Module,
apiexposure.Module,
apisubscription.Module,
approval.Module,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For what purpose have the approval modules been removed?

if data.ApprovalKey != "provider" && data.ApprovalKey != "consumer" {
return 0, fmt.Errorf("invalid Listener approvalKey %q", data.ApprovalKey)
}
if data.Action != "listen-"+data.ApprovalKey {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor:
"linsten-" should be a const with a comment above it, explaining why this is needed and the convention behind it.

func (r *Repository) resolveSubscriptionID(ctx context.Context, data *ApprovalRequestData) (int, error) {
switch data.TargetKind {
case TargetKindListener:
if data.ApprovalKey != "provider" && data.ApprovalKey != "consumer" {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor:
Personal preference: Would like to see const values with some comments (1-liner), explaining our convention.

Also, perhaps both if checks could be combined. (this, and the following).

func (r *Repository) resolveSubscriptionID(ctx context.Context, data *ApprovalData) (int, error) {
switch data.TargetKind {
case TargetKindListener:
if data.ApprovalKey != "provider" && data.ApprovalKey != "consumer" {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Similar to the other comments in approvalrequest

// spec.target references.
et, lk := cachekeys.APISubscriptionMeta(data.Meta.Namespace, data.Meta.Name)
r.cache.Set(et, lk, subscriptionID)
et, lk = cachekeys.APISubscription(data.BasePath, data.OwnerAppName, data.OwnerTeamName)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is the benefit of caching the keys for APISubscription in addition to the APISubscriptionInfo and why is this needed for the listener addition?

TargetKindAPISubscription = "ApiSubscription"
TargetKindEventSubscription = "EventSubscription"
TargetKindAgenticSubscription = "AgenticSubscription"
TargetKindListener = "Listener"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Minor:
Would the key ListenerSubscription make more sense here, since Listener would need to be approved as well?

BasePath string
RequestFilter *model.ListenerFilter
ResponseFilter *model.ListenerFilter
Observer Key

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of key, a direct reference to the model.* should be preferred to be in line with the other approaches.

See the following snippet as an example:

Requester model.RequesterInfo
Decider model.DeciderInfo

The reference would then be resolved in the translator:

Requester: mapRequester(obj.Spec.Requester),

ApplicationInfo seems to be appropriate.

@xCatalitY
xCatalitY force-pushed the feat/spectre branch 3 times, most recently from 61d58be to 32f9344 Compare October 5, 2026 13:29
@xCatalitY
xCatalitY force-pushed the feat/spectre branch 2 times, most recently from 66f1a9b to fe74c70 Compare October 15, 2026 10:46
@xCatalitY
xCatalitY force-pushed the feat/spectre branch 2 times, most recently from 11dc328 to dffbe0d Compare October 22, 2026 14:37
@xCatalitY
xCatalitY force-pushed the feat/spectre branch 3 times, most recently from ecd7a72 to 245a115 Compare October 29, 2026 08:57
Base automatically changed from feat/spectre to main November 3, 2026 09:31
@miju04
miju04 force-pushed the feat/model-listeners branch from cb31f5d to 281ec72 Compare November 4, 2026 09:17
Associate listeners with their declaring application, separate from the API consumer. Require both provider and consumer approval before marking a listener approved.
Key the Listener parent indexes by the full namespace instead of the team name, so a change in one environment no longer enqueues Listeners of another. Treat a SpectreApplication from a different environment as missing, and document the scoping of the remaining raw-client calls.
@miju04
miju04 force-pushed the feat/model-listeners branch from 281ec72 to 6769d64 Compare November 19, 2026 16:27
Replace the duplicated provider/consumer and listen- action checks in the approval and approval request translators and repositories with one shared helper based on the approval API key constants. Restore the original approval module registration order.

This branch has not been deployed

No deployments
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.

2 participants