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
6 changes: 3 additions & 3 deletions controllers/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ func UpdateGWListenerStatus(ctx context.Context, k8sclient client.Client, gw *ga
} else {

hasValidListener = true
attachedRoutes := 0

condition := metav1.Condition{
Type: "Accepted",
Expand All @@ -474,7 +473,6 @@ func UpdateGWListenerStatus(ctx context.Context, k8sclient client.Client, gw *ga
*parentRef.Namespace != gateway_api.Namespace(gw.Namespace) {
continue
}
attachedRoutes++

var httpSectionName string
if parentRef.SectionName == nil {
Expand All @@ -487,8 +485,10 @@ func UpdateGWListenerStatus(ctx context.Context, k8sclient client.Client, gw *ga
if httpSectionName != string(listener.Name) {
continue
}
if parentRef.Port != nil && *parentRef.Port != listener.Port {
continue
}
listenerStatus.AttachedRoutes++
attachedRoutes++

}
}
Expand Down
34 changes: 20 additions & 14 deletions controllers/httproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,25 +291,31 @@ func (r *HTTPRouteReconciler) updateHTTPRouteStatus(ctx context.Context, dns str
httprouteOld = httproute.DeepCopy()
if len(httproute.Status.RouteStatus.Parents) == 0 {
httproute.Status.RouteStatus.Parents = make([]gateway_api.RouteParentStatus, 1)
httproute.Status.RouteStatus.Parents[0].Conditions = make([]metav1.Condition, 1)
httproute.Status.RouteStatus.Parents[0].Conditions[0].LastTransitionTime = eventhandlers.ZeroTransitionTime
}

httproute.Status.RouteStatus.Parents[0].ParentRef = httproute.Spec.ParentRefs[0]
httproute.Status.RouteStatus.Parents[0].ControllerName = config.LatticeGatewayControllerName

httproute.Status.RouteStatus.Parents[0].Conditions[0].Type = string(gateway_api.RouteConditionAccepted)
httproute.Status.RouteStatus.Parents[0].Conditions[0].Status = metav1.ConditionTrue
httproute.Status.RouteStatus.Parents[0].Conditions[0].Message = fmt.Sprintf("DNS Name: %s", dns)
httproute.Status.RouteStatus.Parents[0].Conditions[0].Reason = string(gateway_api.RouteReasonAccepted)
httproute.Status.RouteStatus.Parents[0].Conditions[0].ObservedGeneration = httproute.Generation

if httproute.Status.RouteStatus.Parents[0].Conditions[0].LastTransitionTime == eventhandlers.ZeroTransitionTime {
httproute.Status.RouteStatus.Parents[0].Conditions[0].LastTransitionTime = metav1.NewTime(time.Now())
accepted := metav1.Condition{
Type: string(gateway_api.RouteConditionAccepted),
Status: metav1.ConditionTrue,
ObservedGeneration: httproute.Generation,
LastTransitionTime: metav1.NewTime(time.Now()),
Reason: string(gateway_api.RouteReasonAccepted),
Message: fmt.Sprintf("DNS Name: %s", dns),
}
resolvedRefs := metav1.Condition{
Type: string(gateway_api.RouteConditionResolvedRefs),
Status: metav1.ConditionTrue,
ObservedGeneration: httproute.Generation,
LastTransitionTime: metav1.NewTime(time.Now()),
Reason: string(gateway_api.RouteReasonResolvedRefs),
Message: fmt.Sprintf("DNS Name: %s", dns),
}
httproute.Status.RouteStatus.Parents[0].Conditions = []metav1.Condition{
accepted,
resolvedRefs,
}

httproute.Status.RouteStatus.Parents[0].ParentRef.Group = httproute.Spec.ParentRefs[0].Group
httproute.Status.RouteStatus.Parents[0].ParentRef.Kind = httproute.Spec.ParentRefs[0].Kind
httproute.Status.RouteStatus.Parents[0].ParentRef.Name = httproute.Spec.ParentRefs[0].Name

// Update listener Status
UpdateHTTPRouteListenerStatus(ctx, r.Client, httproute)
Expand Down
68 changes: 33 additions & 35 deletions docs/conformance-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,49 @@
| | [GatewayInvalidRouteKind](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-invalid-route-kind.go) | ok |
| | [GatewayWithAttachedRoutes](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-with-attached-routes.go) | ok |
| | | | |
| | [GatewaySecretInvalidReferenceGrants](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-invalid-reference-grant.go) | NA | VPC Lattice supports ACM certs |
| | [GatewaySecretMissingReferenceGrant](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-missing-reference-grant.go) | NA | same as above
| | [GatewaySecretReferenceGrantAllInNamespace](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-reference-grant-all-in-namespace.go) | NA | same as above
| | [GatewaySecretReferenceGrantSpecific](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-reference-grant-specific.go) | NA | same as above
| | [GatewaySecretInvalidReferenceGrants](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-invalid-reference-grant.go) | N/A | VPC Lattice supports ACM certs |
| | [GatewaySecretMissingReferenceGrant](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-missing-reference-grant.go) | N/A | VPC Lattice supports ACM certs |
| | [GatewaySecretReferenceGrantAllInNamespace](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-reference-grant-all-in-namespace.go) | N/A | VPC Lattice supports ACM Certs |
| | [GatewaySecretReferenceGrantSpecific](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-reference-grant-specific.go) | N/A | VPC Lattice supports ACM certs |
| | | | |
| HTTPRoute | [HTTPRouteCrossNamespace](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-cross-namespace.go) | ok |
| | [HTTPExactPathMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-exact-path-matching.go) | ok |
| | [HTTPRouteHeaderMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-header-matching.go) | ok |
| | [HTTPRouteHeaderMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-header-matching.go) | fail | Test data exceeds Lattice limit on # of rules |
| | [HTTPRouteSimpleSameNamespace](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-simple-same-namespace.go) | ok |
| | [HTTPRouteListenerHostnameMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-listener-hostname-matching.go) | ok |
| | [HTTPRouteMatchingAcrossRoutes](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-matching-across-routes.go) | ok |
| | [HTTPRouteMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-matching.go) | ok |
| | [HTTPRouteListenerHostnameMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-listener-hostname-matching.go) | N/A | Listener hostname not supported |
| | [HTTPRouteMatchingAcrossRoutes](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-matching-across-routes.go) | N/A | Custom domain name conflict not allowed |
| | [HTTPRouteMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-matching.go) | fail | Route precedence |
| | [HTTPRouteObservedGenerationBump](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-observed-generation-bump.go) | ok |
| | [HTTPRoutePathMatchOrder](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-path-match-order.go) | ok |
| | [HTTPRouteReferenceGrant](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-reference-grant.go) | ok |
| | [HTTPRouteDisallowedKind](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-disallowed-kind.go) | ok |
| | [HTTPRouteInvalidNonExistentBackendRef](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-backendref-nonexistent.go) | ok |
| | [HTTPRouteInvalidBackendRefUnknownKind](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-backendref-unknown-kind.go) | ok |
| | [HTTPRouteInvalidCrossNamespaceBackendRef](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-cross-namespace-backend-ref.go) | ok |
| | [HTTPRouteInvalidCrossNamespaceParentRef](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go) | ok |
| | [HTTPRouteInvalidParentRefNotMatchingListenerPort](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-parentref-not-matching-listener-port.go) | ok |
| | [HTTPRouteInvalidParentRefNotMatchingSectionName](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-parentref-not-matching-section-name.go) | ok |
| | [HTTPRoutePathMatchOrder](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-path-match-order.go) | fail | Test data exceeds Lattice limit on # of rules |
| | [HTTPRouteReferenceGrant](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-reference-grant.go) | N/A |
| | [HTTPRouteDisallowedKind](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-disallowed-kind.go) | N/A | Only HTTPRoute is supported |
| | [HTTPRouteInvalidNonExistentBackendRef](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-backendref-nonexistent.go) | fail | [#277](https://github.com/aws/aws-application-networking-k8s/issues/277) |
| | [HTTPRouteInvalidBackendRefUnknownKind](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-backendref-unknown-kind.go) | fail | [#277](https://github.com/aws/aws-application-networking-k8s/issues/277) |
| | [HTTPRouteInvalidCrossNamespaceBackendRef](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-cross-namespace-backend-ref.go) | fail | [#277](https://github.com/aws/aws-application-networking-k8s/issues/277) |
| | [HTTPRouteInvalidCrossNamespaceParentRef](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go) | fail | [#277](https://github.com/aws/aws-application-networking-k8s/issues/277) |
| | [HTTPRouteInvalidParentRefNotMatchingListenerPort](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-parentref-not-matching-listener-port.go) | fail | [#277](https://github.com/aws/aws-application-networking-k8s/issues/277) |
| | [HTTPRouteInvalidParentRefNotMatchingSectionName](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-parentref-not-matching-section-name.go) | fail | [#277](https://github.com/aws/aws-application-networking-k8s/issues/277) |
| | | | |
| | [HTTPRouteMethodMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-method-matching.go) | nok | not support in controller yet. [#123](https://github.com/aws/aws-application-networking-k8s/issues/123) |
| | [HTTPRouteMethodMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-method-matching.go) | fail | not supported in controller yet. [#123](https://github.com/aws/aws-application-networking-k8s/issues/123) |
| | | | |
| | [HTTPRouteHostnameIntersection](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-hostname-intersection.go) | NA | VPC lattice only support one hostname for BYOC
| | HTTPRouteQueryParamMatching | NA | Not supported by lattice |
| | HTTPRouteRedirectHostAndStatus | NA | same as above |
| | HTTPRouteRedirectPath | NA | same as above |
| | HTTPRouteRedirectPort | NA | same as above |
| | HTTPRouteRedirectScheme | NA | same as above |
| | HTTPRouteRequestHeaderModifier | NA | same as above |
| | HTTPRouteResponseHeaderModifier | NA | same as above |
| | HTTPRouteRewriteHost | NA | same as above |
| | HTTPRouteRewritePath | NA | same as above |
| | [HTTPRouteHostnameIntersection](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-hostname-intersection.go) | N/A | VPC lattice only supports one custom domain |
| | HTTPRouteQueryParamMatching | N/A | Not supported by lattice |
| | HTTPRouteRedirectHostAndStatus | N/A | Not supported by lattice |
| | HTTPRouteRedirectPath | N/A | Not supported by lattice |
| | HTTPRouteRedirectPort | N/A | Not supported by lattice |
| | HTTPRouteRedirectScheme | N/A | Not supported by lattice |
| | HTTPRouteRequestHeaderModifier | N/A | Not supported by lattice |
| | HTTPRouteResponseHeaderModifier | N/A | Not supported by lattice |
| | HTTPRouteRewriteHost | N/A | Not supported by lattice |
| | HTTPRouteRewritePath | N/A | Not supported by lattice |

## Running Gateway API Conformance

### Running controller from cloud desktop

```
# create a gateway first in the cluster
kubectl apply -f example my-hotel-gateway.yaml
kubectl apply -f examples/my-hotel-gateway.yaml

# run controller in following mode

Expand All @@ -63,13 +63,11 @@ make run

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: can you change
kubectl apply -f example my-hotel-gateway.yaml to
kubectl apply -f examples/my-hotel-gateway.yaml ?

### Run individual conformance test

```
#
# go test ./conformance/... --run TestConformance/<ShortName>

Conformance tests directly send traffic, so they should run inside the VPC that the cluster is operating on.

go test ./conformance/... --run TestConformance/HTTPRouteInvalidParentRefNotMatchingSectionName \
-args -gateway-class=amazon-vpc-lattice
```
go test ./conformance/ --run "TestConformance/HTTPRouteCrossNamespace$" -v -args -gateway-class amazon-vpc-lattice \
-supported-features Gateway,HTTPRoute,GatewayClassObservedGenerationBump

```

Expand Down
6 changes: 4 additions & 2 deletions pkg/deploy/lattice/listener_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"context"
"errors"
"fmt"
"github.com/golang/glog"
"strings"

"github.com/golang/glog"

"github.com/aws/aws-application-networking-k8s/pkg/utils"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/vpclattice"

Expand Down Expand Up @@ -107,7 +109,7 @@ func k8s2LatticeName(name string, namespace string) string {
}

func k8sLatticeListenerName(name string, namespace string, port int, protocol string) string {
listenerName := fmt.Sprintf("%s-%s-%d-%s", name, namespace, port, strings.ToLower(protocol))
listenerName := fmt.Sprintf("%s-%s-%d-%s", utils.Truncate(name, 20), utils.Truncate(namespace, 18), port, strings.ToLower(protocol))

return listenerName
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/deploy/lattice/service_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package lattice
import (
"context"
"errors"

"github.com/golang/glog"

"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -51,7 +52,7 @@ func NewServiceManager(cloud lattice_aws.Cloud, latticeDataStore *latticestore.L
func (s *defaultServiceManager) Create(ctx context.Context, service *latticemodel.Service) (latticemodel.ServiceStatus, error) {

// check if exists
svcName := latticestore.AWSServiceName(service.Spec.Name, service.Spec.Namespace)
svcName := latticestore.LatticeServiceName(service.Spec.Name, service.Spec.Namespace)
serviceSummary, err := s.findServiceByName(ctx, svcName)
if err != nil {
return latticemodel.ServiceStatus{ServiceARN: "", ServiceID: ""}, err
Expand Down Expand Up @@ -194,7 +195,7 @@ func (s *defaultServiceManager) Delete(ctx context.Context, service *latticemode

latticeSess := s.cloud.Lattice()

svcName := latticestore.AWSServiceName(service.Spec.Name, service.Spec.Namespace)
svcName := latticestore.LatticeServiceName(service.Spec.Name, service.Spec.Namespace)
serviceSummary, err := s.findServiceByName(ctx, svcName)
if err != nil || serviceSummary == nil {
glog.V(6).Infof("defaultServiceManager: Deleting unknown service %v\n", service.Spec.Name)
Expand Down
16 changes: 9 additions & 7 deletions pkg/deploy/lattice/service_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"context"
"errors"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"testing"

"github.com/aws/aws-sdk-go/service/vpclattice"
"github.com/aws/aws-sdk-go/aws"

"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"

"github.com/aws/aws-sdk-go/service/vpclattice"

mocks_aws "github.com/aws/aws-application-networking-k8s/pkg/aws"
mocks "github.com/aws/aws-application-networking-k8s/pkg/aws/services"
"github.com/aws/aws-application-networking-k8s/pkg/config"
Expand Down Expand Up @@ -59,7 +61,7 @@ func Test_Create_ValidateService(t *testing.T) {
latticeDataStore.AddServiceNetwork(tt.meshName, config.AccountID, tt.meshArn, tt.meshId, latticestore.DATASTORE_SERVICE_NETWORK_CREATED)
mockCloud := mocks_aws.NewMockCloud(c)

SVCName := latticestore.AWSServiceName(tt.wantServiceName, "default")
SVCName := latticestore.LatticeServiceName(tt.wantServiceName, "default")
createServiceOutput := &vpclattice.CreateServiceOutput{
Arn: &tt.wantServiceArn,
Id: &tt.wantServiceId,
Expand Down Expand Up @@ -360,7 +362,7 @@ func Test_Create_MeshServiceAssociation(t *testing.T) {
},
Status: &latticemodel.ServiceStatus{ServiceARN: "", ServiceID: ""},
}
SVCName := latticestore.AWSServiceName(tt.wantServiceName, "default")
SVCName := latticestore.LatticeServiceName(tt.wantServiceName, "default")
tt.wantListServiceOutput = append(tt.wantListServiceOutput, &vpclattice.ServiceSummary{
Arn: &tt.wantServiceArn,
Id: &tt.wantServiceId,
Expand Down Expand Up @@ -443,7 +445,7 @@ func Test_Create_Check(t *testing.T) {
},
Status: &latticemodel.ServiceStatus{ServiceARN: "", ServiceID: ""},
}
SVCName := latticestore.AWSServiceName(tt.wantServiceName, "default")
SVCName := latticestore.LatticeServiceName(tt.wantServiceName, "default")
tt.wantListServiceOutput = append(tt.wantListServiceOutput, &vpclattice.ServiceSummary{
Arn: &tt.wantServiceArn,
Id: &tt.wantServiceId,
Expand Down Expand Up @@ -509,7 +511,7 @@ func Test_Delete_ValidateInput(t *testing.T) {
latticeDataStore.AddServiceNetwork(tt.meshName, config.AccountID, tt.meshArn, tt.meshId, latticestore.DATASTORE_SERVICE_NETWORK_CREATED)
mockCloud := mocks_aws.NewMockCloud(c)

SVCName := latticestore.AWSServiceName(tt.wantServiceName, "default")
SVCName := latticestore.LatticeServiceName(tt.wantServiceName, "default")
tt.wantListServiceOutput = append(tt.wantListServiceOutput, &vpclattice.ServiceSummary{
Arn: &tt.wantServiceArn,
Id: &tt.wantServiceId,
Expand Down Expand Up @@ -624,7 +626,7 @@ func Test_Delete_Disassociation_DeleteService(t *testing.T) {
latticeDataStore.AddServiceNetwork(tt.meshName, config.AccountID, tt.meshArn, tt.meshId, latticestore.DATASTORE_SERVICE_NETWORK_CREATED)
mockCloud := mocks_aws.NewMockCloud(c)

SVCName := latticestore.AWSServiceName(tt.wantServiceName, "default")
SVCName := latticestore.LatticeServiceName(tt.wantServiceName, "default")
tt.wantListServiceOutput = append(tt.wantListServiceOutput, &vpclattice.ServiceSummary{
Arn: &tt.wantServiceArn,
Id: &tt.wantServiceId,
Expand Down
16 changes: 8 additions & 8 deletions pkg/latticestore/latticestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ package latticestore
import (
"errors"
"fmt"
"github.com/golang/glog"
"sync"

"github.com/golang/glog"

"github.com/aws/aws-application-networking-k8s/pkg/utils"
)

// ERROR CODE
Expand Down Expand Up @@ -293,18 +296,15 @@ func (ds *LatticeDataStore) GetLatticeService(name string, namespace string) (La

// the max tg name length is 127
func TargetGroupName(name string, namespace string) string {
return fmt.Sprintf("k8s-%0.20s-%0.20s", name, namespace)
return fmt.Sprintf("k8s-%s-%s", utils.Truncate(name, 20), utils.Truncate(namespace, 20))
}

func TargetGroupLongName(k8sName string, routeName string, vpcid string) string {
return fmt.Sprintf("k8s-%0.40s-%0.20s-%0.20s", k8sName, routeName, vpcid)
return fmt.Sprintf("%s-%s-%s", k8sName, utils.Truncate(routeName, 20), utils.Truncate(vpcid, 20))
}

// TODO , find out a good name
// AWSserviceName, or VSNServiceName or LatticeServiceName
// the max name length is 40
func AWSServiceName(name string, namespace string) string {
return fmt.Sprintf("%0.20s-%0.18s", name, namespace)
func LatticeServiceName(name string, namespace string) string {
return fmt.Sprintf("%s-%s", utils.Truncate(name, 20), utils.Truncate(namespace, 18))
}

func (ds *LatticeDataStore) AddTargetGroup(name string, vpc string, arn string, tgID string,
Expand Down
Loading