Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: Use gwapiv1.BackendObjectReference instread of unstable EG one #113

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/v1alpha1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ type AIServiceBackendSpec struct {
// This is required to be set.
//
// +kubebuilder:validation:Required
BackendRef egv1a1.BackendRef `json:"backendRef"`
BackendRef gwapiv1.BackendObjectReference `json:"backendRef"`

// BackendSecurityPolicyRef is the name of the BackendSecurityPolicy resources this backend
// is being attached to.
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (c *configSink) newHTTPRoute(dst *gwapiv1.HTTPRoute, aiGatewayRoute *aigv1a
key := fmt.Sprintf("%s.%s", b.Name, b.Namespace)
rule := gwapiv1.HTTPRouteRule{
BackendRefs: []gwapiv1.HTTPBackendRef{
{BackendRef: gwapiv1.BackendRef{BackendObjectReference: b.Spec.BackendRef.BackendObjectReference}},
{BackendRef: gwapiv1.BackendRef{BackendObjectReference: b.Spec.BackendRef}},
},
Matches: []gwapiv1.HTTPRouteMatch{
{Headers: []gwapiv1.HTTPHeaderMatch{{Name: selectedBackendHeaderKey, Value: key}}},
Expand All @@ -244,7 +244,7 @@ func (c *configSink) newHTTPRoute(dst *gwapiv1.HTTPRoute, aiGatewayRoute *aigv1a
{Path: &gwapiv1.HTTPPathMatch{Value: ptr.To("/")}},
},
BackendRefs: []gwapiv1.HTTPBackendRef{
{BackendRef: gwapiv1.BackendRef{BackendObjectReference: backends[0].Spec.BackendRef.BackendObjectReference}},
{BackendRef: gwapiv1.BackendRef{BackendObjectReference: backends[0].Spec.BackendRef}},
},
})

Expand Down
33 changes: 9 additions & 24 deletions internal/controller/sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
"testing"

egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1"
"github.com/go-logr/logr"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -42,10 +41,10 @@ func TestConfigSink_syncAIGatewayRoute(t *testing.T) {

for _, backend := range []*aigv1a1.AIServiceBackend{
{ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns1"}, Spec: aigv1a1.AIServiceBackendSpec{
BackendRef: egv1a1.BackendRef{BackendObjectReference: gwapiv1.BackendObjectReference{Name: "some-backend1", Namespace: ptr.To[gwapiv1.Namespace]("ns1")}},
BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend1", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
}},
{ObjectMeta: metav1.ObjectMeta{Name: "orange", Namespace: "ns1"}, Spec: aigv1a1.AIServiceBackendSpec{
BackendRef: egv1a1.BackendRef{BackendObjectReference: gwapiv1.BackendObjectReference{Name: "some-backend2", Namespace: ptr.To[gwapiv1.Namespace]("ns1")}},
BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend2", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
}},
} {
err := fakeClient.Create(context.Background(), backend, &client.CreateOptions{})
Expand Down Expand Up @@ -137,33 +136,25 @@ func Test_newHTTPRoute(t *testing.T) {
{
ObjectMeta: metav1.ObjectMeta{Name: "apple", Namespace: "ns1"},
Spec: aigv1a1.AIServiceBackendSpec{
BackendRef: egv1a1.BackendRef{
BackendObjectReference: gwapiv1.BackendObjectReference{Name: "some-backend1", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
},
BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend1", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
},
},
{
ObjectMeta: metav1.ObjectMeta{Name: "orange", Namespace: "ns1"},
Spec: aigv1a1.AIServiceBackendSpec{
BackendRef: egv1a1.BackendRef{
BackendObjectReference: gwapiv1.BackendObjectReference{Name: "some-backend2", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
},
BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend2", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
},
},
{
ObjectMeta: metav1.ObjectMeta{Name: "pineapple", Namespace: "ns1"},
Spec: aigv1a1.AIServiceBackendSpec{
BackendRef: egv1a1.BackendRef{
BackendObjectReference: gwapiv1.BackendObjectReference{Name: "some-backend3", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
},
BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend3", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
},
},
{
ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "ns1"},
Spec: aigv1a1.AIServiceBackendSpec{
BackendRef: egv1a1.BackendRef{
BackendObjectReference: gwapiv1.BackendObjectReference{Name: "some-backend4", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
},
BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend4", Namespace: ptr.To[gwapiv1.Namespace]("ns1")},
},
},
} {
Expand Down Expand Up @@ -227,25 +218,19 @@ func Test_updateExtProcConfigMap(t *testing.T) {
APISchema: aigv1a1.VersionedAPISchema{
Schema: aigv1a1.APISchemaAWSBedrock,
},
BackendRef: egv1a1.BackendRef{
BackendObjectReference: gwapiv1.BackendObjectReference{Name: "some-backend1", Namespace: ptr.To[gwapiv1.Namespace]("ns")},
},
BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend1", Namespace: ptr.To[gwapiv1.Namespace]("ns")},
},
},
{
ObjectMeta: metav1.ObjectMeta{Name: "cat", Namespace: "ns"},
Spec: aigv1a1.AIServiceBackendSpec{
BackendRef: egv1a1.BackendRef{
BackendObjectReference: gwapiv1.BackendObjectReference{Name: "some-backend2", Namespace: ptr.To[gwapiv1.Namespace]("ns")},
},
BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend2", Namespace: ptr.To[gwapiv1.Namespace]("ns")},
},
},
{
ObjectMeta: metav1.ObjectMeta{Name: "pineapple", Namespace: "ns"},
Spec: aigv1a1.AIServiceBackendSpec{
BackendRef: egv1a1.BackendRef{
BackendObjectReference: gwapiv1.BackendObjectReference{Name: "some-backend3", Namespace: ptr.To[gwapiv1.Namespace]("ns")},
},
BackendRef: gwapiv1.BackendObjectReference{Name: "some-backend3", Namespace: ptr.To[gwapiv1.Namespace]("ns")},
},
},
} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,6 @@ spec:

This is required to be set.
properties:
fallback:
description: |-
Fallback indicates whether the backend is designated as a fallback.
Multiple fallback backends can be configured.
It is highly recommended to configure active or passive health checks to ensure that failover can be detected
when the active backends become unhealthy and to automatically readjust once the primary backends are healthy again.
The overprovisioning factor is set to 1.4, meaning the fallback backends will only start receiving traffic when
the health of the active backends falls below 72%.
type: boolean
group:
default: ""
description: |-
Expand Down
8 changes: 4 additions & 4 deletions tests/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ func TestStartControllers(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: backend, Namespace: "default"},
Spec: aigv1a1.AIServiceBackendSpec{
APISchema: defaultSchema,
BackendRef: egv1a1.BackendRef{BackendObjectReference: gwapiv1.BackendObjectReference{
BackendRef: gwapiv1.BackendObjectReference{
Name: gwapiv1.ObjectName(backend),
Port: ptr.To[gwapiv1.PortNumber](8080),
}},
},
},
})
require.NoError(t, err)
Expand Down Expand Up @@ -372,10 +372,10 @@ func TestAIServiceBackendController(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{Name: "mybackend", Namespace: "default"},
Spec: aigv1a1.AIServiceBackendSpec{
APISchema: defaultSchema,
BackendRef: egv1a1.BackendRef{BackendObjectReference: gwapiv1.BackendObjectReference{
BackendRef: gwapiv1.BackendObjectReference{
Name: gwapiv1.ObjectName("mybackend"),
Port: ptr.To[gwapiv1.PortNumber](8080),
}},
},
},
}
err := c.Create(ctx, origin)
Expand Down
Loading