Skip to content

Commit ac63753

Browse files
feat: PAAL-123 move probe equality check to equality.go and reduce complexity
1 parent 75df72c commit ac63753

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

internal/controller/agent_controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ func (r *AgentReconciler) getOpenAIProtocol(agent *runtimev1alpha1.Agent) *runti
401401
}
402402

403403
// getProtocolPort returns the port from protocol or default if not specified
404-
func (r *AgentReconciler) getProtocolPort(protocol *runtimev1alpha1.AgentProtocol, defaultPort int32) int32 {
404+
func (r *AgentReconciler) getProtocolPort(protocol *runtimev1alpha1.AgentProtocol) int32 {
405+
defaultPort := int32(8000) // Default port if none specified
405406
if protocol != nil && protocol.Port != 0 {
406407
return protocol.Port
407408
}
@@ -432,15 +433,15 @@ func (r *AgentReconciler) generateReadinessProbe(agent *runtimev1alpha1.Agent) *
432433
// Use A2A agent card endpoint for health check
433434
a2aProtocol := r.getA2AProtocol(agent)
434435
healthPath := r.getA2AHealthPath(a2aProtocol)
435-
port := r.getProtocolPort(a2aProtocol, 8000)
436+
port := r.getProtocolPort(a2aProtocol)
436437

437438
probe := r.buildA2AReadinessProbe(healthPath, port)
438439

439440
return probe
440441
} else if r.hasOpenAIProtocol(agent) {
441442
// Use TCP probe for OpenAI-only agents
442443
openaiProtocol := r.getOpenAIProtocol(agent)
443-
port := r.getProtocolPort(openaiProtocol, 8000)
444+
port := r.getProtocolPort(openaiProtocol)
444445

445446
probe := r.buildOpenAIReadinessProbe(port)
446447

internal/controller/agent_controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,12 @@ var _ = Describe("Agent Controller", func() {
400400

401401
It("should get protocol port with fallback to default", func() {
402402
protocol := &runtimev1alpha1.AgentProtocol{Type: "A2A", Port: 9000}
403-
port := reconciler.getProtocolPort(protocol, 8000)
403+
port := reconciler.getProtocolPort(protocol)
404404
Expect(port).To(Equal(int32(9000)))
405405

406406
// Test with zero port (should use default)
407407
protocolNoPort := &runtimev1alpha1.AgentProtocol{Type: "A2A", Port: 0}
408-
portDefault := reconciler.getProtocolPort(protocolNoPort, 8000)
408+
portDefault := reconciler.getProtocolPort(protocolNoPort)
409409
Expect(portDefault).To(Equal(int32(8000)))
410410

411411
// Test with nil protocol (should use default)

0 commit comments

Comments
 (0)