Skip to content

Commit 2631856

Browse files
author
Doyoon Kim
authored
Update resource naming and conformance (#275)
* Remove conformance test blockers * Add parentRef port matching * Update conformance test docs
1 parent 27bf5a6 commit 2631856

15 files changed

+133
-107
lines changed

controllers/gateway_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ func UpdateGWListenerStatus(ctx context.Context, k8sclient client.Client, gw *ga
449449
} else {
450450

451451
hasValidListener = true
452-
attachedRoutes := 0
453452

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

479477
var httpSectionName string
480478
if parentRef.SectionName == nil {
@@ -487,8 +485,10 @@ func UpdateGWListenerStatus(ctx context.Context, k8sclient client.Client, gw *ga
487485
if httpSectionName != string(listener.Name) {
488486
continue
489487
}
488+
if parentRef.Port != nil && *parentRef.Port != listener.Port {
489+
continue
490+
}
490491
listenerStatus.AttachedRoutes++
491-
attachedRoutes++
492492

493493
}
494494
}

controllers/httproute_controller.go

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -291,25 +291,31 @@ func (r *HTTPRouteReconciler) updateHTTPRouteStatus(ctx context.Context, dns str
291291
httprouteOld = httproute.DeepCopy()
292292
if len(httproute.Status.RouteStatus.Parents) == 0 {
293293
httproute.Status.RouteStatus.Parents = make([]gateway_api.RouteParentStatus, 1)
294-
httproute.Status.RouteStatus.Parents[0].Conditions = make([]metav1.Condition, 1)
295-
httproute.Status.RouteStatus.Parents[0].Conditions[0].LastTransitionTime = eventhandlers.ZeroTransitionTime
296294
}
297295

296+
httproute.Status.RouteStatus.Parents[0].ParentRef = httproute.Spec.ParentRefs[0]
298297
httproute.Status.RouteStatus.Parents[0].ControllerName = config.LatticeGatewayControllerName
299298

300-
httproute.Status.RouteStatus.Parents[0].Conditions[0].Type = string(gateway_api.RouteConditionAccepted)
301-
httproute.Status.RouteStatus.Parents[0].Conditions[0].Status = metav1.ConditionTrue
302-
httproute.Status.RouteStatus.Parents[0].Conditions[0].Message = fmt.Sprintf("DNS Name: %s", dns)
303-
httproute.Status.RouteStatus.Parents[0].Conditions[0].Reason = string(gateway_api.RouteReasonAccepted)
304-
httproute.Status.RouteStatus.Parents[0].Conditions[0].ObservedGeneration = httproute.Generation
305-
306-
if httproute.Status.RouteStatus.Parents[0].Conditions[0].LastTransitionTime == eventhandlers.ZeroTransitionTime {
307-
httproute.Status.RouteStatus.Parents[0].Conditions[0].LastTransitionTime = metav1.NewTime(time.Now())
299+
accepted := metav1.Condition{
300+
Type: string(gateway_api.RouteConditionAccepted),
301+
Status: metav1.ConditionTrue,
302+
ObservedGeneration: httproute.Generation,
303+
LastTransitionTime: metav1.NewTime(time.Now()),
304+
Reason: string(gateway_api.RouteReasonAccepted),
305+
Message: fmt.Sprintf("DNS Name: %s", dns),
306+
}
307+
resolvedRefs := metav1.Condition{
308+
Type: string(gateway_api.RouteConditionResolvedRefs),
309+
Status: metav1.ConditionTrue,
310+
ObservedGeneration: httproute.Generation,
311+
LastTransitionTime: metav1.NewTime(time.Now()),
312+
Reason: string(gateway_api.RouteReasonResolvedRefs),
313+
Message: fmt.Sprintf("DNS Name: %s", dns),
314+
}
315+
httproute.Status.RouteStatus.Parents[0].Conditions = []metav1.Condition{
316+
accepted,
317+
resolvedRefs,
308318
}
309-
310-
httproute.Status.RouteStatus.Parents[0].ParentRef.Group = httproute.Spec.ParentRefs[0].Group
311-
httproute.Status.RouteStatus.Parents[0].ParentRef.Kind = httproute.Spec.ParentRefs[0].Kind
312-
httproute.Status.RouteStatus.Parents[0].ParentRef.Name = httproute.Spec.ParentRefs[0].Name
313319

314320
// Update listener Status
315321
UpdateHTTPRouteListenerStatus(ctx, r.Client, httproute)

docs/conformance-test.md

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,49 @@
1111
| | [GatewayInvalidRouteKind](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-invalid-route-kind.go) | ok |
1212
| | [GatewayWithAttachedRoutes](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-with-attached-routes.go) | ok |
1313
| | | | |
14-
| | [GatewaySecretInvalidReferenceGrants](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-invalid-reference-grant.go) | NA | VPC Lattice supports ACM certs |
15-
| | [GatewaySecretMissingReferenceGrant](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-missing-reference-grant.go) | NA | same as above
16-
| | [GatewaySecretReferenceGrantAllInNamespace](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-reference-grant-all-in-namespace.go) | NA | same as above
17-
| | [GatewaySecretReferenceGrantSpecific](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/gateway-secret-reference-grant-specific.go) | NA | same as above
14+
| | [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 |
15+
| | [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 |
16+
| | [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 |
17+
| | [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 |
1818
| | | | |
1919
| HTTPRoute | [HTTPRouteCrossNamespace](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-cross-namespace.go) | ok |
2020
| | [HTTPExactPathMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-exact-path-matching.go) | ok |
21-
| | [HTTPRouteHeaderMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-header-matching.go) | ok |
21+
| | [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 |
2222
| | [HTTPRouteSimpleSameNamespace](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-simple-same-namespace.go) | ok |
23-
| | [HTTPRouteListenerHostnameMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-listener-hostname-matching.go) | ok |
24-
| | [HTTPRouteMatchingAcrossRoutes](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-matching-across-routes.go) | ok |
25-
| | [HTTPRouteMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-matching.go) | ok |
23+
| | [HTTPRouteListenerHostnameMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-listener-hostname-matching.go) | N/A | Listener hostname not supported |
24+
| | [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 |
25+
| | [HTTPRouteMatching](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-matching.go) | fail | Route precedence |
2626
| | [HTTPRouteObservedGenerationBump](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-observed-generation-bump.go) | ok |
27-
| | [HTTPRoutePathMatchOrder](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-path-match-order.go) | ok |
28-
| | [HTTPRouteReferenceGrant](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-reference-grant.go) | ok |
29-
| | [HTTPRouteDisallowedKind](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-disallowed-kind.go) | ok |
30-
| | [HTTPRouteInvalidNonExistentBackendRef](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-backendref-nonexistent.go) | ok |
31-
| | [HTTPRouteInvalidBackendRefUnknownKind](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-backendref-unknown-kind.go) | ok |
32-
| | [HTTPRouteInvalidCrossNamespaceBackendRef](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-cross-namespace-backend-ref.go) | ok |
33-
| | [HTTPRouteInvalidCrossNamespaceParentRef](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-cross-namespace-parent-ref.go) | ok |
34-
| | [HTTPRouteInvalidParentRefNotMatchingListenerPort](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-parentref-not-matching-listener-port.go) | ok |
35-
| | [HTTPRouteInvalidParentRefNotMatchingSectionName](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-invalid-parentref-not-matching-section-name.go) | ok |
27+
| | [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 |
28+
| | [HTTPRouteReferenceGrant](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-reference-grant.go) | N/A |
29+
| | [HTTPRouteDisallowedKind](https://github.com/kubernetes-sigs/gateway-api/blob/main/conformance/tests/httproute-disallowed-kind.go) | N/A | Only HTTPRoute is supported |
30+
| | [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) |
31+
| | [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) |
32+
| | [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) |
33+
| | [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) |
34+
| | [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) |
35+
| | [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) |
3636
| | | | |
37-
| | [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) |
37+
| | [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) |
3838
| | | | |
39-
| | [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
40-
| | HTTPRouteQueryParamMatching | NA | Not supported by lattice |
41-
| | HTTPRouteRedirectHostAndStatus | NA | same as above |
42-
| | HTTPRouteRedirectPath | NA | same as above |
43-
| | HTTPRouteRedirectPort | NA | same as above |
44-
| | HTTPRouteRedirectScheme | NA | same as above |
45-
| | HTTPRouteRequestHeaderModifier | NA | same as above |
46-
| | HTTPRouteResponseHeaderModifier | NA | same as above |
47-
| | HTTPRouteRewriteHost | NA | same as above |
48-
| | HTTPRouteRewritePath | NA | same as above |
39+
| | [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 |
40+
| | HTTPRouteQueryParamMatching | N/A | Not supported by lattice |
41+
| | HTTPRouteRedirectHostAndStatus | N/A | Not supported by lattice |
42+
| | HTTPRouteRedirectPath | N/A | Not supported by lattice |
43+
| | HTTPRouteRedirectPort | N/A | Not supported by lattice |
44+
| | HTTPRouteRedirectScheme | N/A | Not supported by lattice |
45+
| | HTTPRouteRequestHeaderModifier | N/A | Not supported by lattice |
46+
| | HTTPRouteResponseHeaderModifier | N/A | Not supported by lattice |
47+
| | HTTPRouteRewriteHost | N/A | Not supported by lattice |
48+
| | HTTPRouteRewritePath | N/A | Not supported by lattice |
4949

5050
## Running Gateway API Conformance
5151

5252
### Running controller from cloud desktop
5353

5454
```
5555
# create a gateway first in the cluster
56-
kubectl apply -f example my-hotel-gateway.yaml
56+
kubectl apply -f examples/my-hotel-gateway.yaml
5757
5858
# run controller in following mode
5959
@@ -63,13 +63,11 @@ make run
6363

6464
### Run individual conformance test
6565

66-
```
67-
#
68-
# go test ./conformance/... --run TestConformance/<ShortName>
69-
66+
Conformance tests directly send traffic, so they should run inside the VPC that the cluster is operating on.
7067

71-
go test ./conformance/... --run TestConformance/HTTPRouteInvalidParentRefNotMatchingSectionName \
72-
-args -gateway-class=amazon-vpc-lattice
68+
```
69+
go test ./conformance/ --run "TestConformance/HTTPRouteCrossNamespace$" -v -args -gateway-class amazon-vpc-lattice \
70+
-supported-features Gateway,HTTPRoute,GatewayClassObservedGenerationBump
7371
7472
```
7573

pkg/deploy/lattice/listener_manager.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"github.com/golang/glog"
87
"strings"
98

9+
"github.com/golang/glog"
10+
11+
"github.com/aws/aws-application-networking-k8s/pkg/utils"
1012
"github.com/aws/aws-sdk-go/aws"
1113
"github.com/aws/aws-sdk-go/service/vpclattice"
1214

@@ -107,7 +109,7 @@ func k8s2LatticeName(name string, namespace string) string {
107109
}
108110

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

112114
return listenerName
113115
}

pkg/deploy/lattice/service_manager.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package lattice
33
import (
44
"context"
55
"errors"
6+
67
"github.com/golang/glog"
78

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

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

195196
latticeSess := s.cloud.Lattice()
196197

197-
svcName := latticestore.AWSServiceName(service.Spec.Name, service.Spec.Namespace)
198+
svcName := latticestore.LatticeServiceName(service.Spec.Name, service.Spec.Namespace)
198199
serviceSummary, err := s.findServiceByName(ctx, svcName)
199200
if err != nil || serviceSummary == nil {
200201
glog.V(6).Infof("defaultServiceManager: Deleting unknown service %v\n", service.Spec.Name)

pkg/deploy/lattice/service_manager_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"github.com/aws/aws-sdk-go/aws"
87
"testing"
98

10-
"github.com/aws/aws-sdk-go/service/vpclattice"
9+
"github.com/aws/aws-sdk-go/aws"
10+
1111
"github.com/golang/mock/gomock"
1212
"github.com/stretchr/testify/assert"
1313

14+
"github.com/aws/aws-sdk-go/service/vpclattice"
15+
1416
mocks_aws "github.com/aws/aws-application-networking-k8s/pkg/aws"
1517
mocks "github.com/aws/aws-application-networking-k8s/pkg/aws/services"
1618
"github.com/aws/aws-application-networking-k8s/pkg/config"
@@ -59,7 +61,7 @@ func Test_Create_ValidateService(t *testing.T) {
5961
latticeDataStore.AddServiceNetwork(tt.meshName, config.AccountID, tt.meshArn, tt.meshId, latticestore.DATASTORE_SERVICE_NETWORK_CREATED)
6062
mockCloud := mocks_aws.NewMockCloud(c)
6163

62-
SVCName := latticestore.AWSServiceName(tt.wantServiceName, "default")
64+
SVCName := latticestore.LatticeServiceName(tt.wantServiceName, "default")
6365
createServiceOutput := &vpclattice.CreateServiceOutput{
6466
Arn: &tt.wantServiceArn,
6567
Id: &tt.wantServiceId,
@@ -360,7 +362,7 @@ func Test_Create_MeshServiceAssociation(t *testing.T) {
360362
},
361363
Status: &latticemodel.ServiceStatus{ServiceARN: "", ServiceID: ""},
362364
}
363-
SVCName := latticestore.AWSServiceName(tt.wantServiceName, "default")
365+
SVCName := latticestore.LatticeServiceName(tt.wantServiceName, "default")
364366
tt.wantListServiceOutput = append(tt.wantListServiceOutput, &vpclattice.ServiceSummary{
365367
Arn: &tt.wantServiceArn,
366368
Id: &tt.wantServiceId,
@@ -443,7 +445,7 @@ func Test_Create_Check(t *testing.T) {
443445
},
444446
Status: &latticemodel.ServiceStatus{ServiceARN: "", ServiceID: ""},
445447
}
446-
SVCName := latticestore.AWSServiceName(tt.wantServiceName, "default")
448+
SVCName := latticestore.LatticeServiceName(tt.wantServiceName, "default")
447449
tt.wantListServiceOutput = append(tt.wantListServiceOutput, &vpclattice.ServiceSummary{
448450
Arn: &tt.wantServiceArn,
449451
Id: &tt.wantServiceId,
@@ -509,7 +511,7 @@ func Test_Delete_ValidateInput(t *testing.T) {
509511
latticeDataStore.AddServiceNetwork(tt.meshName, config.AccountID, tt.meshArn, tt.meshId, latticestore.DATASTORE_SERVICE_NETWORK_CREATED)
510512
mockCloud := mocks_aws.NewMockCloud(c)
511513

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

627-
SVCName := latticestore.AWSServiceName(tt.wantServiceName, "default")
629+
SVCName := latticestore.LatticeServiceName(tt.wantServiceName, "default")
628630
tt.wantListServiceOutput = append(tt.wantListServiceOutput, &vpclattice.ServiceSummary{
629631
Arn: &tt.wantServiceArn,
630632
Id: &tt.wantServiceId,

pkg/latticestore/latticestore.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@ package latticestore
33
import (
44
"errors"
55
"fmt"
6-
"github.com/golang/glog"
76
"sync"
7+
8+
"github.com/golang/glog"
9+
10+
"github.com/aws/aws-application-networking-k8s/pkg/utils"
811
)
912

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

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

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

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

310310
func (ds *LatticeDataStore) AddTargetGroup(name string, vpc string, arn string, tgID string,

0 commit comments

Comments
 (0)