Skip to content
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
5 changes: 5 additions & 0 deletions internal/provider/kubernetes/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ func (r *gatewayAPIReconciler) getNamespace(ctx context.Context, name string) (*
}

func (r *gatewayAPIReconciler) statusUpdateForGateway(gtw *gwapiv1b1.Gateway, svc *corev1.Service, deploy *appsv1.Deployment) {
// nil check for unit tests.
if r.statusUpdater == nil {
return
}

// update scheduled condition
status.UpdateGatewayStatusScheduledCondition(gtw, true)
// update address field and ready condition
Expand Down
51 changes: 11 additions & 40 deletions internal/provider/kubernetes/kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/envoyproxy/gateway/internal/envoygateway/config"
"github.com/envoyproxy/gateway/internal/gatewayapi"
"github.com/envoyproxy/gateway/internal/message"
"github.com/envoyproxy/gateway/internal/provider/kubernetes/test"
)

const (
Expand Down Expand Up @@ -92,40 +93,10 @@ func startEnv() (*envtest.Environment, *rest.Config, error) {
return env, cfg, nil
}

func getGatewayClass(name string) *gwapiv1b1.GatewayClass {
return &gwapiv1b1.GatewayClass{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: gwapiv1b1.GatewayClassSpec{
ControllerName: gwapiv1b1.GatewayController(v1alpha1.GatewayControllerName),
},
}
}

func getService(name, namespace string, ports map[string]int32) *corev1.Service {
service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{},
},
}
for name, port := range ports {
service.Spec.Ports = append(service.Spec.Ports, corev1.ServicePort{
Name: name,
Port: port,
})
}
return service
}

func testGatewayClassController(ctx context.Context, t *testing.T, provider *Provider, resources *message.ProviderResources) {
cli := provider.manager.GetClient()

gc := getGatewayClass("test-gc-controllername")
gc := test.GetGatewayClass("test-gc-controllername", v1alpha1.GatewayControllerName)
require.NoError(t, cli.Create(ctx, gc))

defer func() {
Expand All @@ -141,7 +112,7 @@ func testGatewayClassController(ctx context.Context, t *testing.T, provider *Pro
func testGatewayClassAcceptedStatus(ctx context.Context, t *testing.T, provider *Provider, resources *message.ProviderResources) {
cli := provider.manager.GetClient()

gc := getGatewayClass("test-gc-accepted-status")
gc := test.GetGatewayClass("test-gc-accepted-status", v1alpha1.GatewayControllerName)
require.NoError(t, cli.Create(ctx, gc))

defer func() {
Expand Down Expand Up @@ -173,7 +144,7 @@ func testGatewayClassAcceptedStatus(ctx context.Context, t *testing.T, provider
func testGatewayScheduledStatus(ctx context.Context, t *testing.T, provider *Provider, resources *message.ProviderResources) {
cli := provider.manager.GetClient()

gc := getGatewayClass("gc-scheduled-status-test")
gc := test.GetGatewayClass("gc-scheduled-status-test", v1alpha1.GatewayControllerName)
require.NoError(t, cli.Create(ctx, gc))

// Ensure the GatewayClass reports "Ready".
Expand Down Expand Up @@ -326,7 +297,7 @@ func testGatewayScheduledStatus(ctx context.Context, t *testing.T, provider *Pro
func testLongNameHashedResources(ctx context.Context, t *testing.T, provider *Provider, resources *message.ProviderResources) {
cli := provider.manager.GetClient()

gc := getGatewayClass("envoy-gateway-class")
gc := test.GetGatewayClass("envoy-gateway-class", v1alpha1.GatewayControllerName)
require.NoError(t, cli.Create(ctx, gc))

// Ensure the GatewayClass reports "Ready".
Expand Down Expand Up @@ -428,7 +399,7 @@ func testLongNameHashedResources(ctx context.Context, t *testing.T, provider *Pr
func testHTTPRoute(ctx context.Context, t *testing.T, provider *Provider, resources *message.ProviderResources) {
cli := provider.manager.GetClient()

gc := getGatewayClass("httproute-test")
gc := test.GetGatewayClass("httproute-test", v1alpha1.GatewayControllerName)
require.NoError(t, cli.Create(ctx, gc))

// Ensure the GatewayClass reports ready.
Expand Down Expand Up @@ -476,7 +447,7 @@ func testHTTPRoute(ctx context.Context, t *testing.T, provider *Provider, resour
require.NoError(t, cli.Delete(ctx, gw))
}()

svc := getService("test", ns.Name, map[string]int32{
svc := test.GetService(types.NamespacedName{Namespace: ns.Name, Name: "test"}, nil, map[string]int32{
"http": 80,
"https": 443,
})
Expand Down Expand Up @@ -768,7 +739,7 @@ func testHTTPRoute(ctx context.Context, t *testing.T, provider *Provider, resour
func testTLSRoute(ctx context.Context, t *testing.T, provider *Provider, resources *message.ProviderResources) {
cli := provider.manager.GetClient()

gc := getGatewayClass("tlsroute-test")
gc := test.GetGatewayClass("tlsroute-test", v1alpha1.GatewayControllerName)
require.NoError(t, cli.Create(ctx, gc))

defer func() {
Expand Down Expand Up @@ -801,7 +772,7 @@ func testTLSRoute(ctx context.Context, t *testing.T, provider *Provider, resourc
require.NoError(t, cli.Delete(ctx, gw))
}()

svc := getService("test", ns.Name, map[string]int32{
svc := test.GetService(types.NamespacedName{Namespace: ns.Name, Name: "test"}, nil, map[string]int32{
"tls": 90,
})
require.NoError(t, cli.Create(ctx, svc))
Expand Down Expand Up @@ -909,7 +880,7 @@ func testTLSRoute(ctx context.Context, t *testing.T, provider *Provider, resourc
func testServiceCleanupForMultipleRoutes(ctx context.Context, t *testing.T, provider *Provider, resources *message.ProviderResources) {
cli := provider.manager.GetClient()

gc := getGatewayClass("service-cleanup-test")
gc := test.GetGatewayClass("service-cleanup-test", v1alpha1.GatewayControllerName)
require.NoError(t, cli.Create(ctx, gc))
defer func() {
require.NoError(t, cli.Delete(ctx, gc))
Expand Down Expand Up @@ -945,7 +916,7 @@ func testServiceCleanupForMultipleRoutes(ctx context.Context, t *testing.T, prov
require.NoError(t, cli.Delete(ctx, gw))
}()

svc := getService("test-common-svc", ns.Name, map[string]int32{
svc := test.GetService(types.NamespacedName{Namespace: ns.Name, Name: "test-common-svc"}, nil, map[string]int32{
"http": 80,
"tls": 90,
})
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/kubernetes/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (r *gatewayAPIReconciler) validateServiceForReconcile(obj client.Object) bo
}

r.statusUpdateForGateway(gtw, svc, deployment)
return true
return false
Comment thread
danehans marked this conversation as resolved.
}

httpRouteList := &gwapiv1b1.HTTPRouteList{}
Expand Down
Loading