Skip to content

Conversation

@alexliu541
Copy link
Contributor

Description

For backend, only errors happened during IR construction is reported to CRD, and any error happened during translation time are not and user won't see these errors in CRD status. A complete rework on the plugin status reporting is not ideal right now since backend CRD change is in discussion for agentgateway integration, so this PR attempts to alleviate such problem by move most processing logic into construction time from translation time and report errors there.

With this change, the only errors left for backend translation time are the ones that should never happen, such as casting backend obj, MutateHttpOptions, translation plugin not found, etc..

Change Type

/kind fix

Changelog

None

@github-actions github-actions bot added kind/fix Categorizes issue or PR as related to a bug. release-note-none labels Oct 31, 2025
Signed-off-by: Alexander Liu <[email protected]>
Copy link
Contributor

@shashankram shashankram left a comment

Choose a reason for hiding this comment

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

Looks reasonable. Do we have existing translator tests (internal/kgateway/translator/gateway/gateway_translator_test.go) for all the Backends to ensure we aren't introducing regressions?

Comment on lines 79 to 84
if c == nil && other == nil {
return true
}
if c == nil || other == nil {
return false
}
Copy link
Contributor

Choose a reason for hiding this comment

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

You can reduce the nil checks here and below to:

if a == nil || b == nil {
  return a == nil && b == nil
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

tt.pCtx = pCtx
aiIR := &IR{}
err := PreprocessAIBackend(context.Background(), tt.aiBackend, aiIR)
err := PreprocessAIBackend(context.Background(), tt.aiBackend, nil, nil, aiIR)
Copy link
Contributor

Choose a reason for hiding this comment

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

we probably should extend this test to pass secret and multiSecret, but can be a follow-up

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lets take it as a followup

@alexliu541
Copy link
Contributor Author

Looks reasonable. Do we have existing translator tests (internal/kgateway/translator/gateway/gateway_translator_test.go) for all the Backends to ensure we aren't introducing regressions?

We have translator test for all backends except AI backend. For AI backend there is plugin test and setup test. Given that AI backend will soon be moved completely to agentgateway, this should be enough.

Signed-off-by: Alexander Liu <[email protected]>
Copy link
Contributor

@shashankram shashankram left a comment

Choose a reason for hiding this comment

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

Could you add a test for an AI backend with invalid secretRef to ensure it generates a Status error on the object?

Signed-off-by: Alexander Liu <[email protected]>
@shashankram shashankram added this pull request to the merge queue Nov 4, 2025
Merged via the queue into kgateway-dev:main with commit 1edac8c Nov 4, 2025
26 checks passed
@alexliu541 alexliu541 deleted the alexliu541/backend branch November 4, 2025 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/fix Categorizes issue or PR as related to a bug. release-note-none

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants